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

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

Issue 408923002: Add auto purging for SkPicture-related Ganesh resources (esp. layers) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 6 years, 5 months 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 | « include/core/SkDevice.h ('k') | include/gpu/SkGpuDevice.h » ('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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); 183 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
184 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*); 184 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*);
185 185
186 /** Return true if the picture is suitable for rendering on the GPU. 186 /** Return true if the picture is suitable for rendering on the GPU.
187 */ 187 */
188 188
189 #if SK_SUPPORT_GPU 189 #if SK_SUPPORT_GPU
190 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; 190 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const;
191 #endif 191 #endif
192 192
193 class DeletionListener : public SkRefCnt {
194 public:
195 virtual void onDeletion(uint32_t pictureID) = 0;
196 };
197
198 // Takes ref on listener.
199 void addDeletionListener(DeletionListener* listener) const;
200
193 private: 201 private:
194 // V2 : adds SkPixelRef's generation ID. 202 // V2 : adds SkPixelRef's generation ID.
195 // V3 : PictInfo tag at beginning, and EOF tag at the end 203 // V3 : PictInfo tag at beginning, and EOF tag at the end
196 // V4 : move SkPictInfo to be the header 204 // V4 : move SkPictInfo to be the header
197 // V5 : don't read/write FunctionPtr on cross-process (we can detect that) 205 // V5 : don't read/write FunctionPtr on cross-process (we can detect that)
198 // V6 : added serialization of SkPath's bounds (and packed its flags tighter ) 206 // V6 : added serialization of SkPath's bounds (and packed its flags tighter )
199 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect) 207 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect)
200 // V8 : Add an option for encoding bitmaps 208 // V8 : Add an option for encoding bitmaps
201 // V9 : Allow the reader and writer of an SKP disagree on whether to support 209 // V9 : Allow the reader and writer of an SKP disagree on whether to support
202 // SK_SUPPORT_HINTING_SCALE_FACTOR 210 // SK_SUPPORT_HINTING_SCALE_FACTOR
(...skipping 27 matching lines...) Expand all
230 static const uint32_t MIN_PICTURE_VERSION = 19; 238 static const uint32_t MIN_PICTURE_VERSION = 19;
231 static const uint32_t CURRENT_PICTURE_VERSION = 30; 239 static const uint32_t CURRENT_PICTURE_VERSION = 30;
232 240
233 mutable uint32_t fUniqueID; 241 mutable uint32_t fUniqueID;
234 242
235 // TODO: make SkPictureData const when clone method goes away 243 // TODO: make SkPictureData const when clone method goes away
236 SkAutoTDelete<SkPictureData> fData; 244 SkAutoTDelete<SkPictureData> fData;
237 int fWidth, fHeight; 245 int fWidth, fHeight;
238 mutable SkAutoTUnref<const AccelData> fAccelData; 246 mutable SkAutoTUnref<const AccelData> fAccelData;
239 247
248 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed
249
240 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } 250 void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
251 void callDeletionListeners();
241 252
242 // Create a new SkPicture from an existing SkPictureData. The new picture 253 // Create a new SkPicture from an existing SkPictureData. The new picture
243 // takes ownership of 'data'. 254 // takes ownership of 'data'.
244 SkPicture(SkPictureData* data, int width, int height); 255 SkPicture(SkPictureData* data, int width, int height);
245 256
246 SkPicture(int width, int height, const SkPictureRecord& record, bool deepCop yOps); 257 SkPicture(int width, int height, const SkPictureRecord& record, bool deepCop yOps);
247 258
248 // An OperationList encapsulates a set of operation offsets into the picture byte 259 // An OperationList encapsulates a set of operation offsets into the picture byte
249 // stream along with the CTMs needed for those operation. 260 // stream along with the CTMs needed for those operation.
250 class OperationList : ::SkNoncopyable { 261 class OperationList : ::SkNoncopyable {
(...skipping 25 matching lines...) Expand all
276 friend class SkPictureReplacementPlayback; // to access OperationList 287 friend class SkPictureReplacementPlayback; // to access OperationList
277 288
278 typedef SkRefCnt INHERITED; 289 typedef SkRefCnt INHERITED;
279 290
280 SkPicture(int width, int height, SkRecord*); // Takes ownership. 291 SkPicture(int width, int height, SkRecord*); // Takes ownership.
281 SkAutoTDelete<SkRecord> fRecord; 292 SkAutoTDelete<SkRecord> fRecord;
282 bool fRecordWillPlayBackBitmaps; // TODO: const 293 bool fRecordWillPlayBackBitmaps; // TODO: const
283 }; 294 };
284 295
285 #endif 296 #endif
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | include/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698