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 #ifndef SkPicturePlayback_DEFINED | 8 #ifndef SkPicturePlayback_DEFINED |
9 #define SkPicturePlayback_DEFINED | 9 #define SkPicturePlayback_DEFINED |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 public: | 78 public: |
79 SkPicturePlayback(); | 79 SkPicturePlayback(); |
80 SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo
= NULL); | 80 SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo
= NULL); |
81 explicit SkPicturePlayback(const SkPictureRecord& record, bool deepCopy = fa
lse); | 81 explicit SkPicturePlayback(const SkPictureRecord& record, bool deepCopy = fa
lse); |
82 static SkPicturePlayback* CreateFromStream(SkStream*, const SkPictInfo&, | 82 static SkPicturePlayback* CreateFromStream(SkStream*, const SkPictInfo&, |
83 SkPicture::InstallPixelRefProc); | 83 SkPicture::InstallPixelRefProc); |
84 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&); | 84 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&); |
85 | 85 |
86 virtual ~SkPicturePlayback(); | 86 virtual ~SkPicturePlayback(); |
87 | 87 |
| 88 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); |
| 89 |
88 void draw(SkCanvas& canvas, SkDrawPictureCallback*); | 90 void draw(SkCanvas& canvas, SkDrawPictureCallback*); |
89 | 91 |
90 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; | 92 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; |
91 void flatten(SkWriteBuffer&) const; | 93 void flatten(SkWriteBuffer&) const; |
92 | 94 |
93 void dumpSize() const; | 95 void dumpSize() const; |
94 | 96 |
95 bool containsBitmaps() const; | 97 bool containsBitmaps() const; |
96 | 98 |
97 #ifdef SK_BUILD_FOR_ANDROID | 99 #ifdef SK_BUILD_FOR_ANDROID |
98 // Can be called in the middle of playback (the draw() call). WIll abort the | 100 // Can be called in the middle of playback (the draw() call). WIll abort the |
99 // drawing and return from draw() after the "current" op code is done | 101 // drawing and return from draw() after the "current" op code is done |
100 void abort() { fAbortCurrentPlayback = true; } | 102 void abort() { fAbortCurrentPlayback = true; } |
101 #endif | 103 #endif |
102 | 104 |
103 protected: | 105 protected: |
104 bool parseStream(SkStream*, const SkPictInfo&, | 106 bool parseStream(SkStream*, const SkPictInfo&, |
105 SkPicture::InstallPixelRefProc); | 107 SkPicture::InstallPixelRefProc); |
106 bool parseBuffer(SkReadBuffer& buffer); | 108 bool parseBuffer(SkReadBuffer& buffer); |
107 #ifdef SK_DEVELOPER | 109 #ifdef SK_DEVELOPER |
108 virtual bool preDraw(int opIndex, int type); | 110 virtual bool preDraw(int opIndex, int type); |
109 virtual void postDraw(int opIndex); | 111 virtual void postDraw(int opIndex); |
110 #endif | 112 #endif |
111 | 113 |
112 void preLoadBitmaps(const SkTDArray<void*>& results); | 114 void preLoadBitmaps(const SkTDArray<void*>* results); |
113 | 115 |
114 private: | 116 private: |
115 class TextContainer { | 117 class TextContainer { |
116 public: | 118 public: |
117 size_t length() { return fByteLength; } | 119 size_t length() { return fByteLength; } |
118 const void* text() { return (const void*) fText; } | 120 const void* text() { return (const void*) fText; } |
119 size_t fByteLength; | 121 size_t fByteLength; |
120 const char* fText; | 122 const char* fText; |
121 }; | 123 }; |
122 | 124 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 232 |
231 SkData* fOpData; // opcodes and parameters | 233 SkData* fOpData; // opcodes and parameters |
232 SkAutoTUnref<SkOffsetTable> fBitmapUseOffsets; | 234 SkAutoTUnref<SkOffsetTable> fBitmapUseOffsets; |
233 | 235 |
234 SkPicture** fPictureRefs; | 236 SkPicture** fPictureRefs; |
235 int fPictureCount; | 237 int fPictureCount; |
236 | 238 |
237 SkBBoxHierarchy* fBoundingHierarchy; | 239 SkBBoxHierarchy* fBoundingHierarchy; |
238 SkPictureStateTree* fStateTree; | 240 SkPictureStateTree* fStateTree; |
239 | 241 |
| 242 class CachedOperationList : public SkPicture::OperationList { |
| 243 public: |
| 244 CachedOperationList() { |
| 245 fCacheQueryRect.setEmpty(); |
| 246 } |
| 247 |
| 248 virtual bool valid() const { return true; } |
| 249 virtual int numOps() const SK_OVERRIDE { return fOps.count(); } |
| 250 virtual uint32_t offset(int index) const SK_OVERRIDE; |
| 251 virtual const SkMatrix& matrix(int index) const SK_OVERRIDE; |
| 252 |
| 253 // The query rect for which the cached active ops are valid |
| 254 SkIRect fCacheQueryRect; |
| 255 |
| 256 // The operations which are active within 'fCachedQueryRect' |
| 257 SkTDArray<void*> fOps; |
| 258 |
| 259 private: |
| 260 typedef SkPicture::OperationList INHERITED; |
| 261 }; |
| 262 |
| 263 CachedOperationList* fCachedActiveOps; |
| 264 |
240 SkTypefacePlayback fTFPlayback; | 265 SkTypefacePlayback fTFPlayback; |
241 SkFactoryPlayback* fFactoryPlayback; | 266 SkFactoryPlayback* fFactoryPlayback; |
242 #ifdef SK_BUILD_FOR_ANDROID | 267 #ifdef SK_BUILD_FOR_ANDROID |
243 SkMutex fDrawMutex; | 268 SkMutex fDrawMutex; |
244 bool fAbortCurrentPlayback; | 269 bool fAbortCurrentPlayback; |
245 #endif | 270 #endif |
246 }; | 271 }; |
247 | 272 |
248 #endif | 273 #endif |
OLD | NEW |