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

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

Issue 249453002: First step in pulling SkPicturePlayback & SkPictureRecord out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleanup Created 6 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 unified diff | Download patch | Annotate | Revision Log
« 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 #ifndef SkPicturePlayback_DEFINED 8 #ifndef SkPicturePlayback_DEFINED
9 #define SkPicturePlayback_DEFINED 9 #define SkPicturePlayback_DEFINED
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 struct SkPictCopyInfo { 68 struct SkPictCopyInfo {
69 SkPictCopyInfo() : initialized(false), controller(1024) {} 69 SkPictCopyInfo() : initialized(false), controller(1024) {}
70 70
71 bool initialized; 71 bool initialized;
72 SkChunkFlatController controller; 72 SkChunkFlatController controller;
73 SkTDArray<SkFlatData*> paintData; 73 SkTDArray<SkFlatData*> paintData;
74 }; 74 };
75 75
76 class SkPicturePlayback { 76 class SkPicturePlayback {
77 public: 77 public:
78 SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo = NULL); 78 SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src,
79 SkPicturePlayback(const SkPictureRecord& record, const SkPictInfo&, bool dee pCopy = false); 79 SkPictCopyInfo* deepCopyInfo = NULL);
80 static SkPicturePlayback* CreateFromStream(SkStream*, 80 SkPicturePlayback(const SkPicture* picture, const SkPictureRecord& record, c onst SkPictInfo&,
81 bool deepCopy = false);
82 static SkPicturePlayback* CreateFromStream(SkPicture* picture,
83 SkStream*,
81 const SkPictInfo&, 84 const SkPictInfo&,
82 SkPicture::InstallPixelRefProc); 85 SkPicture::InstallPixelRefProc);
83 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&) ; 86 static SkPicturePlayback* CreateFromBuffer(SkPicture* picture,
87 SkReadBuffer&,
88 const SkPictInfo&);
84 89
85 virtual ~SkPicturePlayback(); 90 virtual ~SkPicturePlayback();
86 91
87 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); 92 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect);
88 93
89 void draw(SkCanvas& canvas, SkDrawPictureCallback*); 94 void draw(SkCanvas& canvas, SkDrawPictureCallback*);
90 95
91 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; 96 void serialize(SkWStream*, SkPicture::EncodeBitmap) const;
92 void flatten(SkWriteBuffer&) const; 97 void flatten(SkWriteBuffer&) const;
93 98
94 void dumpSize() const; 99 void dumpSize() const;
95 100
96 bool containsBitmaps() const; 101 bool containsBitmaps() const;
97 102
98 #ifdef SK_BUILD_FOR_ANDROID 103 #ifdef SK_BUILD_FOR_ANDROID
99 // Can be called in the middle of playback (the draw() call). WIll abort the 104 // Can be called in the middle of playback (the draw() call). WIll abort the
100 // drawing and return from draw() after the "current" op code is done 105 // drawing and return from draw() after the "current" op code is done
101 void abort() { fAbortCurrentPlayback = true; } 106 void abort() { fAbortCurrentPlayback = true; }
102 #endif 107 #endif
103 108
104 size_t curOpID() const { return fCurOffset; } 109 size_t curOpID() const { return fCurOffset; }
105 void resetOpID() { fCurOffset = 0; } 110 void resetOpID() { fCurOffset = 0; }
106 111
107 protected: 112 protected:
108 explicit SkPicturePlayback(const SkPictInfo& info); 113 explicit SkPicturePlayback(const SkPicture* picture, const SkPictInfo& info) ;
109 114
110 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); 115 bool parseStream(SkPicture* picture, SkStream*, SkPicture::InstallPixelRefPr oc);
111 bool parseBuffer(SkReadBuffer& buffer); 116 bool parseBuffer(SkPicture* picture, SkReadBuffer& buffer);
112 #ifdef SK_DEVELOPER 117 #ifdef SK_DEVELOPER
113 virtual bool preDraw(int opIndex, int type); 118 virtual bool preDraw(int opIndex, int type);
114 virtual void postDraw(int opIndex); 119 virtual void postDraw(int opIndex);
115 #endif 120 #endif
116 121
117 private: 122 private:
118 class TextContainer { 123 class TextContainer {
119 public: 124 public:
120 size_t length() { return fByteLength; } 125 size_t length() { return fByteLength; }
121 const void* text() { return (const void*) fText; } 126 const void* text() { return (const void*) fText; }
(...skipping 10 matching lines...) Expand all
132 return fBadBitmap; 137 return fBadBitmap;
133 } 138 }
134 return (*fBitmaps)[index]; 139 return (*fBitmaps)[index];
135 } 140 }
136 141
137 void getMatrix(SkReader32& reader, SkMatrix* matrix) { 142 void getMatrix(SkReader32& reader, SkMatrix* matrix) {
138 reader.readMatrix(matrix); 143 reader.readMatrix(matrix);
139 } 144 }
140 145
141 const SkPath& getPath(SkReader32& reader) { 146 const SkPath& getPath(SkReader32& reader) {
142 return (*fPathHeap)[reader.readInt() - 1]; 147 return fPicture->getPath(reader.readInt() - 1);
143 } 148 }
144 149
145 SkPicture& getPicture(SkReader32& reader) { 150 SkPicture& getPicture(SkReader32& reader) {
146 int index = reader.readInt(); 151 int index = reader.readInt();
147 SkASSERT(index > 0 && index <= fPictureCount); 152 SkASSERT(index > 0 && index <= fPictureCount);
148 return *fPictureRefs[index - 1]; 153 return *fPictureRefs[index - 1];
149 } 154 }
150 155
151 const SkPaint* getPaint(SkReader32& reader) { 156 const SkPaint* getPaint(SkReader32& reader) {
152 int index = reader.readInt(); 157 int index = reader.readInt();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 int dumpRectPtr(char* bufferPtr, char* buffer, char* name); 213 int dumpRectPtr(char* bufferPtr, char* buffer, char* name);
209 int dumpScalar(char* bufferPtr, char* buffer, char* name); 214 int dumpScalar(char* bufferPtr, char* buffer, char* name);
210 void dumpText(char** bufferPtrPtr, char* buffer); 215 void dumpText(char** bufferPtrPtr, char* buffer);
211 void dumpStream(); 216 void dumpStream();
212 217
213 public: 218 public:
214 void dump() const; 219 void dump() const;
215 #endif 220 #endif
216 221
217 private: // these help us with reading/writing 222 private: // these help us with reading/writing
218 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta llPixelRefProc); 223 bool parseStreamTag(SkPicture* picture, SkStream*, uint32_t tag, uint32_t si ze,
219 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); 224 SkPicture::InstallPixelRefProc);
225 bool parseBufferTag(SkPicture* picture, SkReadBuffer&, uint32_t tag, uint32_ t size);
220 void flattenToBuffer(SkWriteBuffer&) const; 226 void flattenToBuffer(SkWriteBuffer&) const;
221 227
222 private: 228 private:
229 // The picture that owns this SkPicturePlayback object
230 const SkPicture* fPicture;
231
223 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty 232 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty
224 // bitmap allows playback to draw nothing and move on. 233 // bitmap allows playback to draw nothing and move on.
225 SkBitmap fBadBitmap; 234 SkBitmap fBadBitmap;
226 235
227 SkAutoTUnref<SkBitmapHeap> fBitmapHeap; 236 SkAutoTUnref<SkBitmapHeap> fBitmapHeap;
228 SkAutoTUnref<SkPathHeap> fPathHeap;
229 237
230 SkTRefArray<SkBitmap>* fBitmaps; 238 SkTRefArray<SkBitmap>* fBitmaps;
231 SkTRefArray<SkPaint>* fPaints; 239 SkTRefArray<SkPaint>* fPaints;
232 240
233 SkData* fOpData; // opcodes and parameters 241 SkData* fOpData; // opcodes and parameters
234 242
235 SkPicture** fPictureRefs; 243 SkPicture** fPictureRefs;
236 int fPictureCount; 244 int fPictureCount;
237 245
238 SkBBoxHierarchy* fBoundingHierarchy; 246 SkBBoxHierarchy* fBoundingHierarchy;
(...skipping 23 matching lines...) Expand all
262 CachedOperationList* fCachedActiveOps; 270 CachedOperationList* fCachedActiveOps;
263 271
264 SkTypefacePlayback fTFPlayback; 272 SkTypefacePlayback fTFPlayback;
265 SkFactoryPlayback* fFactoryPlayback; 273 SkFactoryPlayback* fFactoryPlayback;
266 274
267 // The offset of the current operation when within the draw method 275 // The offset of the current operation when within the draw method
268 size_t fCurOffset; 276 size_t fCurOffset;
269 277
270 const SkPictInfo fInfo; 278 const SkPictInfo fInfo;
271 279
280 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
281 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
282
272 #ifdef SK_BUILD_FOR_ANDROID 283 #ifdef SK_BUILD_FOR_ANDROID
273 SkMutex fDrawMutex; 284 SkMutex fDrawMutex;
274 bool fAbortCurrentPlayback; 285 bool fAbortCurrentPlayback;
275 #endif 286 #endif
276 }; 287 };
277 288
278 #endif 289 #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