| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 SkImage_Base_DEFINED | 8 #ifndef SkImage_Base_DEFINED |
| 9 #define SkImage_Base_DEFINED | 9 #define SkImage_Base_DEFINED |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const =
0; | 48 virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const =
0; |
| 49 | 49 |
| 50 virtual SkImage* onNewSubset(const SkIRect&) const = 0; | 50 virtual SkImage* onNewSubset(const SkIRect&) const = 0; |
| 51 | 51 |
| 52 virtual SkData* onRefEncoded() const { return nullptr; } | 52 virtual SkData* onRefEncoded() const { return nullptr; } |
| 53 | 53 |
| 54 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; | 54 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; |
| 55 | 55 |
| 56 virtual bool onIsLazyGenerated() const { return false; } | 56 virtual bool onIsLazyGenerated() const { return false; } |
| 57 | 57 |
| 58 // Return a bitmap suitable for passing to image-filters |
| 59 // For now, that means wrapping textures into SkGrPixelRefs... |
| 60 virtual bool asBitmapForImageFilters(SkBitmap* bitmap) const { |
| 61 return this->getROPixels(bitmap, kAllow_CachingHint); |
| 62 } |
| 63 |
| 58 // Call when this image is part of the key to a resourcecache entry. This al
lows the cache | 64 // Call when this image is part of the key to a resourcecache entry. This al
lows the cache |
| 59 // to know automatically those entries can be purged when this SkImage delet
ed. | 65 // to know automatically those entries can be purged when this SkImage delet
ed. |
| 60 void notifyAddedToCache() const { | 66 void notifyAddedToCache() const { |
| 61 fAddedToCache.store(true); | 67 fAddedToCache.store(true); |
| 62 } | 68 } |
| 63 | 69 |
| 64 private: | 70 private: |
| 65 // Set true by caches when they cache content that's derived from the curren
t pixels. | 71 // Set true by caches when they cache content that's derived from the curren
t pixels. |
| 66 mutable SkAtomic<bool> fAddedToCache; | 72 mutable SkAtomic<bool> fAddedToCache; |
| 67 | 73 |
| 68 typedef SkImage INHERITED; | 74 typedef SkImage INHERITED; |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 static inline SkImage_Base* as_IB(SkImage* image) { | 77 static inline SkImage_Base* as_IB(SkImage* image) { |
| 72 return static_cast<SkImage_Base*>(image); | 78 return static_cast<SkImage_Base*>(image); |
| 73 } | 79 } |
| 74 | 80 |
| 75 static inline const SkImage_Base* as_IB(const SkImage* image) { | 81 static inline const SkImage_Base* as_IB(const SkImage* image) { |
| 76 return static_cast<const SkImage_Base*>(image); | 82 return static_cast<const SkImage_Base*>(image); |
| 77 } | 83 } |
| 78 | 84 |
| 79 #endif | 85 #endif |
| OLD | NEW |