Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: include/core/SkPicture.h

Issue 748803005: SkPicture::SnapshotArray doesn't really stand to benefit from refcounting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkPicture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 * number may be greater or less than the number of SkCanvas calls 192 * 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 193 * recorded: some calls may be recorded as more than one operation, or some
194 * calls may be optimized away. 194 * calls may be optimized away.
195 */ 195 */
196 int approximateOpCount() const; 196 int approximateOpCount() const;
197 197
198 /** Return true if this picture contains text. 198 /** Return true if this picture contains text.
199 */ 199 */
200 bool hasText() const; 200 bool hasText() const;
201 201
202 // A refcounted array of refcounted const SkPicture pointers. 202 // An array of refcounted const SkPicture pointers.
203 struct SnapshotArray : public SkNVRefCnt<SnapshotArray> { 203 class SnapshotArray : ::SkNoncopyable {
204 public:
204 SnapshotArray(const SkPicture* pics[], size_t count) : fPics(pics), fCou nt(count) {} 205 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 (); } } 206 ~SnapshotArray() { for (size_t i = 0; i < fCount; i++) { fPics[i]->unref (); } }
206 207
207 const SkPicture* const* begin() const { return fPics; } 208 const SkPicture* const* begin() const { return fPics; }
208 size_t count() const { return fCount; } 209 size_t count() const { return fCount; }
209 private: 210 private:
210 SkAutoTMalloc<const SkPicture*> fPics; 211 SkAutoTMalloc<const SkPicture*> fPics;
211 size_t fCount; 212 size_t fCount;
212 }; 213 };
213 214
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 // Only SKPs within the min/current picture version range (inclusive) can be read. 258 // Only SKPs within the min/current picture version range (inclusive) can be read.
258 static const uint32_t MIN_PICTURE_VERSION = 19; 259 static const uint32_t MIN_PICTURE_VERSION = 19;
259 static const uint32_t CURRENT_PICTURE_VERSION = 37; 260 static const uint32_t CURRENT_PICTURE_VERSION = 37;
260 261
261 void callDeletionListeners(); 262 void callDeletionListeners();
262 263
263 void createHeader(SkPictInfo* info) const; 264 void createHeader(SkPictInfo* info) const;
264 static bool IsValidPictInfo(const SkPictInfo& info); 265 static bool IsValidPictInfo(const SkPictInfo& info);
265 266
266 // Takes ownership of the SkRecord, refs the (optional) SnapshotArray and BB H. 267 // Takes ownership of the SkRecord and (optional) SnapshotArray, refs the (o ptional) BBH.
267 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy *); 268 SkPicture(const SkRect& cullRect, SkRecord*, SnapshotArray*, SkBBoxHierarchy *);
268 269
269 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); 270 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*);
270 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, 271 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&,
271 SkPicture const* const drawablePics[], int dr awableCount); 272 SkPicture const* const drawablePics[], int dr awableCount);
272 273
273 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> 274 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture>
274 const uint32_t fUniqueID; 275 const uint32_t fUniqueID;
275 const SkRect fCullRect; 276 const SkRect fCullRect;
276 mutable SkAutoTUnref<const AccelData> fAccelData; 277 mutable SkAutoTUnref<const AccelData> fAccelData;
277 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed 278 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed
278 SkAutoTDelete<const SkRecord> fRecord; 279 SkAutoTDelete<const SkRecord> fRecord;
279 SkAutoTUnref<const SkBBoxHierarchy> fBBH; 280 SkAutoTUnref<const SkBBoxHierarchy> fBBH;
280 SkAutoTUnref<const SnapshotArray> fDrawablePicts; 281 SkAutoTDelete<const SnapshotArray> fDrawablePicts;
281 282
282 // helpers for fDrawablePicts 283 // helpers for fDrawablePicts
283 int drawableCount() const; 284 int drawableCount() const;
284 // will return NULL if drawableCount() returns 0 285 // will return NULL if drawableCount() returns 0
285 SkPicture const* const* drawablePicts() const; 286 SkPicture const* const* drawablePicts() const;
286 287
287 struct PathCounter; 288 struct PathCounter;
288 289
289 struct Analysis { 290 struct Analysis {
290 Analysis() {} // Only used by SkPictureData codepath. 291 Analysis() {} // Only used by SkPictureData codepath.
(...skipping 11 matching lines...) Expand all
302 } fAnalysis; 303 } fAnalysis;
303 304
304 friend class SkPictureRecorder; // SkRecord-based constructor. 305 friend class SkPictureRecorder; // SkRecord-based constructor.
305 friend class GrLayerHoister; // access to fRecord 306 friend class GrLayerHoister; // access to fRecord
306 friend class ReplaceDraw; 307 friend class ReplaceDraw;
307 friend class SkPictureUtils; 308 friend class SkPictureUtils;
308 }; 309 };
309 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); 310 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize);
310 311
311 #endif 312 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698