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

Unified Diff: src/utils/SkDeferredCanvas.cpp

Issue 803913005: Remove SkCanvas::isDrawingToLayer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: moar cleanup Created 6 years 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: src/utils/SkDeferredCanvas.cpp
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 94b3694708af1e2ad53c7e903e079b1da9fa93dd..5d625e070d310a74c0fadc4a1e8e2786644f3d58 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -154,6 +154,7 @@ public:
void skipPendingCommands();
void setMaxRecordingStorage(size_t);
void recordedDrawCommand();
+ void setIsDrawingToLayer(bool value) {fIsDrawingToLayer = value;}
virtual SkImageInfo imageInfo() const SK_OVERRIDE;
@@ -256,6 +257,7 @@ private:
SkDeferredCanvas::NotificationClient* fNotificationClient;
bool fFreshFrame;
bool fCanDiscardCanvasContents;
+ bool fIsDrawingToLayer;
size_t fMaxRecordingStorageBytes;
size_t fPreviousStorageAllocated;
};
@@ -308,7 +310,7 @@ void SkDeferredDevice::setNotificationClient(
}
void SkDeferredDevice::skipPendingCommands() {
- if (!fRecordingCanvas->isDrawingToLayer()) {
+ if (!fIsDrawingToLayer) {
fCanDiscardCanvasContents = true;
if (fPipeController.hasPendingCommands()) {
fFreshFrame = true;
@@ -522,6 +524,7 @@ void SkDeferredCanvas::init() {
fDeferredDrawing = true; // On by default
fCachedCanvasSize.setEmpty();
fCachedCanvasSizeDirty = true;
+ fSaveLevel = 0;
}
void SkDeferredCanvas::setMaxRecordingStorage(size_t maxStorage) {
@@ -673,6 +676,7 @@ bool SkDeferredCanvas::isFullFrame(const SkRect* rect,
}
void SkDeferredCanvas::willSave() {
+ fSaveLevel++;
this->drawingCanvas()->save();
this->recordedDrawCommand();
this->INHERITED::willSave();
@@ -680,6 +684,9 @@ void SkDeferredCanvas::willSave() {
SkCanvas::SaveLayerStrategy SkDeferredCanvas::willSaveLayer(const SkRect* bounds,
const SkPaint* paint, SaveFlags flags) {
+ fSaveLevel++;
+ fSaveLayerStack.push(fSaveLevel);
+ this->getDeferredDevice()->setIsDrawingToLayer(true);
this->drawingCanvas()->saveLayer(bounds, paint, flags);
this->recordedDrawCommand();
this->INHERITED::willSaveLayer(bounds, paint, flags);
@@ -688,15 +695,19 @@ SkCanvas::SaveLayerStrategy SkDeferredCanvas::willSaveLayer(const SkRect* bounds
}
void SkDeferredCanvas::willRestore() {
+ SkASSERT(fSaveLayerStack.isEmpty() || fSaveLayerStack.top() <= fSaveLevel);
+ if (!fSaveLayerStack.isEmpty() && fSaveLayerStack.top() == fSaveLevel) {
+ fSaveLayerStack.pop();
+ if (fSaveLayerStack.isEmpty())
+ {
+ this->getDeferredDevice()->setIsDrawingToLayer(false);
+ }
+ }
this->drawingCanvas()->restore();
this->recordedDrawCommand();
this->INHERITED::willRestore();
}
-bool SkDeferredCanvas::isDrawingToLayer() const {
- return this->drawingCanvas()->isDrawingToLayer();
-}
-
void SkDeferredCanvas::didConcat(const SkMatrix& matrix) {
this->drawingCanvas()->concat(matrix);
this->recordedDrawCommand();
« src/pipe/SkGPipeWrite.cpp ('K') | « src/pipe/SkGPipeWrite.cpp ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698