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

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

Issue 2391883004: Implement WebGL's commit with software compositing (Closed)
Patch Set: rebase + nits 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..2d509755be8b9dbed5807ddc9de497a35aa26b23 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();
@@ -149,13 +154,16 @@ void OffscreenCanvasFrameDispatcherImpl::setTransferableResourceInTexture(
m_cachedImages.add(m_nextResourceId, std::move(image));
}
+// When WebGL's commit is called on swiftshade, we have software rendered WebGL.
Ken Russell (switch to Gerrit) 2016/10/05 20:24:50 typo: SwiftShader.
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 +192,10 @@ void OffscreenCanvasFrameDispatcherImpl::dispatchFrame(
else if (!image->isTextureBacked() &&
RuntimeEnabledFeatures::gpuCompositingEnabled())
setTransferableResourceMemoryToTexture(resource, image);
+ else if (image->isTextureBacked() &&
+ (!RuntimeEnabledFeatures::gpuCompositingEnabled() ||
+ isWebGLSoftwareRendering))
+ 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