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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0; | 55 virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0; |
56 | 56 |
57 // If a ctx is specified, then only gpu-specific formats are requested. | 57 // If a ctx is specified, then only gpu-specific formats are requested. |
58 virtual SkData* onRefEncoded(GrContext*) const { return nullptr; } | 58 virtual SkData* onRefEncoded(GrContext*) const { return nullptr; } |
59 | 59 |
60 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; | 60 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; |
61 | 61 |
62 virtual bool onIsLazyGenerated() const { return false; } | 62 virtual bool onIsLazyGenerated() const { return false; } |
63 | 63 |
64 // Return a bitmap suitable for passing to image-filters | |
65 // For now, that means wrapping textures into SkGrPixelRefs... | |
66 virtual bool asBitmapForImageFilters(SkBitmap* bitmap) const { | |
67 return this->getROPixels(bitmap, kAllow_CachingHint); | |
68 } | |
69 | |
70 // 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 |
71 // 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. |
72 void notifyAddedToCache() const { | 66 void notifyAddedToCache() const { |
73 fAddedToCache.store(true); | 67 fAddedToCache.store(true); |
74 } | 68 } |
75 | 69 |
76 private: | 70 private: |
77 // 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. |
78 mutable SkAtomic<bool> fAddedToCache; | 72 mutable SkAtomic<bool> fAddedToCache; |
79 | 73 |
80 typedef SkImage INHERITED; | 74 typedef SkImage INHERITED; |
81 }; | 75 }; |
82 | 76 |
83 static inline SkImage_Base* as_IB(SkImage* image) { | 77 static inline SkImage_Base* as_IB(SkImage* image) { |
84 return static_cast<SkImage_Base*>(image); | 78 return static_cast<SkImage_Base*>(image); |
85 } | 79 } |
86 | 80 |
87 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) { | 81 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) { |
88 return static_cast<SkImage_Base*>(image.get()); | 82 return static_cast<SkImage_Base*>(image.get()); |
89 } | 83 } |
90 | 84 |
91 static inline const SkImage_Base* as_IB(const SkImage* image) { | 85 static inline const SkImage_Base* as_IB(const SkImage* image) { |
92 return static_cast<const SkImage_Base*>(image); | 86 return static_cast<const SkImage_Base*>(image); |
93 } | 87 } |
94 | 88 |
95 #endif | 89 #endif |
OLD | NEW |