Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 struct SkPictCopyInfo { | 69 struct SkPictCopyInfo { |
| 70 SkPictCopyInfo() : initialized(false), controller(1024) {} | 70 SkPictCopyInfo() : initialized(false), controller(1024) {} |
| 71 | 71 |
| 72 bool initialized; | 72 bool initialized; |
| 73 SkChunkFlatController controller; | 73 SkChunkFlatController controller; |
| 74 SkTDArray<SkFlatData*> paintData; | 74 SkTDArray<SkFlatData*> paintData; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class SkPicturePlayback { | 77 class SkPicturePlayback { |
| 78 public: | 78 public: |
| 79 SkPicturePlayback(); | |
| 80 SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo = NULL); | 79 SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo = NULL); |
| 81 explicit SkPicturePlayback(const SkPictureRecord& record, bool deepCopy = fa lse); | 80 SkPicturePlayback(const SkPictureRecord& record, const SkPictInfo&, bool dee pCopy = false); |
| 82 static SkPicturePlayback* CreateFromStream(SkStream*, const SkPictInfo&, | 81 static SkPicturePlayback* CreateFromStream(SkStream*, |
| 82 const SkPictInfo&, | |
| 83 SkPicture::InstallPixelRefProc); | 83 SkPicture::InstallPixelRefProc); |
| 84 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&); | 84 static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&, const SkPictInfo&) ; |
| 85 | 85 |
| 86 virtual ~SkPicturePlayback(); | 86 virtual ~SkPicturePlayback(); |
| 87 | 87 |
| 88 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); | 88 const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect); |
| 89 | 89 |
| 90 void draw(SkCanvas& canvas, SkDrawPictureCallback*); | 90 void draw(SkCanvas& canvas, SkDrawPictureCallback*); |
| 91 | 91 |
| 92 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; | 92 void serialize(SkWStream*, SkPicture::EncodeBitmap) const; |
| 93 void flatten(SkWriteBuffer&) const; | 93 void flatten(SkWriteBuffer&) const; |
| 94 | 94 |
| 95 void dumpSize() const; | 95 void dumpSize() const; |
| 96 | 96 |
| 97 bool containsBitmaps() const; | 97 bool containsBitmaps() const; |
| 98 | 98 |
| 99 #ifdef SK_BUILD_FOR_ANDROID | 99 #ifdef SK_BUILD_FOR_ANDROID |
| 100 // 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 |
| 101 // 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 |
| 102 void abort() { fAbortCurrentPlayback = true; } | 102 void abort() { fAbortCurrentPlayback = true; } |
| 103 #endif | 103 #endif |
| 104 | 104 |
| 105 size_t curOpID() const { return fCurOffset; } | 105 size_t curOpID() const { return fCurOffset; } |
| 106 void resetOpID() { fCurOffset = 0; } | 106 void resetOpID() { fCurOffset = 0; } |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 bool parseStream(SkStream*, const SkPictInfo&, | 109 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); |
| 110 SkPicture::InstallPixelRefProc); | |
| 111 bool parseBuffer(SkReadBuffer& buffer); | 110 bool parseBuffer(SkReadBuffer& buffer); |
| 112 #ifdef SK_DEVELOPER | 111 #ifdef SK_DEVELOPER |
| 113 virtual bool preDraw(int opIndex, int type); | 112 virtual bool preDraw(int opIndex, int type); |
| 114 virtual void postDraw(int opIndex); | 113 virtual void postDraw(int opIndex); |
| 115 #endif | 114 #endif |
| 116 | 115 |
| 117 void preLoadBitmaps(const SkTDArray<void*>* results); | 116 void preLoadBitmaps(const SkTDArray<void*>* results); |
| 118 | 117 |
| 119 private: | 118 private: |
| 119 explicit SkPicturePlayback(const SkPictInfo& info); | |
| 120 | |
| 120 class TextContainer { | 121 class TextContainer { |
| 121 public: | 122 public: |
| 122 size_t length() { return fByteLength; } | 123 size_t length() { return fByteLength; } |
| 123 const void* text() { return (const void*) fText; } | 124 const void* text() { return (const void*) fText; } |
| 124 size_t fByteLength; | 125 size_t fByteLength; |
| 125 const char* fText; | 126 const char* fText; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 const SkBitmap& getBitmap(SkReader32& reader) { | 129 const SkBitmap& getBitmap(SkReader32& reader) { |
| 129 const int index = reader.readInt(); | 130 const int index = reader.readInt(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 int dumpRectPtr(char* bufferPtr, char* buffer, char* name); | 211 int dumpRectPtr(char* bufferPtr, char* buffer, char* name); |
| 211 int dumpScalar(char* bufferPtr, char* buffer, char* name); | 212 int dumpScalar(char* bufferPtr, char* buffer, char* name); |
| 212 void dumpText(char** bufferPtrPtr, char* buffer); | 213 void dumpText(char** bufferPtrPtr, char* buffer); |
| 213 void dumpStream(); | 214 void dumpStream(); |
| 214 | 215 |
| 215 public: | 216 public: |
| 216 void dump() const; | 217 void dump() const; |
| 217 #endif | 218 #endif |
| 218 | 219 |
| 219 private: // these help us with reading/writing | 220 private: // these help us with reading/writing |
| 220 bool parseStreamTag(SkStream*, const SkPictInfo&, uint32_t tag, size_t size, | 221 bool parseStreamTag(SkStream*, uint32_t tag, size_t size, SkPicture::Install PixelRefProc); |
| 221 SkPicture::InstallPixelRefProc); | |
| 222 bool parseBufferTag(SkReadBuffer&, uint32_t tag, size_t size); | 222 bool parseBufferTag(SkReadBuffer&, uint32_t tag, size_t size); |
| 223 void flattenToBuffer(SkWriteBuffer&) const; | 223 void flattenToBuffer(SkWriteBuffer&) const; |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty | 226 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty |
| 227 // bitmap allows playback to draw nothing and move on. | 227 // bitmap allows playback to draw nothing and move on. |
| 228 SkBitmap fBadBitmap; | 228 SkBitmap fBadBitmap; |
| 229 | 229 |
| 230 SkAutoTUnref<SkBitmapHeap> fBitmapHeap; | 230 SkAutoTUnref<SkBitmapHeap> fBitmapHeap; |
| 231 SkAutoTUnref<SkPathHeap> fPathHeap; | 231 SkAutoTUnref<SkPathHeap> fPathHeap; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 }; | 264 }; |
| 265 | 265 |
| 266 CachedOperationList* fCachedActiveOps; | 266 CachedOperationList* fCachedActiveOps; |
| 267 | 267 |
| 268 SkTypefacePlayback fTFPlayback; | 268 SkTypefacePlayback fTFPlayback; |
| 269 SkFactoryPlayback* fFactoryPlayback; | 269 SkFactoryPlayback* fFactoryPlayback; |
| 270 | 270 |
| 271 // The offset of the current operation when within the draw method | 271 // The offset of the current operation when within the draw method |
| 272 size_t fCurOffset; | 272 size_t fCurOffset; |
| 273 | 273 |
| 274 SkPictInfo fInfo; | |
|
reed1
2014/03/27 20:58:14
can this guy be const?
mtklein
2014/03/27 21:02:48
Yep, done.
| |
| 275 | |
| 274 #ifdef SK_BUILD_FOR_ANDROID | 276 #ifdef SK_BUILD_FOR_ANDROID |
| 275 SkMutex fDrawMutex; | 277 SkMutex fDrawMutex; |
| 276 bool fAbortCurrentPlayback; | 278 bool fAbortCurrentPlayback; |
| 277 #endif | 279 #endif |
| 278 }; | 280 }; |
| 279 | 281 |
| 280 #endif | 282 #endif |
| OLD | NEW |