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

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

Issue 324293004: Remove picture pre-allocation from SkPictureRecorder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix initializer list order Created 6 years, 6 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 | « src/core/SkPicture.cpp ('k') | src/core/SkPicturePlayback.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkPicturePlayback_DEFINED 9 #ifndef SkPicturePlayback_DEFINED
10 #define SkPicturePlayback_DEFINED 10 #define SkPicturePlayback_DEFINED
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // This tag specifies the size of the ReadBuffer, needed for the following tags 55 // This tag specifies the size of the ReadBuffer, needed for the following tags
56 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') 56 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y')
57 // these are all inside the ARRAYS tag 57 // these are all inside the ARRAYS tag
58 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') 58 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p')
59 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') 59 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ')
60 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') 60 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ')
61 61
62 // Always write this guy last (with no length field afterwards) 62 // Always write this guy last (with no length field afterwards)
63 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') 63 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ')
64 64
65 // SkPictureContentInfo is not serialized! It is intended solely for use
66 // with suitableForGpuRasterization.
67 class SkPictureContentInfo {
68 public:
69 SkPictureContentInfo() { this->reset(); }
70
71 SkPictureContentInfo(const SkPictureContentInfo& src) { this->set(src); }
72
73 void set(const SkPictureContentInfo& src) {
74 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
75 fNumAAConcavePaths = src.fNumAAConcavePaths;
76 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
77 }
78
79 void reset() {
80 fNumPaintWithPathEffectUses = 0;
81 fNumAAConcavePaths = 0;
82 fNumAAHairlineConcavePaths = 0;
83 }
84
85 void swap(SkPictureContentInfo* other) {
86 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses) ;
87 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
88 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
89 }
90
91 void incPaintWithPathEffectUses() { ++fNumPaintWithPathEffectUses; }
92 int numPaintWithPathEffectUses() const { return fNumPaintWithPathEffectUses; }
93
94 void incAAConcavePaths() { ++fNumAAConcavePaths; }
95 int numAAConcavePaths() const { return fNumAAConcavePaths; }
96
97 void incAAHairlineConcavePaths() {
98 ++fNumAAHairlineConcavePaths;
99 SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths);
100 }
101 int numAAHairlineConcavePaths() const { return fNumAAHairlineConcavePaths; }
102
103 private:
104 // This field is incremented every time a paint with a path effect is
105 // used (i.e., it is not a de-duplicated count)
106 int fNumPaintWithPathEffectUses;
107 // This field is incremented every time an anti-aliased drawPath call is
108 // issued with a concave path
109 int fNumAAConcavePaths;
110 // This field is incremented every time a drawPath call is
111 // issued for a hairline stroked concave path.
112 int fNumAAHairlineConcavePaths;
113 };
114
65 /** 115 /**
66 * Container for data that is needed to deep copy a SkPicture. The container 116 * Container for data that is needed to deep copy a SkPicture. The container
67 * enables the data to be generated once and reused for subsequent copies. 117 * enables the data to be generated once and reused for subsequent copies.
68 */ 118 */
69 struct SkPictCopyInfo { 119 struct SkPictCopyInfo {
70 SkPictCopyInfo() : initialized(false), controller(1024) {} 120 SkPictCopyInfo() : initialized(false), controller(1024) {}
71 121
72 bool initialized; 122 bool initialized;
73 SkChunkFlatController controller; 123 SkChunkFlatController controller;
74 SkTDArray<SkFlatData*> paintData; 124 SkTDArray<SkFlatData*> paintData;
75 }; 125 };
76 126
77 class SkPicturePlayback { 127 class SkPicturePlayback {
78 public: 128 public:
79 SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src, 129 SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src,
80 SkPictCopyInfo* deepCopyInfo = NULL); 130 SkPictCopyInfo* deepCopyInfo = NULL);
81 SkPicturePlayback(const SkPicture* picture, const SkPictureRecord& record, c onst SkPictInfo&, 131 SkPicturePlayback(const SkPicture* picture, const SkPictureRecord& record,
82 bool deepCopyOps); 132 const SkPictInfo&, bool deepCopyOps);
83 static SkPicturePlayback* CreateFromStream(SkPicture* picture, 133 static SkPicturePlayback* CreateFromStream(SkPicture* picture,
84 SkStream*, 134 SkStream*,
85 const SkPictInfo&, 135 const SkPictInfo&,
86 SkPicture::InstallPixelRefProc); 136 SkPicture::InstallPixelRefProc);
87 static SkPicturePlayback* CreateFromBuffer(SkPicture* picture, 137 static SkPicturePlayback* CreateFromBuffer(SkPicture* picture,
88 SkReadBuffer&, 138 SkReadBuffer&,
89 const SkPictInfo&); 139 const SkPictInfo&);
90 140
91 virtual ~SkPicturePlayback(); 141 virtual ~SkPicturePlayback();
92 142
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 int dumpPtr(char* bufferPtr, char* buffer, char* name, void* ptr); 265 int dumpPtr(char* bufferPtr, char* buffer, char* name, void* ptr);
216 int dumpRectPtr(char* bufferPtr, char* buffer, char* name); 266 int dumpRectPtr(char* bufferPtr, char* buffer, char* name);
217 int dumpScalar(char* bufferPtr, char* buffer, char* name); 267 int dumpScalar(char* bufferPtr, char* buffer, char* name);
218 void dumpText(char** bufferPtrPtr, char* buffer); 268 void dumpText(char** bufferPtrPtr, char* buffer);
219 void dumpStream(); 269 void dumpStream();
220 270
221 public: 271 public:
222 void dump() const; 272 void dump() const;
223 #endif 273 #endif
224 274
275 #if SK_SUPPORT_GPU
276 bool suitableForGpuRasterization(GrContext* context, const char **reason) co nst;
277 #endif
278
225 private: // these help us with reading/writing 279 private: // these help us with reading/writing
226 bool parseStreamTag(SkPicture* picture, SkStream*, uint32_t tag, uint32_t si ze, 280 bool parseStreamTag(SkPicture* picture, SkStream*, uint32_t tag, uint32_t si ze,
227 SkPicture::InstallPixelRefProc); 281 SkPicture::InstallPixelRefProc);
228 bool parseBufferTag(SkPicture* picture, SkReadBuffer&, uint32_t tag, uint32_ t size); 282 bool parseBufferTag(SkPicture* picture, SkReadBuffer&, uint32_t tag, uint32_ t size);
229 void flattenToBuffer(SkWriteBuffer&) const; 283 void flattenToBuffer(SkWriteBuffer&) const;
230 284
231 private: 285 private:
232 friend class SkPicture; 286 friend class SkPicture;
233 friend class SkGpuDevice; // for access to setDrawLimits & setReplacements 287 friend class SkGpuDevice; // for access to setDrawLimits & setReplacements
234 288
(...skipping 10 matching lines...) Expand all
245 SkTRefArray<SkPaint>* fPaints; 299 SkTRefArray<SkPaint>* fPaints;
246 300
247 SkData* fOpData; // opcodes and parameters 301 SkData* fOpData; // opcodes and parameters
248 302
249 const SkPicture** fPictureRefs; 303 const SkPicture** fPictureRefs;
250 int fPictureCount; 304 int fPictureCount;
251 305
252 SkBBoxHierarchy* fBoundingHierarchy; 306 SkBBoxHierarchy* fBoundingHierarchy;
253 SkPictureStateTree* fStateTree; 307 SkPictureStateTree* fStateTree;
254 308
309 SkPictureContentInfo fContentInfo;
310
255 // Limit the opcode playback to be between the offsets 'start' and 'stop'. 311 // Limit the opcode playback to be between the offsets 'start' and 'stop'.
256 // The opcode at 'start' should be a saveLayer while the opcode at 312 // The opcode at 'start' should be a saveLayer while the opcode at
257 // 'stop' should be a restore. Neither of those commands will be issued. 313 // 'stop' should be a restore. Neither of those commands will be issued.
258 // Set both start & stop to 0 to disable draw limiting 314 // Set both start & stop to 0 to disable draw limiting
259 // Draw limiting cannot be enabled at the same time as draw replacing 315 // Draw limiting cannot be enabled at the same time as draw replacing
260 void setDrawLimits(size_t start, size_t stop) { 316 void setDrawLimits(size_t start, size_t stop) {
261 SkASSERT(NULL == fReplacements); 317 SkASSERT(NULL == fReplacements);
262 fStart = start; 318 fStart = start;
263 fStop = stop; 319 fStop = stop;
264 } 320 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); 403 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
348 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); 404 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
349 405
350 #ifdef SK_BUILD_FOR_ANDROID 406 #ifdef SK_BUILD_FOR_ANDROID
351 SkMutex fDrawMutex; 407 SkMutex fDrawMutex;
352 bool fAbortCurrentPlayback; 408 bool fAbortCurrentPlayback;
353 #endif 409 #endif
354 }; 410 };
355 411
356 #endif 412 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698