 Chromium Code Reviews
 Chromium Code Reviews Issue 163773007:
  WebGL: Transfer ownership of WebGraphicsContext3D from WebGLRenderingContext to DrawingBuffer.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@correct_webgl_destroy
    
  
    Issue 163773007:
  WebGL: Transfer ownership of WebGraphicsContext3D from WebGLRenderingContext to DrawingBuffer.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@correct_webgl_destroy| Index: Source/core/html/canvas/WebGLRenderingContextBase.cpp | 
| diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.cpp b/Source/core/html/canvas/WebGLRenderingContextBase.cpp | 
| index 802cec44c6feb71d318e5cb60cbb1be8826ceacf..6747d20a8d48469516cdfe71519da84b192d6423 100644 | 
| --- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp | 
| +++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp | 
| @@ -483,7 +483,6 @@ private: | 
| WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requestedAttributes) | 
| : CanvasRenderingContext(passedCanvas) | 
| , ActiveDOMObject(&passedCanvas->document()) | 
| - , m_context(context) | 
| , m_drawingBuffer(nullptr) | 
| , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatchContextLostEvent) | 
| , m_restoreAllowed(false) | 
| @@ -499,26 +498,26 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa | 
| , m_onePlusMaxEnabledAttribIndex(0) | 
| , m_onePlusMaxNonDefaultTextureUnit(0) | 
| { | 
| - ASSERT(m_context); | 
| + ASSERT(context.get()); | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
This can just be ASSERT(context). PassOwnPtr has a
 | 
| ScriptWrappable::init(this); | 
| m_contextGroup = WebGLContextGroup::create(); | 
| m_contextGroup->addContext(this); | 
| m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 
| - m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 
| + context.get()->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
This can just be context->getIntegerv(...)
 | 
| RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptRef(new WebGLRenderingContextEvictionManager()); | 
| // Create the DrawingBuffer and initialize the platform layer. | 
| DrawingBuffer::PreserveDrawingBuffer preserve = requestedAttributes->preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 
| - m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); | 
| + m_drawingBuffer = DrawingBuffer::create(context, clampedCanvasSize(), preserve, contextEvictionManager.release()); | 
| + if (!m_drawingBuffer) | 
| + return; | 
| - if (!m_drawingBuffer->isZeroSized()) { | 
| - m_drawingBuffer->bind(); | 
| - setupFlags(); | 
| - initializeNewContext(); | 
| - } | 
| + m_drawingBuffer->bind(); | 
| + setupFlags(); | 
| + initializeNewContext(); | 
| } | 
| void WebGLRenderingContextBase::initializeNewContext() | 
| @@ -554,22 +553,22 @@ void WebGLRenderingContextBase::initializeNewContext() | 
| m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; | 
| GLint numCombinedTextureImageUnits = 0; | 
| - m_context->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits); | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
m_drawingBuffer->context() is a boilerplate patter
 | 
