Home | History | Annotate | Download | only in canvas
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "config.h"
      6 #include "core/html/canvas/WebGLSharedWebGraphicsContext3D.h"
      7 
      8 #if ENABLE(OILPAN)
      9 #include "platform/graphics/gpu/DrawingBuffer.h"
     10 #include "public/platform/WebGraphicsContext3D.h"
     11 
     12 namespace blink {
     13 
     14 PassRefPtr<WebGLSharedWebGraphicsContext3D> WebGLSharedWebGraphicsContext3D::create(PassRefPtr<DrawingBuffer> buffer)
     15 {
     16     return adoptRef(new WebGLSharedWebGraphicsContext3D(buffer));
     17 }
     18 
     19 WebGLSharedWebGraphicsContext3D::WebGLSharedWebGraphicsContext3D(PassRefPtr<DrawingBuffer> buffer)
     20     : m_buffer(buffer)
     21 {
     22 }
     23 
     24 WebGLSharedWebGraphicsContext3D::~WebGLSharedWebGraphicsContext3D()
     25 {
     26     dispose();
     27 }
     28 
     29 void WebGLSharedWebGraphicsContext3D::dispose()
     30 {
     31     if (m_buffer) {
     32         m_buffer->beginDestruction();
     33         m_buffer.clear();
     34     }
     35 }
     36 
     37 void WebGLSharedWebGraphicsContext3D::update(PassRefPtr<DrawingBuffer> buffer)
     38 {
     39     m_buffer = buffer;
     40 }
     41 
     42 DrawingBuffer* WebGLSharedWebGraphicsContext3D::drawingBuffer() const
     43 {
     44     return m_buffer.get();
     45 }
     46 
     47 blink::WebGraphicsContext3D* WebGLSharedWebGraphicsContext3D::webContext() const
     48 {
     49     return m_buffer ? m_buffer->context() : 0;
     50 }
     51 
     52 } // namespace blink
     53 
     54 #endif // ENABLE(OILPAN)
     55