Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| index 0b160d20031fff5bf12f426bc9ff473785a1801d..f7ade9e2154e2e12748f943cbc27c942b8de4835 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| @@ -52,7 +52,10 @@ OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl( |
| mojo::GetProxy(&m_sink)); |
| } |
| -// Case 1: both canvas and compositor are not gpu accelerated. |
| +// Case 1: both canvas and compositor are not gpu accelerated, or canvas is |
| +// accelerated but --disable-gpu-compositing is specified, or |
| +// WebGL's commit called with swiftshader. The last case is indicated by |
| +// WebGraphicsContext3DProvider::isSoftwareRendering. |
| void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceInMemory( |
| cc::TransferableResource& resource, |
| RefPtr<StaticBitmapImage> image) { |
| @@ -66,6 +69,8 @@ void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceInMemory( |
| m_width, m_height, kN32_SkColorType, |
| image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); |
| // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456. |
| + // However, in the case when |image| is texture backed, this function call |
| + // does a GPU readback which is required. |
| image->imageForCurrentFrame()->readPixels(imageInfo, pixels, |
| imageInfo.minRowBytes(), 0, 0); |
| resource.mailbox_holder.mailbox = bitmap->id(); |
| @@ -150,12 +155,14 @@ void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceInTexture( |
| } |
| void OffscreenCanvasFrameDispatcherImpl::dispatchFrame( |
| - RefPtr<StaticBitmapImage> image) { |
| + RefPtr<StaticBitmapImage> image, |
| + bool isWebGLSoftwareRendering) { |
| if (!image) |
| return; |
| if (!verifyImageSize(image->imageForCurrentFrame())) |
| return; |
| cc::CompositorFrame frame; |
| + // TODO(crbug.com/652931): update the device_scale_factor |
| frame.metadata.device_scale_factor = 1.0f; |
| frame.delegated_frame_data.reset(new cc::DelegatedFrameData); |
| @@ -184,6 +191,10 @@ void OffscreenCanvasFrameDispatcherImpl::dispatchFrame( |
| else if (!image->isTextureBacked() && |
| RuntimeEnabledFeatures::gpuCompositingEnabled()) |
| setTransferableResourceMemoryToTexture(resource, image); |
| + else if (image->isTextureBacked() && |
| + (!RuntimeEnabledFeatures::gpuCompositingEnabled() || |
| + isWebGLSoftwareRendering)) |
|
Justin Novosad
2016/10/05 15:38:56
Could you add a comment that explains the rational
|
| + setTransferableResourceInMemory(resource, image); |
| else |
| setTransferableResourceInTexture(resource, image); |