| Index: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
|
| index 0810046dd880bf754b1eab8f2f66eb95d608d6c5..4eed48c5a7d9116a2fc1843c5eae2a63d6f88de7 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
|
| @@ -242,6 +242,15 @@ void DrawingBuffer::setFilterQuality(SkFilterQuality filterQuality)
|
| }
|
| }
|
|
|
| +bool DrawingBuffer::requiresRGBEmulation()
|
| +{
|
| +#if OS(MACOSX)
|
| + return !m_drawFramebufferBinding && !m_wantAlphaChannel && m_colorBuffer.imageId;
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| void DrawingBuffer::freeRecycledMailboxes()
|
| {
|
| if (m_recycledMailboxQueue.isEmpty())
|
| @@ -360,9 +369,11 @@ DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters()
|
| // on OSX.
|
| TextureParameters parameters;
|
| parameters.target = GC3D_TEXTURE_RECTANGLE_ARB;
|
| - parameters.internalColorFormat = GL_BGRA_EXT;
|
| + parameters.internalColorFormat = GL_RGBA;
|
| parameters.internalRenderbufferFormat = GL_RGBA8_OES;
|
| - parameters.colorFormat = GL_RGBA;
|
| +
|
| + // Unused.
|
| + parameters.colorFormat = 0;
|
| return parameters;
|
| #else
|
| return defaultTextureParameters();
|
| @@ -764,7 +775,7 @@ bool DrawingBuffer::reset(const IntSize& newSize, bool wantDepthOrStencilBuffer)
|
|
|
| m_gl->Disable(GL_SCISSOR_TEST);
|
| m_gl->ClearColor(0, 0, 0, 0);
|
| - m_gl->ColorMask(true, true, true, true);
|
| + m_gl->ColorMask(true, true, true, !requiresRGBEmulation());
|
|
|
| GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
|
| if (!!m_depthStencilBuffer) {
|
| @@ -779,6 +790,7 @@ bool DrawingBuffer::reset(const IntSize& newSize, bool wantDepthOrStencilBuffer)
|
| }
|
|
|
| clearFramebuffers(clearMask);
|
| + m_gl->ColorMask(true, true, true, true);
|
| return true;
|
| }
|
|
|
| @@ -948,14 +960,25 @@ void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
|
| }
|
| }
|
|
|
| -DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const IntSize& size)
|
| +void DrawingBuffer::clearChromiumImageIfNecessary(const TextureInfo& info)
|
| {
|
| - // TODO(erikchen): Add support for a CHROMIUM_image back buffer whose
|
| - // behavior mimics a texture with internal format GL_RGB.
|
| - // https://crbug.com/581777.
|
| - if (!m_wantAlphaChannel)
|
| - return createDefaultTextureAndAllocateMemory(size);
|
| + if (m_wantAlphaChannel)
|
| + return;
|
|
|
| + GLuint fbo = 0;
|
| + m_gl->GenFramebuffers(1, &fbo);
|
| + m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
|
| + m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, info.parameters.target, info.textureId, 0);
|
| + m_gl->ClearColor(0, 0, 0, 1);
|
| + m_gl->ColorMask(false, false, false, true);
|
| + m_gl->Clear(GL_COLOR_BUFFER_BIT);
|
| + m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, info.parameters.target, 0, 0);
|
| + m_gl->DeleteFramebuffers(1, &fbo);
|
| + restoreFramebufferBindings();
|
| +}
|
| +
|
| +DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const IntSize& size)
|
| +{
|
| if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled())
|
| return createDefaultTextureAndAllocateMemory(size);
|
|
|
| @@ -973,6 +996,7 @@ DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I
|
| info.textureId = textureId;
|
| info.imageId = imageId;
|
| info.parameters = parameters;
|
| + clearChromiumImageIfNecessary(info);
|
| return info;
|
| }
|
|
|
| @@ -997,6 +1021,7 @@ void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size)
|
| if (info->imageId) {
|
| m_gl->BindTexture(info->parameters.target, info->textureId);
|
| m_gl->BindTexImage2DCHROMIUM(info->parameters.target, info->imageId);
|
| + clearChromiumImageIfNecessary(*info);
|
| return;
|
| }
|
|
|
|
|