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

Unified Diff: src/utils/SkDeferredCanvas.cpp

Issue 545813002: Picture Recording: fix the performance bottleneck in SkDeferredCanvas::isFullFrame (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: add a test case for SkDeferredCanvas::getCanvasSize into tests/DeferredCanvasTest.cpp Created 6 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 | « include/utils/SkDeferredCanvas.h ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDeferredCanvas.cpp
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index b46e92a4a09690d60da94d95a634aad43b799f7d..ac78751d142dd39a9db1d8de3ee0637b9778f525 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -526,6 +526,8 @@ SkDeferredCanvas::SkDeferredCanvas(SkDeferredDevice* device) : SkCanvas (device)
void SkDeferredCanvas::init() {
fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold;
fDeferredDrawing = true; // On by default
+ fCanvasSizeChanged = true;
reed1 2014/09/11 15:38:13 nit: often in skia we name this sort of boolean "D
yunchao 2014/09/12 10:13:28 Done.
+ fCanvasSize.setEmpty();
reed1 2014/09/11 15:38:13 nit: may be clear to name this fCachedCanvasSize,
yunchao 2014/09/12 10:13:28 Done.
}
void SkDeferredCanvas::setMaxRecordingStorage(size_t maxStorage) {
@@ -589,6 +591,14 @@ bool SkDeferredCanvas::isFreshFrame() const {
return this->getDeferredDevice()->isFreshFrame();
}
+SkISize SkDeferredCanvas::getCanvasSize() {
+ if (fCanvasSizeChanged) {
+ fCanvasSize = this->getBaseLayerSize();
+ fCanvasSizeChanged = false;
+ }
+ return fCanvasSize;
+}
+
bool SkDeferredCanvas::hasPendingCommands() const {
return this->getDeferredDevice()->hasPendingCommands();
}
@@ -609,6 +619,7 @@ SkSurface* SkDeferredCanvas::setSurface(SkSurface* surface) {
// all pending commands, which can help to seamlessly recover from
// a lost accelerated graphics context.
deferredDevice->setSurface(surface);
+ fCanvasSizeChanged = true;
return surface;
}
@@ -630,9 +641,9 @@ SkImage* SkDeferredCanvas::newImageSnapshot() {
}
bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
- const SkPaint* paint) const {
+ const SkPaint* paint) {
SkCanvas* canvas = this->drawingCanvas();
- SkISize canvasSize = this->getDeviceSize();
+ SkISize canvasSize = this->getCanvasSize();
if (rect) {
if (!canvas->getTotalMatrix().rectStaysRect()) {
return false; // conservative
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698