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

Unified Diff: Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 1308853003: 2D Canvas: disable rendering deferral in cases with a lot of overdraw (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Canvas2DLayerBridge.cpp
diff --git a/Source/platform/graphics/Canvas2DLayerBridge.cpp b/Source/platform/graphics/Canvas2DLayerBridge.cpp
index f33300a52a2f25773036320fdef0ea3087c29dd9..7f68b5fdf4c27eb206d95587f3917583a44fb634 100644
--- a/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -32,6 +32,7 @@
#include "SkSurface.h"
#include "platform/TraceEvent.h"
+#include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/ImageBuffer.h"
#include "public/platform/Platform.h"
@@ -139,6 +140,7 @@ void Canvas2DLayerBridge::startRecording()
if (m_imageBuffer) {
m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas());
}
+ m_recordingPixelCount = 0;
}
SkCanvas* Canvas2DLayerBridge::canvas()
@@ -489,10 +491,15 @@ WebLayer* Canvas2DLayerBridge::layer() const
return m_layer->layer();
}
-void Canvas2DLayerBridge::didDraw()
+void Canvas2DLayerBridge::didDraw(const FloatRect& rect)
{
- if (m_isDeferralEnabled)
+ if (m_isDeferralEnabled) {
m_haveRecordedDrawCommands = true;
+ IntRect pixelBounds = enclosingIntRect(rect);
+ m_recordingPixelCount += pixelBounds.width() * pixelBounds.height();
+ if (m_recordingPixelCount >= (m_size.width() * m_size.height() * ExpensiveCanvasHeuristicParameters::ExpensiveOverdrawThreshold))
+ disableDeferral();
+ }
}
void Canvas2DLayerBridge::finalizeFrame(const FloatRect &dirtyRect)
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerBridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698