aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils
diff options
context:
space:
mode:
authorGravatar yunchao.he <yunchao.he@intel.com>2014-09-15 22:30:38 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-15 22:30:38 -0700
commit49005bf8929dd8ca86431e13414d683b509cd538 (patch)
tree4fe756315ab114196dff8bf3c63712f7f6cdbfb3 /include/utils
parentae232a20d74de16baaec356787f968b4f04144c6 (diff)
Picture Recording: fix the performance bottleneck in SkDeferredCanvas::isFullFrame
blink skips all pending commands during picture recording if it is drawing an opaque full-frame geometry or image. This may improve performance for some edge cases. To recognize an opaque full-frame drawing should be cheap enough. Otherwise, the overhead will offset the improvement. Unfortunately, data from perf for content_shell on Nexus7 shows that SkDeferredCanvas::isFullFrame is far from cheap. Table below shows that how much isFullFrame() costs in the whole render process. benchmark percentage my local benchmark(draw 1000 sprites) 4.1% speedReading 2.8% FishIETank(1000 fishes) 1.5% GUIMark3 Bitmap 2.0% By contrast, real recording (SkGPipeCanvas::drawBitmapRectToRect) and real rasterization (GrDrawTarget::drawRect) cost ~4% and ~6% in the whole render process respectively. Apparently, SkDeferredCanvas::isFullFrame() is nontrivial. getDeviceSize() is the main contributor to this hotspot. The change simply save the canvasSize and reuse it among drawings if it is not a fresh frame. This change cut off ~65% (or improved ~2 times) of isFullFrame(). telemetry smoothness canvas_tough_test didn't show obvious improvement or regression. BUG=411166 Committed: https://skia.googlesource.com/skia/+/8e45c3777d886ba3fe239bb549d06b0693692152 R=junov@chromium.org, tomhudson@google.com, reed@google.com Author: yunchao.he@intel.com Review URL: https://codereview.chromium.org/545813002
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/SkDeferredCanvas.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h
index 907cb91575..5f781f8859 100644
--- a/include/utils/SkDeferredCanvas.h
+++ b/include/utils/SkDeferredCanvas.h
@@ -89,6 +89,11 @@ public:
bool isFreshFrame() const;
/**
+ * Returns canvas's size.
+ */
+ SkISize getCanvasSize() const;
+
+ /**
* Returns true if the canvas has recorded draw commands that have
* not yet been played back.
*/
@@ -250,6 +255,9 @@ private:
size_t fBitmapSizeThreshold;
bool fDeferredDrawing;
+ mutable SkISize fCachedCanvasSize;
+ mutable bool fCachedCanvasSizeDirty;
+
friend class SkDeferredCanvasTester; // for unit testing
typedef SkCanvas INHERITED;
};