Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
index 1c9814fb06148134d02cf4279bc6e42abeab84e5..f6091bd592c5d17320fd11b378c4081d591c0900 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -4910,8 +4910,7 @@ |
SentinelEmptyRect(), 1, 0, exception_state); |
} |
-bool WebGLRenderingContextBase::CanUseTexImageByGPU(GLenum format, |
- GLenum type) { |
+bool WebGLRenderingContextBase::CanUseTexImageByGPU(GLenum type) { |
#if OS(MACOSX) |
// RGB5_A1 is not color-renderable on NVIDIA Mac, see crbug.com/676209. |
// Though, glCopyTextureCHROMIUM can handle RGB5_A1 internalformat by doing a |
@@ -4921,14 +4920,6 @@ |
if (type == GL_UNSIGNED_SHORT_5_5_5_1) |
return false; |
#endif |
- // TODO(kbr): bugs were observed when using CopyTextureCHROMIUM to |
- // copy hardware-accelerated video textures to red-channel textures. |
- // These bugs were seen on macOS but may indicate more general |
- // problems. Investigate the root cause of this and fix it. |
- // crbug.com/710673 |
- if (format == GL_RED || format == GL_RED_INTEGER) |
- return false; |
- |
// OES_texture_half_float doesn't support HALF_FLOAT_OES type for |
// CopyTexImage/CopyTexSubImage. And OES_texture_half_float doesn't require |
// HALF_FLOAT_OES type texture to be renderable. So, HALF_FLOAT_OES type |
@@ -5120,7 +5111,7 @@ |
// float/integer/sRGB internal format. |
// TODO(crbug.com/622958): relax the constrains if copyTextureCHROMIUM is |
// upgraded to handle more formats. |
- if (!canvas->IsAccelerated() || !CanUseTexImageByGPU(format, type)) { |
+ if (!canvas->IsAccelerated() || !CanUseTexImageByGPU(type)) { |
// 2D canvas has only FrontBuffer. |
TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset, |
zoffset, format, type, |
@@ -5232,10 +5223,9 @@ |
source_image_rect == SentinelEmptyRect() || |
source_image_rect == |
IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
- const bool use_copyTextureCHROMIUM = function_id == kTexImage2D && |
- source_image_rect_is_default && |
- depth == 1 && GL_TEXTURE_2D == target && |
- CanUseTexImageByGPU(format, type); |
+ const bool use_copyTextureCHROMIUM = |
+ function_id == kTexImage2D && source_image_rect_is_default && |
+ depth == 1 && GL_TEXTURE_2D == target && CanUseTexImageByGPU(type); |
// Format of source video may be 16-bit format, e.g. Y16 format. |
// glCopyTextureCHROMIUM requires the source texture to be in 8-bit format. |
// Converting 16-bits formated source texture to 8-bits formated texture will |
@@ -5249,9 +5239,16 @@ |
// to system memory if possible. Otherwise, it will fall back to the normal |
// SW path. |
- if (video->CopyVideoTextureToPlatformTexture( |
- ContextGL(), texture->Object(), internalformat, format, type, |
- unpack_premultiply_alpha_, unpack_flip_y_)) { |
+ // Note that neither |
+ // HTMLVideoElement::copyVideoTextureToPlatformTexture nor |
+ // ImageBuffer::copyToPlatformTexture allocate the destination texture |
+ // any more. |
+ TexImage2DBase(target, level, internalformat, video->videoWidth(), |
+ video->videoHeight(), 0, format, type, nullptr); |
+ |
+ if (video->CopyVideoTextureToPlatformTexture(ContextGL(), texture->Object(), |
+ unpack_premultiply_alpha_, |
+ unpack_flip_y_)) { |
texture->UpdateLastUploadedVideo(video->GetWebMediaPlayer()); |
return; |
} |
@@ -5295,11 +5292,6 @@ |
// This is a straight GPU-GPU copy, any necessary color space conversion |
// was handled in the paintCurrentFrameInContext() call. |
- // Note that copyToPlatformTexture no longer allocates the destination |
- // texture. |
- TexImage2DBase(target, level, internalformat, video->videoWidth(), |
- video->videoHeight(), 0, format, type, nullptr); |
- |
if (image_buffer->CopyToPlatformTexture( |
FunctionIDToSnapshotReason(function_id), ContextGL(), target, |
texture->Object(), unpack_premultiply_alpha_, unpack_flip_y_, |
@@ -5396,7 +5388,7 @@ |
// TODO(kbr): make this work for sub-rectangles of ImageBitmaps. |
if (function_id != kTexSubImage3D && function_id != kTexImage3D && |
- bitmap->IsAccelerated() && CanUseTexImageByGPU(format, type) && |
+ bitmap->IsAccelerated() && CanUseTexImageByGPU(type) && |
!selecting_sub_rectangle) { |
if (function_id == kTexImage2D) { |
TexImage2DBase(target, level, internalformat, width, height, 0, format, |