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

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

Issue 206853003: Add new experimental API to SkPicture to get "id" of current op (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | no next file » | 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 "SkOffsetTable.h" 9 #include "SkOffsetTable.h"
10 #include "SkPicturePlayback.h" 10 #include "SkPicturePlayback.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void SkPicturePlayback::init() { 254 void SkPicturePlayback::init() {
255 fBitmaps = NULL; 255 fBitmaps = NULL;
256 fPaints = NULL; 256 fPaints = NULL;
257 fPictureRefs = NULL; 257 fPictureRefs = NULL;
258 fPictureCount = 0; 258 fPictureCount = 0;
259 fOpData = NULL; 259 fOpData = NULL;
260 fFactoryPlayback = NULL; 260 fFactoryPlayback = NULL;
261 fBoundingHierarchy = NULL; 261 fBoundingHierarchy = NULL;
262 fStateTree = NULL; 262 fStateTree = NULL;
263 fCachedActiveOps = NULL; 263 fCachedActiveOps = NULL;
264 fCurOffset = 0;
264 } 265 }
265 266
266 SkPicturePlayback::~SkPicturePlayback() { 267 SkPicturePlayback::~SkPicturePlayback() {
267 SkSafeUnref(fOpData); 268 SkSafeUnref(fOpData);
268 269
269 SkSafeUnref(fBitmaps); 270 SkSafeUnref(fBitmaps);
270 SkSafeUnref(fPaints); 271 SkSafeUnref(fPaints);
271 SkSafeUnref(fBoundingHierarchy); 272 SkSafeUnref(fBoundingHierarchy);
272 SkSafeUnref(fStateTree); 273 SkSafeUnref(fStateTree);
273 274
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 if (0 != fCachedActiveOps->fOps.count()) { 832 if (0 != fCachedActiveOps->fOps.count()) {
832 SkTQSort<SkPictureStateTree::Draw>( 833 SkTQSort<SkPictureStateTree::Draw>(
833 reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps. begin()), 834 reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps. begin()),
834 reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps. end()-1)); 835 reinterpret_cast<SkPictureStateTree::Draw**>(fCachedActiveOps->fOps. end()-1));
835 } 836 }
836 837
837 fCachedActiveOps->fCacheQueryRect = query; 838 fCachedActiveOps->fCacheQueryRect = query;
838 return *fCachedActiveOps; 839 return *fCachedActiveOps;
839 } 840 }
840 841
842 class SkAutoResetOpID {
843 public:
844 SkAutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { }
845 ~SkAutoResetOpID() {
846 if (NULL != fPlayback) {
847 fPlayback->resetOpID();
848 }
849 }
850
851 private:
852 SkPicturePlayback* fPlayback;
853 };
854
841 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { 855 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
856 SkAutoResetOpID aroi(this);
857 SkASSERT(0 == fCurOffset);
858
842 #ifdef ENABLE_TIME_DRAW 859 #ifdef ENABLE_TIME_DRAW
843 SkAutoTime at("SkPicture::draw", 50); 860 SkAutoTime at("SkPicture::draw", 50);
844 #endif 861 #endif
845 862
846 #ifdef SPEW_CLIP_SKIPPING 863 #ifdef SPEW_CLIP_SKIPPING
847 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; 864 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull;
848 int opCount = 0; 865 int opCount = 0;
849 #endif 866 #endif
850 867
851 #ifdef SK_BUILD_FOR_ANDROID 868 #ifdef SK_BUILD_FOR_ANDROID
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 #ifdef SK_BUILD_FOR_ANDROID 929 #ifdef SK_BUILD_FOR_ANDROID
913 if (fAbortCurrentPlayback) { 930 if (fAbortCurrentPlayback) {
914 return; 931 return;
915 } 932 }
916 #endif 933 #endif
917 934
918 #ifdef SPEW_CLIP_SKIPPING 935 #ifdef SPEW_CLIP_SKIPPING
919 opCount++; 936 opCount++;
920 #endif 937 #endif
921 938
922 size_t curOffset = reader.offset(); 939 fCurOffset = reader.offset();
923 uint32_t size; 940 uint32_t size;
924 DrawType op = read_op_and_size(&reader, &size); 941 DrawType op = read_op_and_size(&reader, &size);
925 size_t skipTo = 0; 942 size_t skipTo = 0;
926 if (NOOP == op) { 943 if (NOOP == op) {
927 // NOOPs are to be ignored - do not propagate them any further 944 // NOOPs are to be ignored - do not propagate them any further
928 skipTo = curOffset + size; 945 skipTo = fCurOffset + size;
929 #ifdef SK_DEVELOPER 946 #ifdef SK_DEVELOPER
930 } else { 947 } else {
931 opIndex++; 948 opIndex++;
932 if (this->preDraw(opIndex, op)) { 949 if (this->preDraw(opIndex, op)) {
933 skipTo = curOffset + size; 950 skipTo = fCurOffset + size;
934 } 951 }
935 #endif 952 #endif
936 } 953 }
937 954
938 if (0 != skipTo) { 955 if (0 != skipTo) {
939 if (it.isValid()) { 956 if (it.isValid()) {
940 // If using a bounding box hierarchy, advance the state tree 957 // If using a bounding box hierarchy, advance the state tree
941 // iterator until at or after skipTo 958 // iterator until at or after skipTo
942 uint32_t adjustedSkipTo; 959 uint32_t adjustedSkipTo;
943 do { 960 do {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 for (index = 0; index < fPictureCount; index++) 1822 for (index = 0; index < fPictureCount; index++)
1806 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1823 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1807 "picture%p, ", fPictureRefs[index]); 1824 "picture%p, ", fPictureRefs[index]);
1808 if (fPictureCount > 0) 1825 if (fPictureCount > 0)
1809 SkDebugf("%s0};\n", pBuffer); 1826 SkDebugf("%s0};\n", pBuffer);
1810 1827
1811 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1828 const_cast<SkPicturePlayback*>(this)->dumpStream();
1812 } 1829 }
1813 1830
1814 #endif 1831 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698