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

Side by Side Diff: src/core/SkPicturePlayback.cpp

Issue 286033005: Ensure playing back a picture always balances saves and restores (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments Created 6 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include <new> 7 #include <new>
8 #include "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkPicturePlayback.h" 9 #include "SkPicturePlayback.h"
10 #include "SkPictureRecord.h" 10 #include "SkPictureRecord.h"
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 if (it.isValid()) { 852 if (it.isValid()) {
853 uint32_t skipTo = it.nextDraw(); 853 uint32_t skipTo = it.nextDraw();
854 if (kDrawComplete == skipTo) { 854 if (kDrawComplete == skipTo) {
855 return; 855 return;
856 } 856 }
857 reader.setOffset(skipTo); 857 reader.setOffset(skipTo);
858 } 858 }
859 859
860 // Record this, so we can concat w/ it if we encounter a setMatrix() 860 // Record this, so we can concat w/ it if we encounter a setMatrix()
861 SkMatrix initialMatrix = canvas.getTotalMatrix(); 861 SkMatrix initialMatrix = canvas.getTotalMatrix();
862 int originalSaveCount = canvas.getSaveCount(); 862
863 SkAutoCanvasRestore acr(&canvas, false);
863 864
864 #ifdef SK_BUILD_FOR_ANDROID 865 #ifdef SK_BUILD_FOR_ANDROID
865 fAbortCurrentPlayback = false; 866 fAbortCurrentPlayback = false;
866 #endif 867 #endif
867 868
868 #ifdef SK_DEVELOPER 869 #ifdef SK_DEVELOPER
869 int opIndex = -1; 870 int opIndex = -1;
870 #endif 871 #endif
871 872
872 while (!reader.eof()) { 873 while (!reader.eof()) {
873 if (callback && callback->abortDrawing()) { 874 if (callback && callback->abortDrawing()) {
874 canvas.restoreToCount(originalSaveCount);
875 return; 875 return;
876 } 876 }
877 #ifdef SK_BUILD_FOR_ANDROID 877 #ifdef SK_BUILD_FOR_ANDROID
878 if (fAbortCurrentPlayback) { 878 if (fAbortCurrentPlayback) {
879 return; 879 return;
880 } 880 }
881 #endif 881 #endif
882 if (0 != fStart || 0 != fStop) { 882 if (0 != fStart || 0 != fStop) {
883 size_t offset = reader.offset() ; 883 size_t offset = reader.offset() ;
884 if (offset >= fStop) { 884 if (offset >= fStop) {
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 for (index = 0; index < fPictureCount; index++) 1838 for (index = 0; index < fPictureCount; index++)
1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1840 "picture%p, ", fPictureRefs[index]); 1840 "picture%p, ", fPictureRefs[index]);
1841 if (fPictureCount > 0) 1841 if (fPictureCount > 0)
1842 SkDebugf("%s0};\n", pBuffer); 1842 SkDebugf("%s0};\n", pBuffer);
1843 1843
1844 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1844 const_cast<SkPicturePlayback*>(this)->dumpStream();
1845 } 1845 }
1846 1846
1847 #endif 1847 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698