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

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

Issue 2141793002: Improving canvas 2D performance by switching graphics rendering pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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 4dede47795e53ea3150db3e8b3eb3fb629914f17..7fce4434ac99a816724c31199d24812288e9fb70 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -147,6 +147,7 @@ inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
, m_originClean(true)
, m_didFailToCreateImageBuffer(false)
, m_imageBufferIsClear(false)
+ , m_numFramesSincePipelineSwitch(0)
{
CanvasMetrics::countCanvasContextUsage(CanvasMetrics::CanvasCreated);
}
@@ -292,6 +293,13 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect)
buffer()->didDraw(rect);
}
+static void disableAccelerationWrapper(WeakPtr<ImageBuffer> buffer)
+{
+ if (buffer) {
+ buffer->disableAcceleration();
+ }
+}
+
void HTMLCanvasElement::didFinalizeFrame()
{
notifyListenersCanvasChanged();
@@ -315,6 +323,18 @@ void HTMLCanvasElement::didFinalizeFrame()
ro->invalidatePaintRectangle(mappedDirtyRect);
}
m_dirtyRect = FloatRect();
+
+ m_numFramesSincePipelineSwitch++;
+ if (m_context->is2d() && buffer()->isAccelerated() && m_numFramesSincePipelineSwitch >= 3) {
Justin Novosad 2016/07/12 19:31:23 This hard coded 3 should go into a named constant
sebastienlc 2016/07/13 19:51:02 Done.
+ if (RuntimeEnabledFeatures::enableCanvas2dDynamicPipelineModeEnabled()) {
+ if (!m_context->shouldAccelerate()) {
+ Platform::current()->currentThread()->getWebTaskRunner()->postTask(
+ BLINK_FROM_HERE, WTF::bind(&disableAccelerationWrapper,
+ m_imageBuffer->m_weakPtrFactory.createWeakPtr()));
+ m_numFramesSincePipelineSwitch = 0;
+ }
+ }
+ }
}
void HTMLCanvasElement::didDisableAcceleration()

Powered by Google App Engine
This is Rietveld 408576698