| m_textureUnits.clear(); | 
| m_textureUnits.resize(numCombinedTextureImageUnits); | 
| GLint numVertexAttribs = 0; | 
| - m_context->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); | 
| m_maxVertexAttribs = numVertexAttribs; | 
| m_maxTextureSize = 0; | 
| - m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 
| m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxTextureSize); | 
| m_maxCubeMapTextureSize = 0; | 
| - m_context->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSize); | 
| m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextureSize, m_maxCubeMapTextureSize); | 
| m_maxRenderbufferSize = 0; | 
| - m_context->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); | 
| // These two values from EXT_draw_buffers are lazily queried. | 
| m_maxDrawBuffers = 0; | 
| @@ -585,19 +584,17 @@ void WebGLRenderingContextBase::initializeNewContext() | 
| createFallbackBlackTextures1x1(); | 
| - m_drawingBuffer->reset(clampedCanvasSize()); | 
| - | 
| - m_context->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 
| - m_context->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 
| + m_drawingBuffer->context()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 
| + m_drawingBuffer->context()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 
| m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallback(this)); | 
| m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessageCallback(this)); | 
| - m_context->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 
| - m_context->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 
| + m_drawingBuffer->context()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 
| + m_drawingBuffer->context()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 
| // This ensures that the context has a valid "lastFlushID" and won't be mistakenly identified as the "least recently used" context. | 
| - m_context->flush(); | 
| + m_drawingBuffer->context()->flush(); | 
| for (int i = 0; i < WebGLExtensionNameCount; ++i) | 
| m_extensionEnabled[i] = false; | 
| @@ -607,7 +604,7 @@ void WebGLRenderingContextBase::initializeNewContext() | 
| void WebGLRenderingContextBase::setupFlags() | 
| { | 
| - ASSERT(m_context); | 
| + ASSERT(m_drawingBuffer); | 
| if (Page* p = canvas()->document().page()) { | 
| m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled(); | 
| @@ -698,17 +695,16 @@ void WebGLRenderingContextBase::destroyContext() | 
| { | 
| m_contextLost = true; | 
| - // The drawing buffer holds a context reference. It must also be destroyed | 
| - // in order for the context to be released. | 
| - m_drawingBuffer->releaseResources(); | 
| + if (!m_drawingBuffer) | 
| + return; | 
| m_extensionsUtil.clear(); | 
| - if (m_context) { | 
| - m_context->setContextLostCallback(0); | 
| - m_context->setErrorMessageCallback(0); | 
| - m_context.clear(); | 
| - } | 
| + m_drawingBuffer->context()->setContextLostCallback(0); | 
| + m_drawingBuffer->context()->setErrorMessageCallback(0); | 
| + | 
| + ASSERT(m_drawingBuffer); | 
| + m_drawingBuffer.clear(); | 
| } | 
| void WebGLRenderingContextBase::markContextChanged() | 
| @@ -746,36 +742,37 @@ bool WebGLRenderingContextBase::clearIfComposited(GLbitfield mask) | 
| // Determine if it's possible to combine the clear the user asked for and this clear. | 
| bool combinedClear = mask && !m_scissorEnabled; | 
| - m_context->disable(GL_SCISSOR_TEST); | 
| - if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) | 
| - m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 
| - m_colorMask[1] ? m_clearColor[1] : 0, | 
| - m_colorMask[2] ? m_clearColor[2] : 0, | 
| - m_colorMask[3] ? m_clearColor[3] : 0); | 
| - else | 
| - m_context->clearColor(0, 0, 0, 0); | 
| - m_context->colorMask(true, true, true, true); | 
| + m_drawingBuffer->context()->disable(GL_SCISSOR_TEST); | 
| + if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { | 
| + m_drawingBuffer->context()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 
| + m_colorMask[1] ? m_clearColor[1] : 0, | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
The indentation looks strange here.
 | 
| + m_colorMask[2] ? m_clearColor[2] : 0, | 
| + m_colorMask[3] ? m_clearColor[3] : 0); | 
| + } else { | 
| + m_drawingBuffer->context()->clearColor(0, 0, 0, 0); | 
| + } | 
| + m_drawingBuffer->context()->colorMask(true, true, true, true); | 
| GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 
| if (contextAttributes->depth()) { | 
| if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) | 
| - m_context->clearDepth(1.0f); | 
| + m_drawingBuffer->context()->clearDepth(1.0f); | 
| clearMask |= GL_DEPTH_BUFFER_BIT; | 
| - m_context->depthMask(true); | 
| + m_drawingBuffer->context()->depthMask(true); | 
| } | 
| if (contextAttributes->stencil()) { | 
| if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 
| - m_context->clearStencil(m_clearStencil & m_stencilMask); | 
| + m_drawingBuffer->context()->clearStencil(m_clearStencil & m_stencilMask); | 
| else | 
| - m_context->clearStencil(0); | 
| + m_drawingBuffer->context()->clearStencil(0); | 
| clearMask |= GL_STENCIL_BUFFER_BIT; | 
| - m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 
| + m_drawingBuffer->context()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 
| } | 
| m_drawingBuffer->clearFramebuffers(clearMask); | 
| restoreStateAfterClear(); | 
| if (m_framebufferBinding) | 
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| + m_drawingBuffer->context()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| m_layerCleared = true; | 
| return combinedClear; | 
| @@ -788,15 +785,15 @@ void WebGLRenderingContextBase::restoreStateAfterClear() | 
| // Restore the state that the context set. | 
| if (m_scissorEnabled) | 
| - m_context->enable(GL_SCISSOR_TEST); | 
| - m_context->clearColor(m_clearColor[0], m_clearColor[1], | 
| - m_clearColor[2], m_clearColor[3]); | 
| - m_context->colorMask(m_colorMask[0], m_colorMask[1], | 
| - m_colorMask[2], m_colorMask[3]); | 
| - m_context->clearDepth(m_clearDepth); | 
| - m_context->clearStencil(m_clearStencil); | 
| - m_context->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 
| - m_context->depthMask(m_depthMask); | 
| + m_drawingBuffer->context()->enable(GL_SCISSOR_TEST); | 
| + m_drawingBuffer->context()->clearColor(m_clearColor[0], m_clearColor[1], | 
| + m_clearColor[2], m_clearColor[3]); | 
| + m_drawingBuffer->context()->colorMask(m_colorMask[0], m_colorMask[1], | 
| + m_colorMask[2], m_colorMask[3]); | 
| + m_drawingBuffer->context()->clearDepth(m_clearDepth); | 
| + m_drawingBuffer->context()->clearStencil(m_clearStencil); | 
| + m_drawingBuffer->context()->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 
| + m_drawingBuffer->context()->depthMask(m_depthMask); | 
| } | 
| void WebGLRenderingContextBase::markLayerComposited() | 
| @@ -839,7 +836,7 @@ void WebGLRenderingContextBase::paintRenderingResultsToCanvas() | 
| } | 
| if (m_framebufferBinding) | 
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| + m_drawingBuffer->context()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| else | 
| m_drawingBuffer->bind(); | 
| } | 
| @@ -857,7 +854,7 @@ PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat | 
| return nullptr; | 
| if (m_framebufferBinding) | 
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| + m_drawingBuffer->context()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| else | 
| m_drawingBuffer->bind(); | 
| @@ -892,20 +889,20 @@ void WebGLRenderingContextBase::reshape(int width, int height) | 
| m_drawingBuffer->reset(IntSize(width, height)); | 
| restoreStateAfterClear(); | 
| - m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get())); | 
| - m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBinding.get())); | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get())); | 
| + m_drawingBuffer->context()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBinding.get())); | 
| if (m_framebufferBinding) | 
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| + m_drawingBuffer->context()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBinding.get())); | 
| } | 
| int WebGLRenderingContextBase::drawingBufferWidth() const | 
| { | 
| - return m_drawingBuffer->size().width(); | 
| + return isContextLost() ? 0 : m_drawingBuffer->size().width(); | 
| } | 
| int WebGLRenderingContextBase::drawingBufferHeight() const | 
| { | 
| - return m_drawingBuffer->size().height(); | 
| + return isContextLost() ? 0 : m_drawingBuffer->size().height(); | 
| } | 
| unsigned WebGLRenderingContextBase::sizeInBytes(GLenum type) | 
| @@ -939,7 +936,7 @@ void WebGLRenderingContextBase::activeTexture(GLenum texture) | 
| return; | 
| } | 
| m_activeTextureUnit = texture - GL_TEXTURE0; | 
| - m_context->activeTexture(texture); | 
| + m_drawingBuffer->context()->activeTexture(texture); | 
| m_drawingBuffer->setActiveTextureUnit(texture); | 
| @@ -953,7 +950,7 @@ void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader* | 
| synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachment already has shader"); | 
| return; | 
| } | 
| - m_context->attachShader(objectOrZero(program), objectOrZero(shader)); | 
| + m_drawingBuffer->context()->attachShader(objectOrZero(program), objectOrZero(shader)); | 
| shader->onAttached(); | 
| } | 
| @@ -973,7 +970,7 @@ void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint | 
| synthesizeGLError(GL_INVALID_VALUE, "bindAttribLocation", "index out of range"); | 
| return; | 
| } | 
| - m_context->bindAttribLocation(objectOrZero(program), index, name.utf8().data()); | 
| + m_drawingBuffer->context()->bindAttribLocation(objectOrZero(program), index, name.utf8().data()); | 
| } | 
| bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, WebGLObject* object, bool& deleted) | 
| @@ -1011,7 +1008,7 @@ void WebGLRenderingContextBase::bindBuffer(GLenum target, WebGLBuffer* buffer) | 
| return; | 
| } | 
| - m_context->bindBuffer(target, objectOrZero(buffer)); | 
| + m_drawingBuffer->context()->bindBuffer(target, objectOrZero(buffer)); | 
| if (buffer) | 
| buffer->setTarget(target); | 
| } | 
| @@ -1032,8 +1029,9 @@ void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer* | 
| if (!m_framebufferBinding) { | 
| // Instead of binding fb 0, bind the drawing buffer. | 
| m_drawingBuffer->bind(); | 
| - } else | 
| - m_context->bindFramebuffer(target, objectOrZero(buffer)); | 
| + } else { | 
| + m_drawingBuffer->context()->bindFramebuffer(target, objectOrZero(buffer)); | 
| + } | 
| if (buffer) | 
| buffer->setHasEverBeenBound(); | 
| applyStencilTest(); | 
| @@ -1051,7 +1049,7 @@ void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe | 
| return; | 
| } | 
| m_renderbufferBinding = renderBuffer; | 
| - m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 
| if (renderBuffer) | 
| renderBuffer->setHasEverBeenBound(); | 
| } | 
| @@ -1083,7 +1081,7 @@ void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture | 
| return; | 
| } | 
| - m_context->bindTexture(target, objectOrZero(texture)); | 
| + m_drawingBuffer->context()->bindTexture(target, objectOrZero(texture)); | 
| if (texture) { | 
| texture->setTarget(target, maxLevel); | 
| m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePlusMaxNonDefaultTextureUnit); | 
| @@ -1109,21 +1107,21 @@ void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->blendColor(red, green, blue, alpha); | 
| + m_drawingBuffer->context()->blendColor(red, green, blue, alpha); | 
| } | 
| void WebGLRenderingContextBase::blendEquation(GLenum mode) | 
| { | 
| if (isContextLost() || !validateBlendEquation("blendEquation", mode)) | 
| return; | 
| - m_context->blendEquation(mode); | 
| + m_drawingBuffer->context()->blendEquation(mode); | 
| } | 
| void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) | 
| { | 
| if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeRGB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) | 
| return; | 
| - m_context->blendEquationSeparate(modeRGB, modeAlpha); | 
| + m_drawingBuffer->context()->blendEquationSeparate(modeRGB, modeAlpha); | 
| } | 
| @@ -1131,7 +1129,7 @@ void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) | 
| { | 
| if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfactor)) | 
| return; | 
| - m_context->blendFunc(sfactor, dfactor); | 
| + m_drawingBuffer->context()->blendFunc(sfactor, dfactor); | 
| } | 
| void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) | 
| @@ -1139,7 +1137,7 @@ void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, | 
| // Note: Alpha does not have the same restrictions as RGB. | 
| if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB, dstRGB)) | 
| return; | 
| - m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); | 
| + m_drawingBuffer->context()->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); | 
| } | 
| void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum usage) | 
| @@ -1158,7 +1156,7 @@ void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum | 
| return; | 
| } | 
| - m_context->bufferData(target, static_cast<GLsizeiptr>(size), 0, usage); | 
| + m_drawingBuffer->context()->bufferData(target, static_cast<GLsizeiptr>(size), 0, usage); | 
| } | 
| void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBuffer* data, GLenum usage) | 
| @@ -1172,7 +1170,7 @@ void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBuffer* data, GLe | 
| synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); | 
| return; | 
| } | 
| - m_context->bufferData(target, data->byteLength(), data->data(), usage); | 
| + m_drawingBuffer->context()->bufferData(target, data->byteLength(), data->data(), usage); | 
| } | 
| void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBufferView* data, GLenum usage) | 
| @@ -1187,7 +1185,7 @@ void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBufferView* data, | 
| return; | 
| } | 
| - m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage); | 
| + m_drawingBuffer->context()->bufferData(target, data->byteLength(), data->baseAddress(), usage); | 
| } | 
| void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, ArrayBuffer* data) | 
| @@ -1204,7 +1202,7 @@ void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A | 
| if (!data) | 
| return; | 
| - m_context->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLength(), data->data()); | 
| + m_drawingBuffer->context()->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLength(), data->data()); | 
| } | 
| void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, ArrayBufferView* data) | 
| @@ -1221,7 +1219,7 @@ void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A | 
| if (!data) | 
| return; | 
| - m_context->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLength(), data->baseAddress()); | 
| + m_drawingBuffer->context()->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLength(), data->baseAddress()); | 
| } | 
| GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) | 
| @@ -1240,7 +1238,7 @@ GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) | 
| emitGLWarning("checkFramebufferStatus", reason); | 
| return result; | 
| } | 
| - result = m_context->checkFramebufferStatus(target); | 
| + result = m_drawingBuffer->context()->checkFramebufferStatus(target); | 
| return result; | 
| } | 
| @@ -1253,12 +1251,12 @@ void WebGLRenderingContextBase::clear(GLbitfield mask) | 
| return; | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 
| return; | 
| } | 
| if (!clearIfComposited(mask)) | 
| - m_context->clear(mask); | 
| + m_drawingBuffer->context()->clear(mask); | 
| markContextChanged(); | 
| } | 
| @@ -1278,7 +1276,7 @@ void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl | 
| m_clearColor[1] = g; | 
| m_clearColor[2] = b; | 
| m_clearColor[3] = a; | 
| - m_context->clearColor(r, g, b, a); | 
| + m_drawingBuffer->context()->clearColor(r, g, b, a); | 
| } | 
| void WebGLRenderingContextBase::clearDepth(GLfloat depth) | 
| @@ -1286,7 +1284,7 @@ void WebGLRenderingContextBase::clearDepth(GLfloat depth) | 
| if (isContextLost()) | 
| return; | 
| m_clearDepth = depth; | 
| - m_context->clearDepth(depth); | 
| + m_drawingBuffer->context()->clearDepth(depth); | 
| } | 
| void WebGLRenderingContextBase::clearStencil(GLint s) | 
| @@ -1294,7 +1292,7 @@ void WebGLRenderingContextBase::clearStencil(GLint s) | 
| if (isContextLost()) | 
| return; | 
| m_clearStencil = s; | 
| - m_context->clearStencil(s); | 
| + m_drawingBuffer->context()->clearStencil(s); | 
| } | 
| void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) | 
| @@ -1305,14 +1303,14 @@ void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool | 
| m_colorMask[1] = green; | 
| m_colorMask[2] = blue; | 
| m_colorMask[3] = alpha; | 
| - m_context->colorMask(red, green, blue, alpha); | 
| + m_drawingBuffer->context()->colorMask(red, green, blue, alpha); | 
| } | 
| void WebGLRenderingContextBase::compileShader(WebGLShader* shader) | 
| { | 
| if (isContextLost() || !validateWebGLObject("compileShader", shader)) | 
| return; | 
| - m_context->compileShader(objectOrZero(shader)); | 
| + m_drawingBuffer->context()->compileShader(objectOrZero(shader)); | 
| } | 
| void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBufferView* data) | 
| @@ -1344,8 +1342,8 @@ void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level, | 
| return; | 
| } | 
| } | 
| - m_context->compressedTexImage2D(target, level, internalformat, width, height, | 
| - border, data->byteLength(), data->baseAddress()); | 
| + m_drawingBuffer->context()->compressedTexImage2D(target, level, internalformat, width, height, | 
| + border, data->byteLength(), data->baseAddress()); | 
| tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_BYTE); | 
| } | 
| @@ -1374,8 +1372,8 @@ void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev | 
| if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, level, xoffset, yoffset, width, height, format, tex)) | 
| return; | 
| - m_context->compressedTexSubImage2D(target, level, xoffset, yoffset, | 
| - width, height, format, data->byteLength(), data->baseAddress()); | 
| + m_drawingBuffer->context()->compressedTexSubImage2D(target, level, xoffset, yoffset, | 
| + width, height, format, data->byteLength(), data->baseAddress()); | 
| } | 
| bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionName, GLenum format) | 
| @@ -1407,13 +1405,13 @@ void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu | 
| return; | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", reason); | 
| return; | 
| } | 
| clearIfComposited(); | 
| ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding.get()); | 
| - m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border); | 
| + m_drawingBuffer->context()->copyTexImage2D(target, level, internalformat, x, y, width, height, border); | 
| // FIXME: if the framebuffer is not complete, none of the below should be executed. | 
| tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_BYTE); | 
| } | 
| @@ -1450,13 +1448,13 @@ void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL | 
| return; | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); | 
| return; | 
| } | 
| clearIfComposited(); | 
| ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding.get()); | 
| - m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); | 
| + m_drawingBuffer->context()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); | 
| } | 
| PassRefPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() | 
| @@ -1510,8 +1508,8 @@ WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum | 
| return 0; | 
| if (!renderbuffer->emulatedStencilBuffer()) { | 
| renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 
| - m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedStencilBuffer())); | 
| - m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedStencilBuffer())); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| } | 
| return renderbuffer->emulatedStencilBuffer(); | 
| } | 
| @@ -1543,7 +1541,7 @@ void WebGLRenderingContextBase::cullFace(GLenum mode) | 
| synthesizeGLError(GL_INVALID_ENUM, "cullFace", "invalid mode"); | 
| return; | 
| } | 
| - m_context->cullFace(mode); | 
| + m_drawingBuffer->context()->cullFace(mode); | 
| } | 
| bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) | 
| @@ -1557,7 +1555,7 @@ bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) | 
| if (object->object()) { | 
| // We need to pass in context here because we want | 
| // things in this context unbound. | 
| - object->deleteObject(m_context.get()); | 
| + object->deleteObject(m_drawingBuffer->context()); | 
| } | 
| return true; | 
| } | 
| @@ -1639,7 +1637,7 @@ void WebGLRenderingContextBase::depthFunc(GLenum func) | 
| return; | 
| if (!validateStencilOrDepthFunc("depthFunc", func)) | 
| return; | 
| - m_context->depthFunc(func); | 
| + m_drawingBuffer->context()->depthFunc(func); | 
| } | 
| void WebGLRenderingContextBase::depthMask(GLboolean flag) | 
| @@ -1647,7 +1645,7 @@ void WebGLRenderingContextBase::depthMask(GLboolean flag) | 
| if (isContextLost()) | 
| return; | 
| m_depthMask = flag; | 
| - m_context->depthMask(flag); | 
| + m_drawingBuffer->context()->depthMask(flag); | 
| } | 
| void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) | 
| @@ -1658,7 +1656,7 @@ void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) | 
| synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 
| return; | 
| } | 
| - m_context->depthRange(zNear, zFar); | 
| + m_drawingBuffer->context()->depthRange(zNear, zFar); | 
| } | 
| void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) | 
| @@ -1669,8 +1667,8 @@ void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* | 
| synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not attached"); | 
| return; | 
| } | 
| - m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 
| - shader->onDetached(m_context.get()); | 
| + m_drawingBuffer->context()->detachShader(objectOrZero(program), objectOrZero(shader)); | 
| + shader->onDetached(m_drawingBuffer->context()); | 
| } | 
| void WebGLRenderingContextBase::disable(GLenum cap) | 
| @@ -1686,7 +1684,7 @@ void WebGLRenderingContextBase::disable(GLenum cap) | 
| m_scissorEnabled = false; | 
| m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 
| } | 
| - m_context->disable(cap); | 
| + m_drawingBuffer->context()->disable(cap); | 
| } | 
| void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 
| @@ -1706,7 +1704,7 @@ void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 
| findNewMaxEnabledAttribIndex(); | 
| } | 
| - m_context->disableVertexAttribArray(index); | 
| + m_drawingBuffer->context()->disableVertexAttribArray(index); | 
| } | 
| bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) | 
| @@ -1750,7 +1748,7 @@ void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou | 
| clearIfComposited(); | 
| handleTextureCompleteness("drawArrays", true); | 
| - m_context->drawArrays(mode, first, count); | 
| + m_drawingBuffer->context()->drawArrays(mode, first, count); | 
| handleTextureCompleteness("drawArrays", false); | 
| markContextChanged(); | 
| } | 
| @@ -1763,7 +1761,7 @@ void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum | 
| clearIfComposited(); | 
| handleTextureCompleteness("drawElements", true); | 
| - m_context->drawElements(mode, count, type, static_cast<GLintptr>(offset)); | 
| + m_drawingBuffer->context()->drawElements(mode, count, type, static_cast<GLintptr>(offset)); | 
| handleTextureCompleteness("drawElements", false); | 
| markContextChanged(); | 
| } | 
| @@ -1779,7 +1777,7 @@ void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs | 
| clearIfComposited(); | 
| handleTextureCompleteness("drawArraysInstancedANGLE", true); | 
| - m_context->drawArraysInstancedANGLE(mode, first, count, primcount); | 
| + m_drawingBuffer->context()->drawArraysInstancedANGLE(mode, first, count, primcount); | 
| handleTextureCompleteness("drawArraysInstancedANGLE", false); | 
| markContextChanged(); | 
| } | 
| @@ -1795,7 +1793,7 @@ void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei | 
| clearIfComposited(); | 
| handleTextureCompleteness("drawElementsInstancedANGLE", true); | 
| - m_context->drawElementsInstancedANGLE(mode, count, type, static_cast<GLintptr>(offset), primcount); | 
| + m_drawingBuffer->context()->drawElementsInstancedANGLE(mode, count, type, static_cast<GLintptr>(offset), primcount); | 
| handleTextureCompleteness("drawElementsInstancedANGLE", false); | 
| markContextChanged(); | 
| } | 
| @@ -1813,7 +1811,7 @@ void WebGLRenderingContextBase::enable(GLenum cap) | 
| m_scissorEnabled = true; | 
| m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 
| } | 
| - m_context->enable(cap); | 
| + m_drawingBuffer->context()->enable(cap); | 
| } | 
| void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 
| @@ -1830,21 +1828,21 @@ void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 
| m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribIndex); | 
| - m_context->enableVertexAttribArray(index); | 
| + m_drawingBuffer->context()->enableVertexAttribArray(index); | 
| } | 
| void WebGLRenderingContextBase::finish() | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->flush(); // Intentionally a flush, not a finish. | 
| + m_drawingBuffer->context()->flush(); // Intentionally a flush, not a finish. | 
| } | 
| void WebGLRenderingContextBase::flush() | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->flush(); | 
| + m_drawingBuffer->context()->flush(); | 
| } | 
| void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 
| @@ -1870,20 +1868,20 @@ void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at | 
| switch (attachment) { | 
| case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 
| if (isDepthStencilSupported() || !buffer) { | 
| - m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, renderbuffertarget, bufferObject); | 
| - m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject); | 
| + m_drawingBuffer->context()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, renderbuffertarget, bufferObject); | 
| + m_drawingBuffer->context()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject); | 
| } else { | 
| WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuffer(renderbuffertarget, buffer); | 
| if (!emulatedStencilBuffer) { | 
| synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "out of memory"); | 
| return; | 
| } | 
| - m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, renderbuffertarget, bufferObject); | 
| - m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 
| + m_drawingBuffer->context()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, renderbuffertarget, bufferObject); | 
| + m_drawingBuffer->context()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 
| } | 
| break; | 
| default: | 
| - m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, bufferObject); | 
| + m_drawingBuffer->context()->framebufferRenderbuffer(target, attachment, renderbuffertarget, bufferObject); | 
| } | 
| m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 
| applyStencilTest(); | 
| @@ -1911,17 +1909,17 @@ void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac | 
| Platform3DObject textureObject = objectOrZero(texture); | 
| switch (attachment) { | 
| case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 
| - m_context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget, textureObject, level); | 
| - m_context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget, textureObject, level); | 
| + m_drawingBuffer->context()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget, textureObject, level); | 
| + m_drawingBuffer->context()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget, textureObject, level); | 
| break; | 
| case GL_DEPTH_ATTACHMENT: | 
| - m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| + m_drawingBuffer->context()->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| break; | 
| case GL_STENCIL_ATTACHMENT: | 
| - m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| + m_drawingBuffer->context()->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| break; | 
| default: | 
| - m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| + m_drawingBuffer->context()->framebufferTexture2D(target, attachment, textarget, textureObject, level); | 
| } | 
| m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget, texture, level); | 
| applyStencilTest(); | 
| @@ -1939,7 +1937,7 @@ void WebGLRenderingContextBase::frontFace(GLenum mode) | 
| synthesizeGLError(GL_INVALID_ENUM, "frontFace", "invalid mode"); | 
| return; | 
| } | 
| - m_context->frontFace(mode); | 
| + m_drawingBuffer->context()->frontFace(mode); | 
| } | 
| void WebGLRenderingContextBase::generateMipmap(GLenum target) | 
| @@ -1961,14 +1959,14 @@ void WebGLRenderingContextBase::generateMipmap(GLenum target) | 
| #if OS(MACOSX) | 
| bool needToResetMinFilter = false; | 
| if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) { | 
| - m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); | 
| + m_drawingBuffer->context()->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); | 
| needToResetMinFilter = true; | 
| } | 
| #endif | 
| - m_context->generateMipmap(target); | 
| + m_drawingBuffer->context()->generateMipmap(target); | 
| #if OS(MACOSX) | 
| if (needToResetMinFilter) | 
| - m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilter()); | 
| + m_drawingBuffer->context()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilter()); | 
| #endif | 
| tex->generateMipmapLevelInfo(); | 
| } | 
| @@ -1978,7 +1976,7 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg | 
| if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 
| return nullptr; | 
| blink::WebGraphicsContext3D::ActiveInfo info; | 
| - if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 
| + if (!m_drawingBuffer->context()->getActiveAttrib(objectOrZero(program), index, info)) | 
| return nullptr; | 
| return WebGLActiveInfo::create(info.name, info.type, info.size); | 
| } | 
| @@ -1988,7 +1986,7 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLPro | 
| if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 
| return nullptr; | 
| blink::WebGraphicsContext3D::ActiveInfo info; | 
| - if (!m_context->getActiveUniform(objectOrZero(program), index, info)) | 
| + if (!m_drawingBuffer->context()->getActiveUniform(objectOrZero(program), index, info)) | 
| return nullptr; | 
| return WebGLActiveInfo::create(info.name, info.type, info.size); | 
| } | 
| @@ -2025,7 +2023,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program, const | 
| synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program not linked"); | 
| return 0; | 
| } | 
| - return m_context->getAttribLocation(objectOrZero(program), name.utf8().data()); | 
| + return m_drawingBuffer->context()->getAttribLocation(objectOrZero(program), name.utf8().data()); | 
| } | 
| WebGLGetInfo WebGLRenderingContextBase::getBufferParameter(GLenum target, GLenum pname) | 
| @@ -2043,7 +2041,7 @@ WebGLGetInfo WebGLRenderingContextBase::getBufferParameter(GLenum target, GLenum | 
| } | 
| GLint value = 0; | 
| - m_context->getBufferParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->getBufferParameteriv(target, pname, &value); | 
| if (pname == GL_BUFFER_SIZE) | 
| return WebGLGetInfo(value); | 
| return WebGLGetInfo(static_cast<unsigned>(value)); | 
| @@ -2055,7 +2053,7 @@ PassRefPtr<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttribut | 
| return nullptr; | 
| // We always need to return a new WebGLContextAttributes object to | 
| // prevent the user from mutating any cached version. | 
| - blink::WebGraphicsContext3D::Attributes attrs = m_context->getContextAttributes(); | 
| + blink::WebGraphicsContext3D::Attributes attrs = m_drawingBuffer->context()->getContextAttributes(); | 
| RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); | 
| // Some requested attributes may not be honored, so we need to query the underlying | 
| // context/drawing buffer and adjust accordingly. | 
| @@ -2078,7 +2076,7 @@ GLenum WebGLRenderingContextBase::getError() | 
| if (isContextLost()) | 
| return GL_NO_ERROR; | 
| - return m_context->getError(); | 
| + return m_drawingBuffer->context()->getError(); | 
| } | 
| bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const String& name) const | 
| @@ -2153,7 +2151,7 @@ WebGLGetInfo WebGLRenderingContextBase::getFramebufferAttachmentParameter(GLenum | 
| case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 
| { | 
| GLint value = 0; | 
| - m_context->getFramebufferAttachmentParameteriv(target, attachment, pname, &value); | 
| + m_drawingBuffer->context()->getFramebufferAttachmentParameteriv(target, attachment, pname, &value); | 
| return WebGLGetInfo(value); | 
| } | 
| default: | 
| @@ -2299,7 +2297,7 @@ WebGLGetInfo WebGLRenderingContextBase::getParameter(GLenum pname) | 
| case GL_SCISSOR_TEST: | 
| return getBooleanParameter(pname); | 
| case GL_SHADING_LANGUAGE_VERSION: | 
| - return WebGLGetInfo("WebGL GLSL ES 1.0 (" + String(m_context->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); | 
| + return WebGLGetInfo("WebGL GLSL ES 1.0 (" + String(m_drawingBuffer->context()->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); | 
| case GL_STENCIL_BACK_FAIL: | 
| return getUnsignedIntParameter(pname); | 
| case GL_STENCIL_BACK_FUNC: | 
| @@ -2353,7 +2351,7 @@ WebGLGetInfo WebGLRenderingContextBase::getParameter(GLenum pname) | 
| case GL_VENDOR: | 
| return WebGLGetInfo(String("WebKit")); | 
| case GL_VERSION: | 
| - return WebGLGetInfo("WebGL 1.0 (" + String(m_context->getString(GL_VERSION)) + ")"); | 
| + return WebGLGetInfo("WebGL 1.0 (" + String(m_drawingBuffer->context()->getString(GL_VERSION)) + ")"); | 
| case GL_VIEWPORT: | 
| return getWebGLIntArrayParameter(pname); | 
| case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives | 
| @@ -2363,12 +2361,12 @@ WebGLGetInfo WebGLRenderingContextBase::getParameter(GLenum pname) | 
| return WebGLGetInfo(); | 
| case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: | 
| if (extensionEnabled(WebGLDebugRendererInfoName)) | 
| - return WebGLGetInfo(m_context->getString(GL_RENDERER)); | 
| + return WebGLGetInfo(m_drawingBuffer->context()->getString(GL_RENDERER)); | 
| synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled"); | 
| return WebGLGetInfo(); | 
| case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: | 
| if (extensionEnabled(WebGLDebugRendererInfoName)) | 
| - return WebGLGetInfo(m_context->getString(GL_VENDOR)); | 
| + return WebGLGetInfo(m_drawingBuffer->context()->getString(GL_VENDOR)); | 
| synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled"); | 
| return WebGLGetInfo(); | 
| case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object | 
| @@ -2420,14 +2418,14 @@ WebGLGetInfo WebGLRenderingContextBase::getProgramParameter(WebGLProgram* progra | 
| case GL_DELETE_STATUS: | 
| return WebGLGetInfo(program->isDeleted()); | 
| case GL_VALIDATE_STATUS: | 
| - m_context->getProgramiv(objectOrZero(program), pname, &value); | 
| + m_drawingBuffer->context()->getProgramiv(objectOrZero(program), pname, &value); | 
| return WebGLGetInfo(static_cast<bool>(value)); | 
| case GL_LINK_STATUS: | 
| return WebGLGetInfo(program->linkStatus()); | 
| case GL_ATTACHED_SHADERS: | 
| case GL_ACTIVE_ATTRIBUTES: | 
| case GL_ACTIVE_UNIFORMS: | 
| - m_context->getProgramiv(objectOrZero(program), pname, &value); | 
| + m_drawingBuffer->context()->getProgramiv(objectOrZero(program), pname, &value); | 
| return WebGLGetInfo(value); | 
| default: | 
| synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid parameter name"); | 
| @@ -2441,7 +2439,7 @@ String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) | 
| return String(); | 
| if (!validateWebGLObject("getProgramInfoLog", program)) | 
| return ""; | 
| - return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); | 
| + return ensureNotNull(m_drawingBuffer->context()->getProgramInfoLog(objectOrZero(program))); | 
| } | 
| WebGLGetInfo WebGLRenderingContextBase::getRenderbufferParameter(GLenum target, GLenum pname) | 
| @@ -2466,15 +2464,15 @@ WebGLGetInfo WebGLRenderingContextBase::getRenderbufferParameter(GLenum target, | 
| case GL_RENDERBUFFER_BLUE_SIZE: | 
| case GL_RENDERBUFFER_ALPHA_SIZE: | 
| case GL_RENDERBUFFER_DEPTH_SIZE: | 
| - m_context->getRenderbufferParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->getRenderbufferParameteriv(target, pname, &value); | 
| return WebGLGetInfo(value); | 
| case GL_RENDERBUFFER_STENCIL_SIZE: | 
| if (m_renderbufferBinding->emulatedStencilBuffer()) { | 
| - m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding->emulatedStencilBuffer())); | 
| - m_context->getRenderbufferParameteriv(target, pname, &value); | 
| - m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding->emulatedStencilBuffer())); | 
| + m_drawingBuffer->context()->getRenderbufferParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| } else { | 
| - m_context->getRenderbufferParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->getRenderbufferParameteriv(target, pname, &value); | 
| } | 
| return WebGLGetInfo(value); | 
| case GL_RENDERBUFFER_INTERNAL_FORMAT: | 
| @@ -2494,10 +2492,10 @@ WebGLGetInfo WebGLRenderingContextBase::getShaderParameter(WebGLShader* shader, | 
| case GL_DELETE_STATUS: | 
| return WebGLGetInfo(shader->isDeleted()); | 
| case GL_COMPILE_STATUS: | 
| - m_context->getShaderiv(objectOrZero(shader), pname, &value); | 
| + m_drawingBuffer->context()->getShaderiv(objectOrZero(shader), pname, &value); | 
| return WebGLGetInfo(static_cast<bool>(value)); | 
| case GL_SHADER_TYPE: | 
| - m_context->getShaderiv(objectOrZero(shader), pname, &value); | 
| + m_drawingBuffer->context()->getShaderiv(objectOrZero(shader), pname, &value); | 
| return WebGLGetInfo(static_cast<unsigned>(value)); | 
| default: | 
| synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parameter name"); | 
| @@ -2511,7 +2509,7 @@ String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) | 
| return String(); | 
| if (!validateWebGLObject("getShaderInfoLog", shader)) | 
| return ""; | 
| - return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 
| + return ensureNotNull(m_drawingBuffer->context()->getShaderInfoLog(objectOrZero(shader))); | 
| } | 
| PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPrecisionFormat(GLenum shaderType, GLenum precisionType) | 
| @@ -2541,7 +2539,7 @@ PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPreci | 
| GLint range[2] = {0, 0}; | 
| GLint precision = 0; | 
| - m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &precision); | 
| + m_drawingBuffer->context()->getShaderPrecisionFormat(shaderType, precisionType, range, &precision); | 
| return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 
| } | 
| @@ -2588,11 +2586,11 @@ WebGLGetInfo WebGLRenderingContextBase::getTexParameter(GLenum target, GLenum pn | 
| case GL_TEXTURE_MIN_FILTER: | 
| case GL_TEXTURE_WRAP_S: | 
| case GL_TEXTURE_WRAP_T: | 
| - m_context->getTexParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->getTexParameteriv(target, pname, &value); | 
| return WebGLGetInfo(static_cast<unsigned>(value)); | 
| case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic | 
| if (extensionEnabled(EXTTextureFilterAnisotropicName)) { | 
| - m_context->getTexParameteriv(target, pname, &value); | 
| + m_drawingBuffer->context()->getTexParameteriv(target, pname, &value); | 
| return WebGLGetInfo(static_cast<unsigned>(value)); | 
| } | 
| synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled"); | 
| @@ -2615,10 +2613,10 @@ WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const | 
| // FIXME: make this more efficient using WebGLUniformLocation and caching types in it | 
| GLint activeUniforms = 0; | 
| - m_context->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activeUniforms); | 
| + m_drawingBuffer->context()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activeUniforms); | 
| for (GLint i = 0; i < activeUniforms; i++) { | 
| blink::WebGraphicsContext3D::ActiveInfo info; | 
| - if (!m_context->getActiveUniform(objectOrZero(program), i, info)) | 
| + if (!m_drawingBuffer->context()->getActiveUniform(objectOrZero(program), i, info)) | 
| return WebGLGetInfo(); | 
| String name = info.name; | 
| StringBuilder nameBuilder; | 
| @@ -2635,7 +2633,7 @@ WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const | 
| nameBuilder.append(']'); | 
| } | 
| // Now need to look this up by name again to find its location | 
| - GLint loc = m_context->getUniformLocation(objectOrZero(program), nameBuilder.toString().utf8().data()); | 
| + GLint loc = m_drawingBuffer->context()->getUniformLocation(objectOrZero(program), nameBuilder.toString().utf8().data()); | 
| if (loc == location) { | 
| // Found it. Use the type in the ActiveInfo to determine the return type. | 
| GLenum baseType; | 
| @@ -2714,21 +2712,21 @@ WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const | 
| switch (baseType) { | 
| case GL_FLOAT: { | 
| GLfloat value[16] = {0}; | 
| - m_context->getUniformfv(objectOrZero(program), location, value); | 
| + m_drawingBuffer->context()->getUniformfv(objectOrZero(program), location, value); | 
| if (length == 1) | 
| return WebGLGetInfo(value[0]); | 
| return WebGLGetInfo(Float32Array::create(value, length)); | 
| } | 
| case GL_INT: { | 
| GLint value[4] = {0}; | 
| - m_context->getUniformiv(objectOrZero(program), location, value); | 
| + m_drawingBuffer->context()->getUniformiv(objectOrZero(program), location, value); | 
| if (length == 1) | 
| return WebGLGetInfo(value[0]); | 
| return WebGLGetInfo(Int32Array::create(value, length)); | 
| } | 
| case GL_BOOL: { | 
| GLint value[4] = {0}; | 
| - m_context->getUniformiv(objectOrZero(program), location, value); | 
| + m_drawingBuffer->context()->getUniformiv(objectOrZero(program), location, value); | 
| if (length > 1) { | 
| bool boolValue[16] = {0}; | 
| for (unsigned j = 0; j < length; j++) | 
| @@ -2762,7 +2760,7 @@ PassRefPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUniformLocation(W | 
| synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program not linked"); | 
| return nullptr; | 
| } | 
| - GLint uniformLocation = m_context->getUniformLocation(objectOrZero(program), name.utf8().data()); | 
| + GLint uniformLocation = m_drawingBuffer->context()->getUniformLocation(objectOrZero(program), name.utf8().data()); | 
| if (uniformLocation == -1) | 
| return nullptr; | 
| return WebGLUniformLocation::create(program, uniformLocation); | 
| @@ -2812,7 +2810,7 @@ long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum | 
| synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid parameter name"); | 
| return 0; | 
| } | 
| - GLsizeiptr result = m_context->getVertexAttribOffset(index, pname); | 
| + GLsizeiptr result = m_drawingBuffer->context()->getVertexAttribOffset(index, pname); | 
| return static_cast<long long>(result); | 
| } | 
| @@ -2834,7 +2832,7 @@ void WebGLRenderingContextBase::hint(GLenum target, GLenum mode) | 
| synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); | 
| return; | 
| } | 
| - m_context->hint(target, mode); | 
| + m_drawingBuffer->context()->hint(target, mode); | 
| } | 
| GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) | 
| @@ -2845,10 +2843,10 @@ GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) | 
| if (!buffer->hasEverBeenBound()) | 
| return 0; | 
| - return m_context->isBuffer(buffer->object()); | 
| + return m_drawingBuffer->context()->isBuffer(buffer->object()); | 
| } | 
| -bool WebGLRenderingContextBase::isContextLost() | 
| +bool WebGLRenderingContextBase::isContextLost() const | 
| { | 
| return m_contextLost; | 
| } | 
| @@ -2859,7 +2857,7 @@ GLboolean WebGLRenderingContextBase::isEnabled(GLenum cap) | 
| return 0; | 
| if (cap == GL_STENCIL_TEST) | 
| return m_stencilEnabled; | 
| - return m_context->isEnabled(cap); | 
| + return m_drawingBuffer->context()->isEnabled(cap); | 
| } | 
| GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer) | 
| @@ -2870,7 +2868,7 @@ GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer | 
| if (!framebuffer->hasEverBeenBound()) | 
| return 0; | 
| - return m_context->isFramebuffer(framebuffer->object()); | 
| + return m_drawingBuffer->context()->isFramebuffer(framebuffer->object()); | 
| } | 
| GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) | 
| @@ -2878,7 +2876,7 @@ GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) | 
| if (!program || isContextLost()) | 
| return 0; | 
| - return m_context->isProgram(program->object()); | 
| + return m_drawingBuffer->context()->isProgram(program->object()); | 
| } | 
| GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuffer) | 
| @@ -2889,7 +2887,7 @@ GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuf | 
| if (!renderbuffer->hasEverBeenBound()) | 
| return 0; | 
| - return m_context->isRenderbuffer(renderbuffer->object()); | 
| + return m_drawingBuffer->context()->isRenderbuffer(renderbuffer->object()); | 
| } | 
| GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) | 
| @@ -2897,7 +2895,7 @@ GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) | 
| if (!shader || isContextLost()) | 
| return 0; | 
| - return m_context->isShader(shader->object()); | 
| + return m_drawingBuffer->context()->isShader(shader->object()); | 
| } | 
| GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) | 
| @@ -2908,14 +2906,14 @@ GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) | 
| if (!texture->hasEverBeenBound()) | 
| return 0; | 
| - return m_context->isTexture(texture->object()); | 
| + return m_drawingBuffer->context()->isTexture(texture->object()); | 
| } | 
| void WebGLRenderingContextBase::lineWidth(GLfloat width) | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->lineWidth(width); | 
| + m_drawingBuffer->context()->lineWidth(width); | 
| } | 
| void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) | 
| @@ -2923,7 +2921,7 @@ void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) | 
| if (isContextLost() || !validateWebGLObject("linkProgram", program)) | 
| return; | 
| - m_context->linkProgram(objectOrZero(program)); | 
| + m_drawingBuffer->context()->linkProgram(objectOrZero(program)); | 
| program->increaseLinkCount(); | 
| } | 
| @@ -2955,7 +2953,7 @@ void WebGLRenderingContextBase::pixelStorei(GLenum pname, GLint param) | 
| } else { // GL_UNPACK_ALIGNMENT: | 
| m_unpackAlignment = param; | 
| } | 
| - m_context->pixelStorei(pname, param); | 
| + m_drawingBuffer->context()->pixelStorei(pname, param); | 
| } else { | 
| synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid parameter for alignment"); | 
| return; | 
| @@ -2971,7 +2969,7 @@ void WebGLRenderingContextBase::polygonOffset(GLfloat factor, GLfloat units) | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->polygonOffset(factor, units); | 
| + m_drawingBuffer->context()->polygonOffset(factor, units); | 
| } | 
| void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView* pixels) | 
| @@ -3015,7 +3013,7 @@ void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi | 
| return; | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason); | 
| return; | 
| } | 
| @@ -3037,13 +3035,13 @@ void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi | 
| { | 
| ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding.get()); | 
| - m_context->readPixels(x, y, width, height, format, type, data); | 
| + m_drawingBuffer->context()->readPixels(x, y, width, height, format, type, data); | 
| } | 
| #if OS(MACOSX) | 
| // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | 
| // when alpha is off, readPixels should set alpha to 255 instead of 0. | 
| - if (!m_framebufferBinding && !m_context->getContextAttributes().alpha) { | 
| + if (!m_framebufferBinding && !m_drawingBuffer->context()->getContextAttributes().alpha) { | 
| unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | 
| for (GLsizei iy = 0; iy < height; ++iy) { | 
| for (GLsizei ix = 0; ix < width; ++ix) { | 
| @@ -3076,24 +3074,24 @@ void WebGLRenderingContextBase::renderbufferStorage(GLenum target, GLenum intern | 
| case GL_RGB5_A1: | 
| case GL_RGB565: | 
| case GL_STENCIL_INDEX8: | 
| - m_context->renderbufferStorage(target, internalformat, width, height); | 
| + m_drawingBuffer->context()->renderbufferStorage(target, internalformat, width, height); | 
| m_renderbufferBinding->setInternalFormat(internalformat); | 
| m_renderbufferBinding->setSize(width, height); | 
| - m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); | 
| + m_renderbufferBinding->deleteEmulatedStencilBuffer(m_drawingBuffer->context()); | 
| break; | 
| case GL_DEPTH_STENCIL_OES: | 
| if (isDepthStencilSupported()) { | 
| - m_context->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width, height); | 
| + m_drawingBuffer->context()->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width, height); | 
| } else { | 
| WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuffer(target, m_renderbufferBinding.get()); | 
| if (!emulatedStencilBuffer) { | 
| synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out of memory"); | 
| return; | 
| } | 
| - m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width, height); | 
| - m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuffer)); | 
| - m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, height); | 
| - m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| + m_drawingBuffer->context()->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width, height); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(emulatedStencilBuffer)); | 
| + m_drawingBuffer->context()->renderbufferStorage(target, GL_STENCIL_INDEX8, width, height); | 
| + m_drawingBuffer->context()->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.get())); | 
| emulatedStencilBuffer->setSize(width, height); | 
| emulatedStencilBuffer->setInternalFormat(GL_STENCIL_INDEX8); | 
| } | 
| @@ -3111,7 +3109,7 @@ void WebGLRenderingContextBase::sampleCoverage(GLfloat value, GLboolean invert) | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->sampleCoverage(value, invert); | 
| + m_drawingBuffer->context()->sampleCoverage(value, invert); | 
| } | 
| void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei height) | 
| @@ -3120,7 +3118,7 @@ void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei | 
| return; | 
| if (!validateSize("scissor", width, height)) | 
| return; | 
| - m_context->scissor(x, y, width, height); | 
| + m_drawingBuffer->context()->scissor(x, y, width, height); | 
| } | 
| void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String& string) | 
| @@ -3131,7 +3129,7 @@ void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String& | 
| if (!validateString("shaderSource", stringWithoutComments)) | 
| return; | 
| shader->setSource(string); | 
| - m_context->shaderSource(objectOrZero(shader), stringWithoutComments.utf8().data()); | 
| + m_drawingBuffer->context()->shaderSource(objectOrZero(shader), stringWithoutComments.utf8().data()); | 
| } | 
| void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) | 
| @@ -3144,7 +3142,7 @@ void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) | 
| m_stencilFuncRefBack = ref; | 
| m_stencilFuncMask = mask; | 
| m_stencilFuncMaskBack = mask; | 
| - m_context->stencilFunc(func, ref, mask); | 
| + m_drawingBuffer->context()->stencilFunc(func, ref, mask); | 
| } | 
| void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) | 
| @@ -3172,7 +3170,7 @@ void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GL | 
| synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"); | 
| return; | 
| } | 
| - m_context->stencilFuncSeparate(face, func, ref, mask); | 
| + m_drawingBuffer->context()->stencilFuncSeparate(face, func, ref, mask); | 
| } | 
| void WebGLRenderingContextBase::stencilMask(GLuint mask) | 
| @@ -3181,7 +3179,7 @@ void WebGLRenderingContextBase::stencilMask(GLuint mask) | 
| return; | 
| m_stencilMask = mask; | 
| m_stencilMaskBack = mask; | 
| - m_context->stencilMask(mask); | 
| + m_drawingBuffer->context()->stencilMask(mask); | 
| } | 
| void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) | 
| @@ -3203,21 +3201,21 @@ void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) | 
| synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"); | 
| return; | 
| } | 
| - m_context->stencilMaskSeparate(face, mask); | 
| + m_drawingBuffer->context()->stencilMaskSeparate(face, mask); | 
| } | 
| void WebGLRenderingContextBase::stencilOp(GLenum fail, GLenum zfail, GLenum zpass) | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->stencilOp(fail, zfail, zpass); | 
| + m_drawingBuffer->context()->stencilOp(fail, zfail, zpass); | 
| } | 
| void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) | 
| { | 
| if (isContextLost()) | 
| return; | 
| - m_context->stencilOpSeparate(face, fail, zfail, zpass); | 
| + m_drawingBuffer->context()->stencilOpSeparate(face, fail, zfail, zpass); | 
| } | 
| GLenum WebGLRenderingContextBase::convertTexInternalFormat(GLenum internalformat, GLenum type) | 
| @@ -3241,7 +3239,7 @@ void WebGLRenderingContextBase::texImage2DBase(GLenum target, GLint level, GLenu | 
| ASSERT(tex); | 
| ASSERT(!level || !WebGLTexture::isNPOT(width, height)); | 
| ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); | 
| - m_context->texImage2D(target, level, convertTexInternalFormat(internalformat, type), width, height, border, format, type, pixels); | 
| + m_drawingBuffer->context()->texImage2D(target, level, convertTexInternalFormat(internalformat, type), width, height, border, format, type, pixels); | 
| tex->setLevelInfo(target, level, internalformat, width, height, type); | 
| } | 
| @@ -3269,10 +3267,10 @@ void WebGLRenderingContextBase::texImage2DImpl(GLenum target, GLint level, GLenu | 
| } | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texImage2DBase(target, level, internalformat, image->width(), image->height(), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionState); | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexFuncValidationFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset) | 
| @@ -3350,10 +3348,10 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in | 
| changeUnpackAlignment = true; | 
| } | 
| if (changeUnpackAlignment) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texImage2DBase(target, level, internalformat, width, height, border, format, type, data, exceptionState); | 
| if (changeUnpackAlignment) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum internalformat, | 
| @@ -3374,10 +3372,10 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in | 
| } | 
| } | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), exceptionState); | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum internalformat, | 
| @@ -3408,14 +3406,14 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in | 
| if (GL_TEXTURE_2D == target && texture) { | 
| if (!canvas->is3D()) { | 
| ImageBuffer* buffer = canvas->buffer(); | 
| - if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture->object(), internalformat, type, | 
| + if (buffer && buffer->copyToPlatformTexture(m_drawingBuffer->context(), texture->object(), internalformat, type, | 
| level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 
| texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type); | 
| return; | 
| } | 
| } else { | 
| WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->renderingContext()); | 
| - if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get(), texture->object(), internalformat, type, | 
| + if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_drawingBuffer->context(), texture->object(), internalformat, type, | 
| level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 
| texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type); | 
| return; | 
| @@ -3455,7 +3453,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in | 
| // Otherwise, it will fall back to the normal SW path. | 
| WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 
| if (GL_TEXTURE_2D == target && texture) { | 
| - if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->object(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 
| + if (video->copyVideoTextureToPlatformTexture(m_drawingBuffer->context(), texture->object(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 
| texture->setLevelInfo(target, level, internalformat, video->videoWidth(), video->videoHeight(), type); | 
| return; | 
| } | 
| @@ -3499,10 +3497,10 @@ void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa | 
| } | 
| if (isFloat) { | 
| tex->setParameterf(pname, paramf); | 
| - m_context->texParameterf(target, pname, paramf); | 
| + m_drawingBuffer->context()->texParameterf(target, pname, paramf); | 
| } else { | 
| tex->setParameteri(pname, parami); | 
| - m_context->texParameteri(target, pname, parami); | 
| + m_drawingBuffer->context()->texParameteri(target, pname, parami); | 
| } | 
| } | 
| @@ -3534,7 +3532,7 @@ void WebGLRenderingContextBase::texSubImage2DBase(GLenum target, GLint level, GL | 
| ASSERT(tex->getHeight(target, level) >= (yoffset + height)); | 
| ASSERT(tex->getInternalFormat(target, level) == format); | 
| ASSERT(tex->getType(target, level) == type); | 
| - m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); | 
| + m_drawingBuffer->context()->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); | 
| } | 
| void WebGLRenderingContextBase::texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, Image* image, WebGLImageConversion::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionState& exceptionState) | 
| @@ -3561,10 +3559,10 @@ void WebGLRenderingContextBase::texSubImage2DImpl(GLenum target, GLint level, GL | 
| } | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(), format, type, needConversion ? data.data() : imagePixelData, exceptionState); | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 
| @@ -3588,10 +3586,10 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint | 
| changeUnpackAlignment = true; | 
| } | 
| if (changeUnpackAlignment) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, type, data, exceptionState); | 
| if (changeUnpackAlignment) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 
| @@ -3613,10 +3611,10 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint | 
| } | 
| } | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 
| texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, type, needConversion ? data.data() : pixels->data()->data(), exceptionState); | 
| if (m_unpackAlignment != 1) | 
| - m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| + m_drawingBuffer->context()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 
| } | 
| void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 
| @@ -3672,7 +3670,7 @@ void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform1f(location->location(), x); | 
| + m_drawingBuffer->context()->uniform1f(location->location(), x); | 
| } | 
| void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, Float32Array* v) | 
| @@ -3680,7 +3678,7 @@ void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) | 
| return; | 
| - m_context->uniform1fv(location->location(), v->length(), v->data()); | 
| + m_drawingBuffer->context()->uniform1fv(location->location(), v->length(), v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, GLfloat* v, GLsizei size) | 
| @@ -3688,7 +3686,7 @@ void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) | 
| return; | 
| - m_context->uniform1fv(location->location(), size, v); | 
| + m_drawingBuffer->context()->uniform1fv(location->location(), size, v); | 
| } | 
| void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, GLint x) | 
| @@ -3701,7 +3699,7 @@ void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform1i(location->location(), x); | 
| + m_drawingBuffer->context()->uniform1i(location->location(), x); | 
| } | 
| void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, Int32Array* v) | 
| @@ -3709,7 +3707,7 @@ void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) | 
| return; | 
| - m_context->uniform1iv(location->location(), v->length(), v->data()); | 
| + m_drawingBuffer->context()->uniform1iv(location->location(), v->length(), v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, GLint* v, GLsizei size) | 
| @@ -3717,7 +3715,7 @@ void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) | 
| return; | 
| - m_context->uniform1iv(location->location(), size, v); | 
| + m_drawingBuffer->context()->uniform1iv(location->location(), size, v); | 
| } | 
| void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, GLfloat x, GLfloat y) | 
| @@ -3730,7 +3728,7 @@ void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform2f(location->location(), x, y); | 
| + m_drawingBuffer->context()->uniform2f(location->location(), x, y); | 
| } | 
| void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, Float32Array* v) | 
| @@ -3738,7 +3736,7 @@ void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) | 
| return; | 
| - m_context->uniform2fv(location->location(), v->length() / 2, v->data()); | 
| + m_drawingBuffer->context()->uniform2fv(location->location(), v->length() / 2, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, GLfloat* v, GLsizei size) | 
| @@ -3746,7 +3744,7 @@ void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) | 
| return; | 
| - m_context->uniform2fv(location->location(), size / 2, v); | 
| + m_drawingBuffer->context()->uniform2fv(location->location(), size / 2, v); | 
| } | 
| void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, GLint x, GLint y) | 
| @@ -3759,7 +3757,7 @@ void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform2i(location->location(), x, y); | 
| + m_drawingBuffer->context()->uniform2i(location->location(), x, y); | 
| } | 
| void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, Int32Array* v) | 
| @@ -3767,7 +3765,7 @@ void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) | 
| return; | 
| - m_context->uniform2iv(location->location(), v->length() / 2, v->data()); | 
| + m_drawingBuffer->context()->uniform2iv(location->location(), v->length() / 2, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, GLint* v, GLsizei size) | 
| @@ -3775,7 +3773,7 @@ void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) | 
| return; | 
| - m_context->uniform2iv(location->location(), size / 2, v); | 
| + m_drawingBuffer->context()->uniform2iv(location->location(), size / 2, v); | 
| } | 
| void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, GLfloat x, GLfloat y, GLfloat z) | 
| @@ -3788,7 +3786,7 @@ void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform3f(location->location(), x, y, z); | 
| + m_drawingBuffer->context()->uniform3f(location->location(), x, y, z); | 
| } | 
| void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, Float32Array* v) | 
| @@ -3796,7 +3794,7 @@ void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) | 
| return; | 
| - m_context->uniform3fv(location->location(), v->length() / 3, v->data()); | 
| + m_drawingBuffer->context()->uniform3fv(location->location(), v->length() / 3, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, GLfloat* v, GLsizei size) | 
| @@ -3804,7 +3802,7 @@ void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) | 
| return; | 
| - m_context->uniform3fv(location->location(), size / 3, v); | 
| + m_drawingBuffer->context()->uniform3fv(location->location(), size / 3, v); | 
| } | 
| void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, GLint x, GLint y, GLint z) | 
| @@ -3817,7 +3815,7 @@ void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform3i(location->location(), x, y, z); | 
| + m_drawingBuffer->context()->uniform3i(location->location(), x, y, z); | 
| } | 
| void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, Int32Array* v) | 
| @@ -3825,7 +3823,7 @@ void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) | 
| return; | 
| - m_context->uniform3iv(location->location(), v->length() / 3, v->data()); | 
| + m_drawingBuffer->context()->uniform3iv(location->location(), v->length() / 3, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, GLint* v, GLsizei size) | 
| @@ -3833,7 +3831,7 @@ void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) | 
| return; | 
| - m_context->uniform3iv(location->location(), size / 3, v); | 
| + m_drawingBuffer->context()->uniform3iv(location->location(), size / 3, v); | 
| } | 
| void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) | 
| @@ -3846,7 +3844,7 @@ void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform4f(location->location(), x, y, z, w); | 
| + m_drawingBuffer->context()->uniform4f(location->location(), x, y, z, w); | 
| } | 
| void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, Float32Array* v) | 
| @@ -3854,7 +3852,7 @@ void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) | 
| return; | 
| - m_context->uniform4fv(location->location(), v->length() / 4, v->data()); | 
| + m_drawingBuffer->context()->uniform4fv(location->location(), v->length() / 4, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, GLfloat* v, GLsizei size) | 
| @@ -3862,7 +3860,7 @@ void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) | 
| return; | 
| - m_context->uniform4fv(location->location(), size / 4, v); | 
| + m_drawingBuffer->context()->uniform4fv(location->location(), size / 4, v); | 
| } | 
| void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, GLint x, GLint y, GLint z, GLint w) | 
| @@ -3875,7 +3873,7 @@ void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, | 
| return; | 
| } | 
| - m_context->uniform4i(location->location(), x, y, z, w); | 
| + m_drawingBuffer->context()->uniform4i(location->location(), x, y, z, w); | 
| } | 
| void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, Int32Array* v) | 
| @@ -3883,7 +3881,7 @@ void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) | 
| return; | 
| - m_context->uniform4iv(location->location(), v->length() / 4, v->data()); | 
| + m_drawingBuffer->context()->uniform4iv(location->location(), v->length() / 4, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, GLint* v, GLsizei size) | 
| @@ -3891,49 +3889,49 @@ void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, | 
| if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, size, 4)) | 
| return; | 
| - m_context->uniform4iv(location->location(), size / 4, v); | 
| + m_drawingBuffer->context()->uniform4iv(location->location(), size / 4, v); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* location, GLboolean transpose, Float32Array* v) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, 4)) | 
| return; | 
| - m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose, v->data()); | 
| + m_drawingBuffer->context()->uniformMatrix2fv(location->location(), v->length() / 4, transpose, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* location, GLboolean transpose, GLfloat* v, GLsizei size) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, v, size, 4)) | 
| return; | 
| - m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v); | 
| + m_drawingBuffer->context()->uniformMatrix2fv(location->location(), size / 4, transpose, v); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* location, GLboolean transpose, Float32Array* v) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, 9)) | 
| return; | 
| - m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose, v->data()); | 
| + m_drawingBuffer->context()->uniformMatrix3fv(location->location(), v->length() / 9, transpose, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* location, GLboolean transpose, GLfloat* v, GLsizei size) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, v, size, 9)) | 
| return; | 
| - m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v); | 
| + m_drawingBuffer->context()->uniformMatrix3fv(location->location(), size / 9, transpose, v); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* location, GLboolean transpose, Float32Array* v) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, 16)) | 
| return; | 
| - m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpose, v->data()); | 
| + m_drawingBuffer->context()->uniformMatrix4fv(location->location(), v->length() / 16, transpose, v->data()); | 
| } | 
| void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* location, GLboolean transpose, GLfloat* v, GLsizei size) | 
| { | 
| if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v, size, 16)) | 
| return; | 
| - m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); | 
| + m_drawingBuffer->context()->uniformMatrix4fv(location->location(), size / 16, transpose, v); | 
| } | 
| void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 
| @@ -3949,9 +3947,9 @@ void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 
| } | 
| if (m_currentProgram != program) { | 
| if (m_currentProgram) | 
| - m_currentProgram->onDetached(m_context.get()); | 
| + m_currentProgram->onDetached(m_drawingBuffer->context()); | 
| m_currentProgram = program; | 
| - m_context->useProgram(objectOrZero(program)); | 
| + m_drawingBuffer->context()->useProgram(objectOrZero(program)); | 
| if (program) | 
| program->onAttached(); | 
| } | 
| @@ -3961,7 +3959,7 @@ void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 
| { | 
| if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 
| return; | 
| - m_context->validateProgram(objectOrZero(program)); | 
| + m_drawingBuffer->context()->validateProgram(objectOrZero(program)); | 
| } | 
| void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) | 
| @@ -4064,7 +4062,7 @@ void WebGLRenderingContextBase::vertexAttribPointer(GLuint index, GLint size, GL | 
| GLsizei bytesPerElement = size * typeSize; | 
| m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 
| - m_context->vertexAttribPointer(index, size, type, normalized, stride, static_cast<GLintptr>(offset)); | 
| + m_drawingBuffer->context()->vertexAttribPointer(index, size, type, normalized, stride, static_cast<GLintptr>(offset)); | 
| } | 
| void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint divisor) | 
| @@ -4078,7 +4076,7 @@ void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di | 
| } | 
| m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); | 
| - m_context->vertexAttribDivisorANGLE(index, divisor); | 
| + m_drawingBuffer->context()->vertexAttribDivisorANGLE(index, divisor); | 
| } | 
| void WebGLRenderingContextBase::viewport(GLint x, GLint y, GLsizei width, GLsizei height) | 
| @@ -4087,7 +4085,7 @@ void WebGLRenderingContextBase::viewport(GLint x, GLint y, GLsizei width, GLsize | 
| return; | 
| if (!validateSize("viewport", width, height)) | 
| return; | 
| - m_context->viewport(x, y, width, height); | 
| + m_drawingBuffer->context()->viewport(x, y, width, height); | 
| } | 
| void WebGLRenderingContextBase::forceLostContext(WebGLRenderingContextBase::LostContextMode mode) | 
| @@ -4112,7 +4110,7 @@ void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostC | 
| // Inform the embedder that a lost context was received. In response, the embedder might | 
| // decide to take action such as asking the user for permission to use WebGL again. | 
| if (LocalFrame* frame = canvas()->document().frame()) | 
| - frame->loader().client()->didLoseWebGLContext(m_context->getGraphicsResetStatusARB()); | 
| + frame->loader().client()->didLoseWebGLContext(m_drawingBuffer->context()->getGraphicsResetStatusARB()); | 
| } | 
| // Make absolutely sure we do not refer to an already-deleted texture or framebuffer. | 
| @@ -4164,15 +4162,22 @@ void WebGLRenderingContextBase::forceRestoreContext() | 
| m_restoreTimer.startOneShot(0); | 
| } | 
| +blink::WebGraphicsContext3D* WebGLRenderingContextBase::webGraphicsContext3D() const | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
Since this helper is here, please use it throughou
 | 
