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 32416b2befbeabbe7bb114d8140b223cad285ab8..ce16c86666138f98266eb9759a7e2ec7783c7363 100644 |
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp |
@@ -284,7 +284,8 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt |
m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
} |
} else { |
- m_gl->CopyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.internalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); |
+ m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, |
+ 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE); |
} |
restoreFramebufferBindings(); |
@@ -477,6 +478,7 @@ bool DrawingBuffer::initialize(const IntSize& size, bool useMultisampling) |
m_antiAliasingMode = ScreenSpaceAntialiasing; |
} |
} |
+ m_storageTextureSupported = m_extensionsUtil->supportsExtension("GL_EXT_texture_storage"); |
Zhenyao Mo
2016/07/06 18:12:06
What about WebGL 2 / ES3 context? This extension
dshwang
2016/07/07 12:33:26
Done. Set m_storageTextureSupported to true on Web
|
m_sampleCount = std::min(4, maxSampleCount); |
m_gl->GenFramebuffers(1, &m_fbo); |
@@ -941,10 +943,22 @@ void DrawingBuffer::flipVertically(uint8_t* framebuffer, int width, int height) |
} |
} |
-void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment) |
+bool DrawingBuffer::createStorageTextureIfPossible(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type) |
Zhenyao Mo
2016/07/06 18:12:06
To me this method should not return anything. It
Ken Russell (switch to Gerrit)
2016/07/06 23:53:49
Naming nit: could you please call this "allocate*"
dshwang
2016/07/07 12:33:26
Done.
|
{ |
- ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); |
- m_gl->TexImage2D(target, level, internalformat, width, height, border, format, type, 0); |
+ if (m_storageTextureSupported) { |
+ GLenum internalStorageFormat = GL_NONE; |
+ if (internalformat == GL_RGB) { |
+ internalStorageFormat = GL_RGB8; |
+ } else if (internalformat == GL_RGBA) { |
+ internalStorageFormat = GL_RGBA8; |
+ } else { |
+ NOTREACHED(); |
+ } |
+ m_gl->TexStorage2DEXT(GL_TEXTURE_2D, 1, internalStorageFormat, width, height); |
+ return true; |
+ } |
+ m_gl->TexImage2D(target, 0, internalformat, width, height, border, format, type, 0); |
+ return false; |
} |
void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
@@ -1006,13 +1020,12 @@ DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I |
DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(const IntSize& size) |
{ |
- TextureParameters parameters = defaultTextureParameters(); |
- GLuint textureId = createColorTexture(parameters); |
- texImage2DResourceSafe(parameters.target, 0, parameters.creationInternalColorFormat, size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYTE); |
- |
DrawingBuffer::TextureInfo info; |
- info.textureId = textureId; |
+ TextureParameters parameters = defaultTextureParameters(); |
info.parameters = parameters; |
+ info.textureId = createColorTexture(parameters); |
+ info.immutable = createStorageTextureIfPossible(parameters.target, parameters.creationInternalColorFormat, |
+ size.width(), size.height(), 0, parameters.colorFormat, GL_UNSIGNED_BYTE); |
return info; |
} |
@@ -1020,11 +1033,17 @@ void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) |
{ |
ASSERT(info->textureId); |
if (!RuntimeEnabledFeatures::webGLImageChromiumEnabled()) { |
+ if (info->immutable) { |
+ m_gl->DeleteTextures(1, &info->textureId); |
+ info->textureId = createColorTexture(info->parameters); |
+ } |
m_gl->BindTexture(info->parameters.target, info->textureId); |
- texImage2DResourceSafe(info->parameters.target, 0, info->parameters.creationInternalColorFormat, size.width(), size.height(), 0, info->parameters.colorFormat, GL_UNSIGNED_BYTE); |
+ info->immutable = createStorageTextureIfPossible(info->parameters.target, info->parameters.creationInternalColorFormat, |
+ size.width(), size.height(), 0, info->parameters.colorFormat, GL_UNSIGNED_BYTE); |
return; |
} |
+ DCHECK(!info->immutable); |
deleteChromiumImageForTexture(info); |
info->imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), size.height(), info->parameters.creationInternalColorFormat, GC3D_SCANOUT_CHROMIUM); |
if (info->imageId) { |