Chromium Code Reviews| 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 // A refcounted array of refcounted const SkPicture pointers. | 194 // A refcounted array of refcounted const SkPicture pointers. |
| 203 struct SnapshotArray : public SkNVRefCnt<SnapshotArray> { | 195 struct SnapshotArray : public SkNVRefCnt<SnapshotArray> { |
| 204 SnapshotArray(const SkPicture* pics[], size_t count) : fPics(pics), fCou nt(count) {} | 196 SnapshotArray(const SkPicture* pics[], size_t count) : fPics(pics), fCou nt(count) {} |
| 205 ~SnapshotArray() { for (size_t i = 0; i < fCount; i++) { fPics[i]->unref (); } } | 197 ~SnapshotArray() { for (size_t i = 0; i < fCount; i++) { fPics[i]->unref (); } } |
| 206 | 198 |
| 207 const SkPicture* const* begin() const { return fPics; } | 199 const SkPicture* const* begin() const { return fPics; } |
| 208 size_t count() const { return fCount; } | 200 size_t count() const { return fCount; } |
| 209 private: | 201 private: |
| 210 SkAutoTMalloc<const SkPicture*> fPics; | 202 SkAutoTMalloc<const SkPicture*> fPics; |
| 211 size_t fCount; | 203 size_t fCount; |
| 212 }; | 204 }; |
| 213 | 205 |
| 206 // Sent via SkMessageBus from destructor. | |
|
robertphillips
2014/11/24 15:13:15
fUniqueID ?
mtklein
2014/11/24 16:05:05
Done, though I think this is probably a net negati
| |
| 207 struct DeletionMessage { int32_t uniqueID; }; | |
| 208 | |
| 214 private: | 209 private: |
| 215 // V2 : adds SkPixelRef's generation ID. | 210 // V2 : adds SkPixelRef's generation ID. |
| 216 // V3 : PictInfo tag at beginning, and EOF tag at the end | 211 // V3 : PictInfo tag at beginning, and EOF tag at the end |
| 217 // V4 : move SkPictInfo to be the header | 212 // V4 : move SkPictInfo to be the header |
| 218 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) | 213 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) |
| 219 // V6 : added serialization of SkPath's bounds (and packed its flags tighter ) | 214 // V6 : added serialization of SkPath's bounds (and packed its flags tighter ) |
| 220 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) | 215 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) |
| 221 // V8 : Add an option for encoding bitmaps | 216 // V8 : Add an option for encoding bitmaps |
| 222 // V9 : Allow the reader and writer of an SKP disagree on whether to support | 217 // V9 : Allow the reader and writer of an SKP disagree on whether to support |
| 223 // SK_SUPPORT_HINTING_SCALE_FACTOR | 218 // SK_SUPPORT_HINTING_SCALE_FACTOR |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 251 // V36: Remove (obsolete) alphatype from SkColorTable | 246 // V36: Remove (obsolete) alphatype from SkColorTable |
| 252 // V37: Added shadow only option to SkDropShadowImageFilter | 247 // V37: Added shadow only option to SkDropShadowImageFilter |
| 253 | 248 |
| 254 // Note: If the picture version needs to be increased then please follow the | 249 // Note: If the picture version needs to be increased then please follow the |
| 255 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw | 250 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw |
| 256 | 251 |
| 257 // Only SKPs within the min/current picture version range (inclusive) can be read. | 252 // Only SKPs within the min/current picture version range (inclusive) can be read. |
| 258 static const uint32_t MIN_PICTURE_VERSION = 19; | 253 static const uint32_t MIN_PICTURE_VERSION = 19; |
| 259 static const uint32_t CURRENT_PICTURE_VERSION = 37; | 254 static const uint32_t CURRENT_PICTURE_VERSION = 37; |
| 260 | 255 |
| 261 void callDeletionListeners(); | |
| 262 | |
| 263 void createHeader(SkPictInfo* info) const; | 256 void createHeader(SkPictInfo* info) const; |
| 264 static bool IsValidPictInfo(const SkPictInfo& info); | 257 static bool IsValidPictInfo(const SkPictInfo& info); |
| 265 | 258 |
| 266 // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BB H. | 259 // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BB H. |
| 267 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy *); | 260 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy *); |
| 268 | 261 |
| 269 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 262 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
| 270 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, | 263 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
| 271 SkPicture const* const drawablePics[], int dr awableCount); | 264 SkPicture const* const drawablePics[], int dr awableCount); |
| 272 | 265 |
| 273 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> | 266 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
| 274 const uint32_t fUniqueID; | 267 const uint32_t fUniqueID; |
| 275 const SkRect fCullRect; | 268 const SkRect fCullRect; |
| 276 mutable SkAutoTUnref<const AccelData> fAccelData; | 269 mutable SkAutoTUnref<const AccelData> fAccelData; |
| 277 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed | |
| 278 SkAutoTDelete<const SkRecord> fRecord; | 270 SkAutoTDelete<const SkRecord> fRecord; |
| 279 SkAutoTUnref<const SkBBoxHierarchy> fBBH; | 271 SkAutoTUnref<const SkBBoxHierarchy> fBBH; |
| 280 SkAutoTUnref<const SnapshotArray> fDrawablePicts; | 272 SkAutoTUnref<const SnapshotArray> fDrawablePicts; |
| 281 | 273 |
| 282 // helpers for fDrawablePicts | 274 // helpers for fDrawablePicts |
| 283 int drawableCount() const; | 275 int drawableCount() const; |
| 284 // will return NULL if drawableCount() returns 0 | 276 // will return NULL if drawableCount() returns 0 |
| 285 SkPicture const* const* drawablePicts() const; | 277 SkPicture const* const* drawablePicts() const; |
| 286 | 278 |
| 287 struct PathCounter; | 279 struct PathCounter; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 302 } fAnalysis; | 294 } fAnalysis; |
| 303 | 295 |
| 304 friend class SkPictureRecorder; // SkRecord-based constructor. | 296 friend class SkPictureRecorder; // SkRecord-based constructor. |
| 305 friend class GrLayerHoister; // access to fRecord | 297 friend class GrLayerHoister; // access to fRecord |
| 306 friend class ReplaceDraw; | 298 friend class ReplaceDraw; |
| 307 friend class SkPictureUtils; | 299 friend class SkPictureUtils; |
| 308 }; | 300 }; |
| 309 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); | 301 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
| 310 | 302 |
| 311 #endif | 303 #endif |
| OLD | NEW |