OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
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 | 9 |
10 #ifndef SkPicture_DEFINED | 10 #ifndef SkPicture_DEFINED |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); | 173 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); |
174 static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*); | 174 static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*); |
175 | 175 |
176 /** Return true if the picture is suitable for rendering on the GPU. | 176 /** Return true if the picture is suitable for rendering on the GPU. |
177 */ | 177 */ |
178 | 178 |
179 #if SK_SUPPORT_GPU | 179 #if SK_SUPPORT_GPU |
180 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; | 180 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; |
181 #endif | 181 #endif |
182 | 182 |
183 class DeletionListener : public SkRefCnt { | |
184 public: | |
185 virtual void onDeletion(uint32_t pictureID) = 0; | |
186 }; | |
187 | |
188 // Takes ref on listener. | |
189 void addDeletionListener(DeletionListener* listener) const; | |
190 | |
191 /** Return the approximate number of operations in this picture. This | 183 /** Return the approximate number of operations in this picture. This |
192 * number may be greater or less than the number of SkCanvas calls | 184 * number may be greater or less than the number of SkCanvas calls |
193 * recorded: some calls may be recorded as more than one operation, or some | 185 * recorded: some calls may be recorded as more than one operation, or some |
194 * calls may be optimized away. | 186 * calls may be optimized away. |
195 */ | 187 */ |
196 int approximateOpCount() const; | 188 int approximateOpCount() const; |
197 | 189 |
198 /** Return true if this picture contains text. | 190 /** Return true if this picture contains text. |
199 */ | 191 */ |
200 bool hasText() const; | 192 bool hasText() const; |
201 | 193 |
202 // An array of refcounted const SkPicture pointers. | 194 // An array of refcounted const SkPicture pointers. |
203 class SnapshotArray : ::SkNoncopyable { | 195 class SnapshotArray : ::SkNoncopyable { |
204 public: | 196 public: |
205 SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(
count) {} | 197 SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(
count) {} |
206 ~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref();
} } | 198 ~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref();
} } |
207 | 199 |
208 const SkPicture* const* begin() const { return fPics; } | 200 const SkPicture* const* begin() const { return fPics; } |
209 int count() const { return fCount; } | 201 int count() const { return fCount; } |
210 private: | 202 private: |
211 SkAutoTMalloc<const SkPicture*> fPics; | 203 SkAutoTMalloc<const SkPicture*> fPics; |
212 int fCount; | 204 int fCount; |
213 }; | 205 }; |
214 | 206 |
| 207 // Sent via SkMessageBus from destructor. |
| 208 struct DeletionMessage { int32_t fUniqueID; }; |
| 209 |
215 private: | 210 private: |
216 // V2 : adds SkPixelRef's generation ID. | 211 // V2 : adds SkPixelRef's generation ID. |
217 // V3 : PictInfo tag at beginning, and EOF tag at the end | 212 // V3 : PictInfo tag at beginning, and EOF tag at the end |
218 // V4 : move SkPictInfo to be the header | 213 // V4 : move SkPictInfo to be the header |
219 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) | 214 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) |
220 // V6 : added serialization of SkPath's bounds (and packed its flags tighter
) | 215 // V6 : added serialization of SkPath's bounds (and packed its flags tighter
) |
221 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) | 216 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) |
222 // V8 : Add an option for encoding bitmaps | 217 // V8 : Add an option for encoding bitmaps |
223 // V9 : Allow the reader and writer of an SKP disagree on whether to support | 218 // V9 : Allow the reader and writer of an SKP disagree on whether to support |
224 // SK_SUPPORT_HINTING_SCALE_FACTOR | 219 // SK_SUPPORT_HINTING_SCALE_FACTOR |
(...skipping 27 matching lines...) Expand all Loading... |
252 // V36: Remove (obsolete) alphatype from SkColorTable | 247 // V36: Remove (obsolete) alphatype from SkColorTable |
253 // V37: Added shadow only option to SkDropShadowImageFilter | 248 // V37: Added shadow only option to SkDropShadowImageFilter |
254 | 249 |
255 // Note: If the picture version needs to be increased then please follow the | 250 // Note: If the picture version needs to be increased then please follow the |
256 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g
l/qATVcw | 251 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g
l/qATVcw |
257 | 252 |
258 // Only SKPs within the min/current picture version range (inclusive) can be
read. | 253 // Only SKPs within the min/current picture version range (inclusive) can be
read. |
259 static const uint32_t MIN_PICTURE_VERSION = 19; | 254 static const uint32_t MIN_PICTURE_VERSION = 19; |
260 static const uint32_t CURRENT_PICTURE_VERSION = 37; | 255 static const uint32_t CURRENT_PICTURE_VERSION = 37; |
261 | 256 |
262 void callDeletionListeners(); | |
263 | |
264 void createHeader(SkPictInfo* info) const; | 257 void createHeader(SkPictInfo* info) const; |
265 static bool IsValidPictInfo(const SkPictInfo& info); | 258 static bool IsValidPictInfo(const SkPictInfo& info); |
266 | 259 |
267 // Takes ownership of the SkRecord and (optional) SnapshotArray, refs the (o
ptional) BBH. | 260 // Takes ownership of the SkRecord and (optional) SnapshotArray, refs the (o
ptional) BBH. |
268 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy
*); | 261 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy
*); |
269 | 262 |
270 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 263 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
271 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, | 264 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
272 SkPicture const* const drawablePics[], int dr
awableCount); | 265 SkPicture const* const drawablePics[], int dr
awableCount); |
273 | 266 |
274 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> | 267 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
275 const uint32_t fUniqueID; | 268 const uint32_t fUniqueID; |
276 const SkRect fCullRect; | 269 const SkRect fCullRect; |
277 mutable SkAutoTUnref<const AccelData> fAccelData; | 270 mutable SkAutoTUnref<const AccelData> fAccelData; |
278 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re
fed | |
279 SkAutoTDelete<const SkRecord> fRecord; | 271 SkAutoTDelete<const SkRecord> fRecord; |
280 SkAutoTUnref<const SkBBoxHierarchy> fBBH; | 272 SkAutoTUnref<const SkBBoxHierarchy> fBBH; |
281 SkAutoTDelete<const SnapshotArray> fDrawablePicts; | 273 SkAutoTDelete<const SnapshotArray> fDrawablePicts; |
282 | 274 |
283 // helpers for fDrawablePicts | 275 // helpers for fDrawablePicts |
284 int drawableCount() const; | 276 int drawableCount() const; |
285 // will return NULL if drawableCount() returns 0 | 277 // will return NULL if drawableCount() returns 0 |
286 SkPicture const* const* drawablePicts() const; | 278 SkPicture const* const* drawablePicts() const; |
287 | 279 |
288 struct PathCounter; | 280 struct PathCounter; |
(...skipping 14 matching lines...) Expand all Loading... |
303 } fAnalysis; | 295 } fAnalysis; |
304 | 296 |
305 friend class SkPictureRecorder; // SkRecord-based constructor. | 297 friend class SkPictureRecorder; // SkRecord-based constructor. |
306 friend class GrLayerHoister; // access to fRecord | 298 friend class GrLayerHoister; // access to fRecord |
307 friend class ReplaceDraw; | 299 friend class ReplaceDraw; |
308 friend class SkPictureUtils; | 300 friend class SkPictureUtils; |
309 }; | 301 }; |
310 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); | 302 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
311 | 303 |
312 #endif | 304 #endif |
OLD | NEW |