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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 * number may be greater or less than the number of SkCanvas calls | 195 * number may be greater or less than the number of SkCanvas calls |
196 * recorded: some calls may be recorded as more than one operation, or some | 196 * recorded: some calls may be recorded as more than one operation, or some |
197 * calls may be optimized away. | 197 * calls may be optimized away. |
198 */ | 198 */ |
199 int approximateOpCount() const; | 199 int approximateOpCount() const; |
200 | 200 |
201 /** Return true if this picture contains text. | 201 /** Return true if this picture contains text. |
202 */ | 202 */ |
203 bool hasText() const; | 203 bool hasText() const; |
204 | 204 |
205 // A refcounted array of refcounted const SkPicture pointers. | |
206 struct SnapshotArray : public SkNVRefCnt { | |
207 explicit SnapshotArray(size_t count) { fArray.setCount(count); } | |
208 ~SnapshotArray() { fArray.unrefAll(); } | |
209 | |
210 const SkPicture*& operator[](size_t i) { return fArray[i]; } | |
reed1
2014/11/20 20:36:47
this looks tricky, since it allows the receiver to
mtklein
2014/11/21 16:03:50
Went with set(). I don't think we can assert sing
| |
211 const SkPicture* operator[](size_t i) const { return fArray[i]; } | |
212 size_t count() const { return fArray.count(); } | |
213 const SkPicture* const* begin() const { return fArray.begin(); } | |
214 private: | |
215 SkTDArray<const SkPicture*> fArray; | |
216 }; | |
217 | |
205 private: | 218 private: |
206 // V2 : adds SkPixelRef's generation ID. | 219 // V2 : adds SkPixelRef's generation ID. |
207 // V3 : PictInfo tag at beginning, and EOF tag at the end | 220 // V3 : PictInfo tag at beginning, and EOF tag at the end |
208 // V4 : move SkPictInfo to be the header | 221 // V4 : move SkPictInfo to be the header |
209 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) | 222 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) |
210 // V6 : added serialization of SkPath's bounds (and packed its flags tighter ) | 223 // V6 : added serialization of SkPath's bounds (and packed its flags tighter ) |
211 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) | 224 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) |
212 // V8 : Add an option for encoding bitmaps | 225 // V8 : Add an option for encoding bitmaps |
213 // V9 : Allow the reader and writer of an SKP disagree on whether to support | 226 // V9 : Allow the reader and writer of an SKP disagree on whether to support |
214 // SK_SUPPORT_HINTING_SCALE_FACTOR | 227 // SK_SUPPORT_HINTING_SCALE_FACTOR |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 // Only SKPs within the min/current picture version range (inclusive) can be read. | 261 // Only SKPs within the min/current picture version range (inclusive) can be read. |
249 static const uint32_t MIN_PICTURE_VERSION = 19; | 262 static const uint32_t MIN_PICTURE_VERSION = 19; |
250 static const uint32_t CURRENT_PICTURE_VERSION = 37; | 263 static const uint32_t CURRENT_PICTURE_VERSION = 37; |
251 | 264 |
252 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } | 265 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } |
253 void callDeletionListeners(); | 266 void callDeletionListeners(); |
254 | 267 |
255 void createHeader(SkPictInfo* info) const; | 268 void createHeader(SkPictInfo* info) const; |
256 static bool IsValidPictInfo(const SkPictInfo& info); | 269 static bool IsValidPictInfo(const SkPictInfo& info); |
257 | 270 |
258 // Takes ownership of the SkRecord, refs the (optional) drawablePicts and BB H. | 271 // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BB H. |
259 SkPicture(const SkRect& cullRect, SkRecord*, SkData* drawablePicts, | 272 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy *); |
260 SkBBoxHierarchy*); | |
261 | 273 |
262 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 274 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
263 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, | 275 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
264 SkPicture const* const drawablePics[], int dr awableCount); | 276 SkPicture const* const drawablePics[], int dr awableCount); |
265 | 277 |
266 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> | 278 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
267 mutable uint32_t fUniqueID; | 279 mutable uint32_t fUniqueID; |
268 const SkRect fCullRect; | 280 const SkRect fCullRect; |
269 mutable SkAutoTUnref<const AccelData> fAccelData; | 281 mutable SkAutoTUnref<const AccelData> fAccelData; |
270 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed | 282 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed |
271 SkAutoTDelete<SkRecord> fRecord; | 283 SkAutoTDelete<SkRecord> fRecord; |
272 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 284 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
273 SkAutoTUnref<SkData> fDrawablePicts; | 285 SkAutoTUnref<SnapshotArray> fDrawablePicts; |
274 | 286 |
275 // helpers for fDrawablePicts | 287 // helpers for fDrawablePicts |
276 int drawableCount() const; | 288 int drawableCount() const; |
277 // will return NULL if drawableCount() returns 0 | 289 // will return NULL if drawableCount() returns 0 |
278 SkPicture const* const* drawablePicts() const; | 290 SkPicture const* const* drawablePicts() const; |
279 | 291 |
280 struct PathCounter; | 292 struct PathCounter; |
281 | 293 |
282 struct Analysis { | 294 struct Analysis { |
283 Analysis() {} // Only used by SkPictureData codepath. | 295 Analysis() {} // Only used by SkPictureData codepath. |
(...skipping 11 matching lines...) Expand all Loading... | |
295 } fAnalysis; | 307 } fAnalysis; |
296 | 308 |
297 friend class SkPictureRecorder; // SkRecord-based constructor. | 309 friend class SkPictureRecorder; // SkRecord-based constructor. |
298 friend class GrLayerHoister; // access to fRecord | 310 friend class GrLayerHoister; // access to fRecord |
299 friend class ReplaceDraw; | 311 friend class ReplaceDraw; |
300 friend class SkPictureUtils; | 312 friend class SkPictureUtils; |
301 }; | 313 }; |
302 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); | 314 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
303 | 315 |
304 #endif | 316 #endif |
OLD | NEW |