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

Unified Diff: skia/ext/analysis_canvas.cc

Issue 2425323002: Abort canvas analysis after a few operations are rejected (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 | « skia/ext/analysis_canvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/analysis_canvas.cc
diff --git a/skia/ext/analysis_canvas.cc b/skia/ext/analysis_canvas.cc
index 2caa73d00dd2cbad35493532d6de1b9ade8cd84d..b5d1e9830e458416a101c49c4b2c09a07ed4b44f 100644
--- a/skia/ext/analysis_canvas.cc
+++ b/skia/ext/analysis_canvas.cc
@@ -54,7 +54,7 @@ bool IsFullQuad(SkCanvas* canvas, const SkRect& drawn_rect) {
SkIRect clip_irect;
if (!canvas->getClipDeviceBounds(&clip_irect))
return false;
-
+
// if the clip is smaller than the canvas, we're partly clipped, so abort.
if (!clip_irect.contains(SkIRect::MakeSize(canvas->getBaseLayerSize())))
return false;
@@ -113,6 +113,7 @@ void AnalysisCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
quickReject(paint.computeFastBounds(rect, &scratch))) {
TRACE_EVENT_INSTANT0("disabled-by-default-skia", "Quick reject.",
TRACE_EVENT_SCOPE_THREAD);
+ ++rejected_op_count_;
return;
}
@@ -349,7 +350,8 @@ AnalysisCanvas::AnalysisCanvas(int width, int height)
is_solid_color_(true),
color_(SK_ColorTRANSPARENT),
is_transparent_(true),
- draw_op_count_(0) {
+ draw_op_count_(0),
+ rejected_op_count_(0) {
}
AnalysisCanvas::~AnalysisCanvas() {}
@@ -367,11 +369,11 @@ bool AnalysisCanvas::GetColorIfSolid(SkColor* color) const {
}
bool AnalysisCanvas::abort() {
- // Early out as soon as we have more than one draw op.
- // TODO(vmpstr): Investigate if 1 is the correct metric here. We need to
- // balance the amount of time we spend analyzing vs how many tiles would be
- // solid if the number was higher.
- if (draw_op_count_ > 1) {
+ // Early out as soon as we have more than 1 draw op or 5 rejected ops.
+ // TODO(vmpstr): Investigate if 1 and 5 are the correct metrics here. We need
+ // to balance the amount of time we spend analyzing vs how many tiles would be
+ // solid if the numbers were higher.
+ if (draw_op_count_ > 1 || rejected_op_count_ > 5) {
TRACE_EVENT0("disabled-by-default-skia",
"AnalysisCanvas::abort() -- aborting");
// We have to reset solid/transparent state to false since we don't
« no previous file with comments | « skia/ext/analysis_canvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698