OLD | NEW |
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 SkPictureData_DEFINED |
10 #define SkPicturePlayback_DEFINED | 10 #define SkPictureData_DEFINED |
11 | 11 |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 #include "SkPathHeap.h" | 13 #include "SkPathHeap.h" |
14 #include "SkPicture.h" | 14 #include "SkPicture.h" |
15 #include "SkPictureFlat.h" | 15 #include "SkPictureFlat.h" |
16 | 16 |
17 #ifdef SK_BUILD_FOR_ANDROID | 17 #ifdef SK_BUILD_FOR_ANDROID |
18 #include "SkThread.h" | 18 #include "SkThread.h" |
19 #endif | 19 #endif |
20 | 20 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 */ | 126 */ |
127 struct SkPictCopyInfo { | 127 struct SkPictCopyInfo { |
128 SkPictCopyInfo() : initialized(false), controller(1024) {} | 128 SkPictCopyInfo() : initialized(false), controller(1024) {} |
129 | 129 |
130 bool initialized; | 130 bool initialized; |
131 SkChunkFlatController controller; | 131 SkChunkFlatController controller; |
132 SkTDArray<SkFlatData*> paintData; | 132 SkTDArray<SkFlatData*> paintData; |
133 }; | 133 }; |
134 #endif | 134 #endif |
135 | 135 |
136 class SkPicturePlayback { | 136 class SkPictureData { |
137 public: | 137 public: |
138 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 138 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
139 SkPicturePlayback(const SkPicturePlayback& src, | 139 SkPictureData(const SkPictureData& src, |
140 SkPictCopyInfo* deepCopyInfo = NULL); | 140 SkPictCopyInfo* deepCopyInfo = NULL); |
141 #else | 141 #else |
142 SkPicturePlayback(const SkPicturePlayback& src); | 142 SkPictureData(const SkPictureData& src); |
143 #endif | 143 #endif |
144 SkPicturePlayback(const SkPictureRecord& record, const SkPictInfo&, bool dee
pCopyOps); | 144 SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCop
yOps); |
145 static SkPicturePlayback* CreateFromStream(SkStream*, | 145 static SkPictureData* CreateFromStream(SkStream*, |
146 const SkPictInfo&, | 146 const SkPictInfo&, |
147 SkPicture::InstallPixelRefProc); | 147 SkPicture::InstallPixelRefProc); |
148 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&, | 148 static SkPictureData* CreateFromBuffer(SkReadBuffer&, |
149 const SkPictInfo&); | 149 const SkPictInfo&); |
150 | 150 |
151 virtual ~SkPicturePlayback(); | 151 virtual ~SkPictureData(); |
152 | 152 |
153 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); | 153 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); |
154 | 154 |
155 void setUseBBH(bool useBBH) { fUseBBH = useBBH; } | 155 void setUseBBH(bool useBBH) { fUseBBH = useBBH; } |
156 | 156 |
157 void draw(SkCanvas& canvas, SkDrawPictureCallback*); | 157 void draw(SkCanvas& canvas, SkDrawPictureCallback*); |
158 | 158 |
159 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; | 159 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; |
160 void flatten(SkWriteBuffer&) const; | 160 void flatten(SkWriteBuffer&) const; |
161 | 161 |
162 void dumpSize() const; | 162 void dumpSize() const; |
163 | 163 |
164 bool containsBitmaps() const; | 164 bool containsBitmaps() const; |
165 | 165 |
166 #ifdef SK_BUILD_FOR_ANDROID | 166 #ifdef SK_BUILD_FOR_ANDROID |
167 // Can be called in the middle of playback (the draw() call). WIll abort the | 167 // Can be called in the middle of playback (the draw() call). WIll abort the |
168 // drawing and return from draw() after the "current" op code is done | 168 // drawing and return from draw() after the "current" op code is done |
169 void abort() { fAbortCurrentPlayback = true; } | 169 void abort() { fAbortCurrentPlayback = true; } |
170 #endif | 170 #endif |
171 | 171 |
172 size_t curOpID() const { return fCurOffset; } | 172 size_t curOpID() const { return fCurOffset; } |
173 void resetOpID() { fCurOffset = 0; } | 173 void resetOpID() { fCurOffset = 0; } |
174 | 174 |
175 protected: | 175 protected: |
176 explicit SkPicturePlayback(const SkPictInfo& info); | 176 explicit SkPictureData(const SkPictInfo& info); |
177 | 177 |
178 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); | 178 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); |
179 bool parseBuffer(SkReadBuffer& buffer); | 179 bool parseBuffer(SkReadBuffer& buffer); |
180 #ifdef SK_DEVELOPER | 180 #ifdef SK_DEVELOPER |
181 virtual bool preDraw(int opIndex, int type); | 181 virtual bool preDraw(int opIndex, int type); |
182 virtual void postDraw(int opIndex); | 182 virtual void postDraw(int opIndex); |
183 #endif | 183 #endif |
184 | 184 |
185 private: | 185 private: |
186 class TextContainer { | 186 class TextContainer { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 }; | 358 }; |
359 | 359 |
360 ~PlaybackReplacements() { this->freeAll(); } | 360 ~PlaybackReplacements() { this->freeAll(); } |
361 | 361 |
362 // Add a new replacement range. The replacement ranges should be | 362 // Add a new replacement range. The replacement ranges should be |
363 // sorted in increasing order and non-overlapping (esp. no nested | 363 // sorted in increasing order and non-overlapping (esp. no nested |
364 // saveLayers). | 364 // saveLayers). |
365 ReplacementInfo* push(); | 365 ReplacementInfo* push(); |
366 | 366 |
367 private: | 367 private: |
368 friend class SkPicturePlayback; // for access to lookupByStart | 368 friend class SkPictureData; // for access to lookupByStart |
369 | 369 |
370 // look up a replacement range by its start offset | 370 // look up a replacement range by its start offset |
371 ReplacementInfo* lookupByStart(size_t start); | 371 ReplacementInfo* lookupByStart(size_t start); |
372 | 372 |
373 void freeAll(); | 373 void freeAll(); |
374 | 374 |
375 #ifdef SK_DEBUG | 375 #ifdef SK_DEBUG |
376 void validate() const; | 376 void validate() const; |
377 #endif | 377 #endif |
378 | 378 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 void initForPlayback() const; | 429 void initForPlayback() const; |
430 | 430 |
431 #ifdef SK_BUILD_FOR_ANDROID | 431 #ifdef SK_BUILD_FOR_ANDROID |
432 SkMutex fDrawMutex; | 432 SkMutex fDrawMutex; |
433 bool fAbortCurrentPlayback; | 433 bool fAbortCurrentPlayback; |
434 #endif | 434 #endif |
435 }; | 435 }; |
436 | 436 |
437 #endif | 437 #endif |
OLD | NEW |