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 "GrTexture.h" | |
12 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
13 #include "SkImage.h" | 12 #include "SkImage.h" |
14 #include "SkSurface.h" | 13 #include "SkSurface.h" |
15 | 14 |
| 15 #if SK_SUPPORT_GPU |
| 16 #include "GrTexture.h" |
| 17 #endif |
| 18 |
16 #include <new> | 19 #include <new> |
17 | 20 |
18 class GrTextureParams; | 21 class GrTextureParams; |
19 class SkImageCacherator; | 22 class SkImageCacherator; |
20 | 23 |
21 enum { | 24 enum { |
22 kNeedNewImageUniqueID = 0 | 25 kNeedNewImageUniqueID = 0 |
23 }; | 26 }; |
24 | 27 |
25 class SkImage_Base : public SkImage { | 28 class SkImage_Base : public SkImage { |
26 public: | 29 public: |
27 SkImage_Base(int width, int height, uint32_t uniqueID); | 30 SkImage_Base(int width, int height, uint32_t uniqueID); |
28 virtual ~SkImage_Base(); | 31 virtual ~SkImage_Base(); |
29 | 32 |
30 // User: returns image info for this SkImage. | 33 // User: returns image info for this SkImage. |
31 // Implementors: if you can not return the value, return an invalid ImageInf
o with w=0 & h=0 | 34 // Implementors: if you can not return the value, return an invalid ImageInf
o with w=0 & h=0 |
32 // & unknown color space. | 35 // & unknown color space. |
33 virtual SkImageInfo onImageInfo() const = 0; | 36 virtual SkImageInfo onImageInfo() const = 0; |
34 | 37 |
35 virtual bool onPeekPixels(SkPixmap*) const { return false; } | 38 virtual bool onPeekPixels(SkPixmap*) const { return false; } |
36 | 39 |
37 virtual const SkBitmap* onPeekBitmap() const { return nullptr; } | 40 virtual const SkBitmap* onPeekBitmap() const { return nullptr; } |
38 | 41 |
39 // Default impl calls onDraw | 42 // Default impl calls onDraw |
40 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, | 43 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, |
41 int srcX, int srcY, CachingHint) const; | 44 int srcX, int srcY, CachingHint) const; |
42 | 45 |
43 virtual GrTexture* peekTexture() const { return nullptr; } | 46 virtual GrTexture* peekTexture() const { return nullptr; } |
| 47 #if SK_SUPPORT_GPU |
44 virtual sk_sp<GrTexture> refPinnedTexture(uint32_t* uniqueID) const { return
nullptr; } | 48 virtual sk_sp<GrTexture> refPinnedTexture(uint32_t* uniqueID) const { return
nullptr; } |
| 49 #endif |
45 virtual SkImageCacherator* peekCacherator() const { return nullptr; } | 50 virtual SkImageCacherator* peekCacherator() const { return nullptr; } |
46 | 51 |
47 // return a read-only copy of the pixels. We promise to not modify them, | 52 // return a read-only copy of the pixels. We promise to not modify them, |
48 // but only inspect them (or encode them). | 53 // but only inspect them (or encode them). |
49 virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const
= 0; | 54 virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const
= 0; |
50 | 55 |
51 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const { | 56 virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const { |
52 return SkSurface::MakeRaster(info); | 57 return SkSurface::MakeRaster(info); |
53 } | 58 } |
54 | 59 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 92 |
88 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) { | 93 static inline SkImage_Base* as_IB(const sk_sp<SkImage>& image) { |
89 return static_cast<SkImage_Base*>(image.get()); | 94 return static_cast<SkImage_Base*>(image.get()); |
90 } | 95 } |
91 | 96 |
92 static inline const SkImage_Base* as_IB(const SkImage* image) { | 97 static inline const SkImage_Base* as_IB(const SkImage* image) { |
93 return static_cast<const SkImage_Base*>(image); | 98 return static_cast<const SkImage_Base*>(image); |
94 } | 99 } |
95 | 100 |
96 #endif | 101 #endif |
OLD | NEW |