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 |
11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
12 #include "SkImage.h" | 12 #include "SkImage.h" |
13 #include "SkSurface.h" | 13 #include "SkSurface.h" |
14 | 14 |
15 #include <new> | 15 #include <new> |
16 | 16 |
17 class GrTextureParams; | 17 class GrTextureParams; |
18 class SkImageCacherator; | 18 class SkImageCacherator; |
19 | 19 |
20 enum { | 20 enum { |
21 kNeedNewImageUniqueID = 0 | 21 kNeedNewImageUniqueID = 0 |
22 }; | 22 }; |
23 | 23 |
24 class SkImage_Base : public SkImage { | 24 class SkImage_Base : public SkImage { |
25 public: | 25 public: |
26 SkImage_Base(int width, int height, uint32_t uniqueID); | 26 SkImage_Base(int width, int height, uint32_t uniqueID); |
27 virtual ~SkImage_Base(); | 27 virtual ~SkImage_Base(); |
28 | 28 |
29 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const {
return nullptr; } | 29 virtual bool onPeekPixels(SkPixmap*) const { return false; } |
30 | 30 |
31 // Default impl calls onDraw | 31 // Default impl calls onDraw |
32 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, | 32 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, |
33 int srcX, int srcY, CachingHint) const; | 33 int srcX, int srcY, CachingHint) const; |
34 | 34 |
35 virtual GrTexture* peekTexture() const { return nullptr; } | 35 virtual GrTexture* peekTexture() const { return nullptr; } |
36 virtual SkImageCacherator* peekCacherator() const { return nullptr; } | 36 virtual SkImageCacherator* peekCacherator() const { return nullptr; } |
37 | 37 |
38 // return a read-only copy of the pixels. We promise to not modify them, | 38 // return a read-only copy of the pixels. We promise to not modify them, |
39 // but only inspect them (or encode them). | 39 // but only inspect them (or encode them). |
(...skipping 27 matching lines...) Expand all Loading... |
67 fAddedToCache.store(true); | 67 fAddedToCache.store(true); |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 // 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. |
72 mutable SkAtomic<bool> fAddedToCache; | 72 mutable SkAtomic<bool> fAddedToCache; |
73 | 73 |
74 typedef SkImage INHERITED; | 74 typedef SkImage INHERITED; |
75 }; | 75 }; |
76 | 76 |
77 static inline SkImage_Base* as_IB(SkImage* image) { | 77 static inline SkImage_Base* as_IB(SkImage* image) { |
78 return static_cast<SkImage_Base*>(image); | 78 return static_cast<SkImage_Base*>(image); |
79 } | 79 } |
80 | 80 |
81 static inline const SkImage_Base* as_IB(const SkImage* image) { | 81 static inline const SkImage_Base* as_IB(const SkImage* image) { |
82 return static_cast<const SkImage_Base*>(image); | 82 return static_cast<const SkImage_Base*>(image); |
83 } | 83 } |
84 | 84 |
85 #endif | 85 #endif |
OLD | NEW |