| +{ | 
| + ASSERT(m_drawingBuffer); | 
| + return m_drawingBuffer->context(); | 
| +} | 
| + | 
| blink::WebLayer* WebGLRenderingContextBase::platformLayer() const | 
| { | 
| - return m_drawingBuffer->platformLayer(); | 
| + return isContextLost() ? 0 : m_drawingBuffer->platformLayer(); | 
| } | 
| Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() | 
| { | 
| + ASSERT(!isContextLost()); | 
| if (!m_extensionsUtil) | 
| - m_extensionsUtil = adoptPtr(new Extensions3DUtil(m_context.get())); | 
| + m_extensionsUtil = adoptPtr(new Extensions3DUtil(m_drawingBuffer->context())); | 
| return m_extensionsUtil.get(); | 
| } | 
| @@ -4223,7 +4228,7 @@ WebGLGetInfo WebGLRenderingContextBase::getBooleanParameter(GLenum pname) | 
| { | 
| GLboolean value = 0; | 
| if (!isContextLost()) | 
| - m_context->getBooleanv(pname, &value); | 
| + m_drawingBuffer->context()->getBooleanv(pname, &value); | 
| return WebGLGetInfo(static_cast<bool>(value)); | 
| } | 
| @@ -4235,7 +4240,7 @@ WebGLGetInfo WebGLRenderingContextBase::getBooleanArrayParameter(GLenum pname) | 
| } | 
| GLboolean value[4] = {0}; | 
| if (!isContextLost()) | 
| - m_context->getBooleanv(pname, value); | 
| + m_drawingBuffer->context()->getBooleanv(pname, value); | 
| bool boolValue[4]; | 
| for (int ii = 0; ii < 4; ++ii) | 
| boolValue[ii] = static_cast<bool>(value[ii]); | 
| @@ -4246,7 +4251,7 @@ WebGLGetInfo WebGLRenderingContextBase::getFloatParameter(GLenum pname) | 
| { | 
| GLfloat value = 0; | 
| if (!isContextLost()) | 
| - m_context->getFloatv(pname, &value); | 
| + m_drawingBuffer->context()->getFloatv(pname, &value); | 
| return WebGLGetInfo(value); | 
| } | 
| @@ -4254,7 +4259,7 @@ WebGLGetInfo WebGLRenderingContextBase::getIntParameter(GLenum pname) | 
| { | 
| GLint value = 0; | 
| if (!isContextLost()) | 
| - m_context->getIntegerv(pname, &value); | 
| + m_drawingBuffer->context()->getIntegerv(pname, &value); | 
| return WebGLGetInfo(value); | 
| } | 
| @@ -4262,7 +4267,7 @@ WebGLGetInfo WebGLRenderingContextBase::getUnsignedIntParameter(GLenum pname) | 
| { | 
| GLint value = 0; | 
| if (!isContextLost()) | 
| - m_context->getIntegerv(pname, &value); | 
| + m_drawingBuffer->context()->getIntegerv(pname, &value); | 
| return WebGLGetInfo(static_cast<unsigned>(value)); | 
| } | 
| @@ -4270,7 +4275,7 @@ WebGLGetInfo WebGLRenderingContextBase::getWebGLFloatArrayParameter(GLenum pname | 
| { | 
| GLfloat value[4] = {0}; | 
| if (!isContextLost()) | 
| - m_context->getFloatv(pname, value); | 
| + m_drawingBuffer->context()->getFloatv(pname, value); | 
| unsigned length = 0; | 
| switch (pname) { | 
| case GL_ALIASED_POINT_SIZE_RANGE: | 
| @@ -4292,7 +4297,7 @@ WebGLGetInfo WebGLRenderingContextBase::getWebGLIntArrayParameter(GLenum pname) | 
| { | 
| GLint value[4] = {0}; | 
| if (!isContextLost()) | 
| - m_context->getIntegerv(pname, value); | 
| + m_drawingBuffer->context()->getIntegerv(pname, value); | 
| unsigned length = 0; | 
| switch (pname) { | 
| case GL_MAX_VIEWPORT_DIMS: | 
| @@ -4318,10 +4323,10 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa | 
| if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag)) | 
| || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { | 
| if (ii != m_activeTextureUnit) { | 
| - m_context->activeTexture(ii); | 
| + m_drawingBuffer->context()->activeTexture(ii); | 
| resetActiveUnit = true; | 
| } else if (resetActiveUnit) { | 
| - m_context->activeTexture(ii); | 
| + m_drawingBuffer->context()->activeTexture(ii); | 
| resetActiveUnit = false; | 
| } | 
| WebGLTexture* tex2D; | 
| @@ -4338,13 +4343,13 @@ void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa | 
| texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); | 
| } | 
| if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag)) | 
| - m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); | 
| if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag)) | 
| - m_context->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCubeMap)); | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCubeMap)); | 
| } | 
| } | 
| if (resetActiveUnit) | 
| - m_context->activeTexture(m_activeTextureUnit); | 
| + m_drawingBuffer->context()->activeTexture(m_activeTextureUnit); | 
| } | 
| void WebGLRenderingContextBase::createFallbackBlackTextures1x1() | 
| @@ -4352,25 +4357,25 @@ void WebGLRenderingContextBase::createFallbackBlackTextures1x1() | 
| // All calling functions check isContextLost, so a duplicate check is not needed here. | 
| unsigned char black[] = {0, 0, 0, 255}; | 
| m_blackTexture2D = createTexture(); | 
| - m_context->bindTexture(GL_TEXTURE_2D, m_blackTexture2D->object()); | 
| - m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_2D, m_blackTexture2D->object()); | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->bindTexture(GL_TEXTURE_2D, 0); | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_2D, 0); | 
| m_blackTextureCubeMap = createTexture(); | 
| - m_context->bindTexture(GL_TEXTURE_CUBE_MAP, m_blackTextureCubeMap->object()); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_CUBE_MAP, m_blackTextureCubeMap->object()); | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 1, 1, | 
| + m_drawingBuffer->context()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 1, 1, | 
| 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 
| - m_context->bindTexture(GL_TEXTURE_CUBE_MAP, 0); | 
| + m_drawingBuffer->context()->bindTexture(GL_TEXTURE_CUBE_MAP, 0); | 
| } | 
| bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat, GLenum colorBufferFormat) | 
| @@ -5147,7 +5152,7 @@ bool WebGLRenderingContextBase::validateDrawArrays(const char* functionName, GLe | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason); | 
| return false; | 
| } | 
| @@ -5197,7 +5202,7 @@ bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G | 
| } | 
| const char* reason = "framebuffer incomplete"; | 
| - if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(), &reason)) { | 
| + if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_drawingBuffer->context(), &reason)) { | 
| synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason); | 
| return false; | 
| } | 
| @@ -5235,16 +5240,16 @@ void WebGLRenderingContextBase::vertexAttribfImpl(const char* functionName, GLui | 
| // In GL, we skip setting vertexAttrib0 values. | 
| switch (expectedSize) { | 
| case 1: | 
| - m_context->vertexAttrib1f(index, v0); | 
| + m_drawingBuffer->context()->vertexAttrib1f(index, v0); | 
| break; | 
| case 2: | 
| - m_context->vertexAttrib2f(index, v0, v1); | 
| + m_drawingBuffer->context()->vertexAttrib2f(index, v0, v1); | 
| break; | 
| case 3: | 
| - m_context->vertexAttrib3f(index, v0, v1, v2); | 
| + m_drawingBuffer->context()->vertexAttrib3f(index, v0, v1, v2); | 
| break; | 
| case 4: | 
| - m_context->vertexAttrib4f(index, v0, v1, v2, v3); | 
| + m_drawingBuffer->context()->vertexAttrib4f(index, v0, v1, v2, v3); | 
| break; | 
| } | 
| VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 
| @@ -5284,16 +5289,16 @@ void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GLu | 
| // In GL, we skip setting vertexAttrib0 values. | 
| switch (expectedSize) { | 
| case 1: | 
| - m_context->vertexAttrib1fv(index, v); | 
| + m_drawingBuffer->context()->vertexAttrib1fv(index, v); | 
| break; | 
| case 2: | 
| - m_context->vertexAttrib2fv(index, v); | 
| + m_drawingBuffer->context()->vertexAttrib2fv(index, v); | 
| break; | 
| case 3: | 
| - m_context->vertexAttrib3fv(index, v); | 
| + m_drawingBuffer->context()->vertexAttrib3fv(index, v); | 
| break; | 
| case 4: | 
| - m_context->vertexAttrib4fv(index, v); | 
| + m_drawingBuffer->context()->vertexAttrib4fv(index, v); | 
| break; | 
| } | 
| VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 
| @@ -5336,7 +5341,16 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB | 
| blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->attributes(canvas()->document().topDocument()->url().string(), settings); | 
| OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes)); | 
| - if (!context) { | 
| + | 
| + ASSERT(!m_drawingBuffer); | 
| + if (context) { | 
| + RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptRef(new WebGLRenderingContextEvictionManager()); | 
| + DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 
| + m_drawingBuffer = DrawingBuffer::create(context.release(), clampedCanvasSize(), preserve, contextEvictionManager.release()); | 
| 
Ken Russell (switch to Gerrit)
2014/02/27 22:49:09
Are the offscreen context's resources fully releas
 | 
| + } | 
| + | 
| + bool failToRestore = !m_drawingBuffer; | 
| + if (failToRestore) { | 
| if (m_contextLostMode == RealLostContext) { | 
| m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); | 
| } else { | 
| @@ -5346,21 +5360,8 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB | 
| return; | 
| } | 
| - RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptRef(new WebGLRenderingContextEvictionManager()); | 
| - | 
| - // Construct a new drawing buffer with the new WebGraphicsContext3D. | 
| - m_drawingBuffer->releaseResources(); | 
| - DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 
| - m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); | 
| - | 
| - if (m_drawingBuffer->isZeroSized()) | 
| - return; | 
| - | 
| m_drawingBuffer->bind(); | 
| - | 
| m_lostContextErrors.clear(); | 
| - | 
| - m_context = context.release(); | 
| m_contextLost = false; | 
| setupFlags(); | 
| @@ -5443,7 +5444,7 @@ void WebGLRenderingContextBase::synthesizeGLError(GLenum error, const char* func | 
| printGLErrorToConsole(message); | 
| } | 
| if (!isContextLost()) | 
| - m_context->synthesizeGLError(error); | 
| + m_drawingBuffer->context()->synthesizeGLError(error); | 
| else { | 
| if (m_lostContextErrors.find(error) == WTF::kNotFound) | 
| m_lostContextErrors.append(error); | 
| @@ -5479,9 +5480,9 @@ void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 
| if (isContextLost()) | 
| return; | 
| if (enable) | 
| - m_context->enable(capability); | 
| + m_drawingBuffer->context()->enable(capability); | 
| else | 
| - m_context->disable(capability); | 
| + m_drawingBuffer->context()->disable(capability); | 
| } | 
| IntSize WebGLRenderingContextBase::clampedCanvasSize() | 
| @@ -5495,9 +5496,9 @@ GLint WebGLRenderingContextBase::maxDrawBuffers() | 
| if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) | 
| return 0; | 
| if (!m_maxDrawBuffers) | 
| - m_context->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); | 
| if (!m_maxColorAttachments) | 
| - m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachments); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachments); | 
| // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. | 
| return std::min(m_maxDrawBuffers, m_maxColorAttachments); | 
| } | 
| @@ -5507,7 +5508,7 @@ GLint WebGLRenderingContextBase::maxColorAttachments() | 
| if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) | 
| return 0; | 
| if (!m_maxColorAttachments) | 
| - m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachments); | 
| + m_drawingBuffer->context()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachments); | 
| return m_maxColorAttachments; | 
| } |