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

Unified Diff: src/utils/SkDeferredCanvas.cpp

Issue 14063015: Adding optimization to avoid image copy in SkSurface copy on write when content is discardable (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | « src/image/SkSurface_Raster.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDeferredCanvas.cpp
===================================================================
--- src/utils/SkDeferredCanvas.cpp (revision 8710)
+++ src/utils/SkDeferredCanvas.cpp (working copy)
@@ -248,6 +248,7 @@
SkSurface* fSurface;
SkDeferredCanvas::NotificationClient* fNotificationClient;
bool fFreshFrame;
+ bool fCanDiscardCanvasContents;
size_t fMaxRecordingStorageBytes;
size_t fPreviousStorageAllocated;
size_t fBitmapSizeThreshold;
@@ -281,6 +282,7 @@
void DeferredDevice::init() {
fRecordingCanvas = NULL;
fFreshFrame = true;
+ fCanDiscardCanvasContents = false;
fPreviousStorageAllocated = 0;
fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold;
fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes;
@@ -312,11 +314,14 @@
}
void DeferredDevice::skipPendingCommands() {
- if (!fRecordingCanvas->isDrawingToLayer() && fPipeController.hasPendingCommands()) {
- fFreshFrame = true;
- flushPendingCommands(kSilent_PlaybackMode);
- if (fNotificationClient) {
- fNotificationClient->skippedPendingDrawCommands();
+ if (!fRecordingCanvas->isDrawingToLayer()) {
+ fCanDiscardCanvasContents = true;
+ if (fPipeController.hasPendingCommands()) {
+ fFreshFrame = true;
+ flushPendingCommands(kSilent_PlaybackMode);
+ if (fNotificationClient) {
+ fNotificationClient->skippedPendingDrawCommands();
+ }
}
}
}
@@ -335,8 +340,18 @@
if (!fPipeController.hasPendingCommands()) {
return;
}
- if (playbackMode == kNormal_PlaybackMode && fNotificationClient) {
- fNotificationClient->prepareForDraw();
+ if (playbackMode == kNormal_PlaybackMode) {
+ if (NULL != fNotificationClient) {
+ fNotificationClient->prepareForDraw();
+ }
+ if (fCanDiscardCanvasContents) {
+ if (NULL != fSurface) {
+ // Pre-empt notifyContentChanged(false) calls that will happen
+ // during flush
+ fSurface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
+ }
+ fCanDiscardCanvasContents = false;
+ }
}
fPipeWriter.flushRecording(true);
fPipeController.playback(kSilent_PlaybackMode == playbackMode);
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698