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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2320663002: Fix performance regression in WebGL to 2D canvas draws. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index 9ec0e15ee415e2d3c8463837151c3a6201bf026e..2e58bec4cd36bf80e7f4042a0613b8a186f9b851 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -1126,16 +1126,18 @@ PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageStatus*
return createTransparentImage(size());
}
+ sk_sp<SkImage> skImage;
if (m_context->is3d()) {
- m_context->paintRenderingResultsToCanvas(BackBuffer);
+ // Because WebGL sources always require making a copy of the back buffer, we
+ // use paintRenderingResultsToCanvas instead of getImage in order to keep a cached
+ // copy of the backing in the canvas's ImageBuffer.
+ renderingContext()->paintRenderingResultsToCanvas(BackBuffer);
+ skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason) : createTransparentImage(size())->imageForCurrentFrame();
+ } else {
+ RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason);
+ skImage = image ? image->imageForCurrentFrame() : createTransparentImage(size())->imageForCurrentFrame();
}
- sk_sp<SkImage> skImage;
- RefPtr<blink::Image> image = renderingContext()->getImage(reason);
-
- if (image)
- skImage = image->imageForCurrentFrame();
-
if (skImage) {
*status = NormalSourceImageStatus;
return StaticBitmapImage::create(std::move(skImage));
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698