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

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

Issue 1305453007: SkImage method for detecting lazy decoding (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 4 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/SkImage.h ('k') | src/image/SkImage.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 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPixelRef_DEFINED 8 #ifndef SkPixelRef_DEFINED
9 #define SkPixelRef_DEFINED 9 #define SkPixelRef_DEFINED
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void addGenIDChangeListener(GenIDChangeListener* listener); 258 void addGenIDChangeListener(GenIDChangeListener* listener);
259 259
260 // Call when this pixelref is part of the key to a resourcecache entry. This allows the cache 260 // Call when this pixelref is part of the key to a resourcecache entry. This allows the cache
261 // to know automatically those entries can be purged when this pixelref is c hanged or deleted. 261 // to know automatically those entries can be purged when this pixelref is c hanged or deleted.
262 void notifyAddedToCache() { 262 void notifyAddedToCache() {
263 fAddedToCache.store(true); 263 fAddedToCache.store(true);
264 } 264 }
265 265
266 virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return NULL; } 266 virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return NULL; }
267 267
268 /**
269 * Returns true if the pixels are generated on-the-fly (when required).
270 */
271 bool isLazyGenerated() const { return this->onIsLazyGenerated(); }
272
268 protected: 273 protected:
269 /** 274 /**
270 * On success, returns true and fills out the LockRec for the pixels. On 275 * On success, returns true and fills out the LockRec for the pixels. On
271 * failure returns false and ignores the LockRec parameter. 276 * failure returns false and ignores the LockRec parameter.
272 * 277 *
273 * The caller will have already acquired a mutex for thread safety, so this 278 * The caller will have already acquired a mutex for thread safety, so this
274 * method need not do that. 279 * method need not do that.
275 */ 280 */
276 virtual bool onNewLockPixels(LockRec*) = 0; 281 virtual bool onNewLockPixels(LockRec*) = 0;
277 282
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 * This should be implemented in all serializable SkPixelRef derived classe s. 316 * This should be implemented in all serializable SkPixelRef derived classe s.
312 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo w this value, 317 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo w this value,
313 * otherwise the rendering code may attempt to read memory out of bounds. 318 * otherwise the rendering code may attempt to read memory out of bounds.
314 * 319 *
315 * @return default impl returns 0. 320 * @return default impl returns 0.
316 */ 321 */
317 virtual size_t getAllocatedSizeInBytes() const; 322 virtual size_t getAllocatedSizeInBytes() const;
318 323
319 virtual bool onRequestLock(const LockRequest&, LockResult*); 324 virtual bool onRequestLock(const LockRequest&, LockResult*);
320 325
326 virtual bool onIsLazyGenerated() const { return false; }
327
321 /** Return the mutex associated with this pixelref. This value is assigned 328 /** Return the mutex associated with this pixelref. This value is assigned
322 in the constructor, and cannot change during the lifetime of the object. 329 in the constructor, and cannot change during the lifetime of the object.
323 */ 330 */
324 SkBaseMutex* mutex() const { return &fMutex; } 331 SkBaseMutex* mutex() const { return &fMutex; }
325 332
326 // only call from constructor. Flags this to always be locked, removing 333 // only call from constructor. Flags this to always be locked, removing
327 // the need to grab the mutex and call onLockPixels/onUnlockPixels. 334 // the need to grab the mutex and call onLockPixels/onUnlockPixels.
328 // Performance tweak to avoid those calls (esp. in multi-thread use case). 335 // Performance tweak to avoid those calls (esp. in multi-thread use case).
329 void setPreLocked(void*, size_t rowBytes, SkColorTable*); 336 void setPreLocked(void*, size_t rowBytes, SkColorTable*);
330 337
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 /** 398 /**
392 * Allocate a new pixelref matching the specified ImageInfo, allocating 399 * Allocate a new pixelref matching the specified ImageInfo, allocating
393 * the memory for the pixels. If the ImageInfo requires a ColorTable, 400 * the memory for the pixels. If the ImageInfo requires a ColorTable,
394 * the pixelref will ref() the colortable. 401 * the pixelref will ref() the colortable.
395 * On failure return NULL. 402 * On failure return NULL.
396 */ 403 */
397 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0; 404 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0;
398 }; 405 };
399 406
400 #endif 407 #endif
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698