Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Unified Diff: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp

Issue 2391883004: Implement WebGL's commit with software compositing (Closed)
Patch Set: update comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698