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; |
| 18 |
17 enum { | 19 enum { |
18 kNeedNewImageUniqueID = 0 | 20 kNeedNewImageUniqueID = 0 |
19 }; | 21 }; |
20 | 22 |
21 class SkImage_Base : public SkImage { | 23 class SkImage_Base : public SkImage { |
22 public: | 24 public: |
23 SkImage_Base(int width, int height, uint32_t uniqueID); | 25 SkImage_Base(int width, int height, uint32_t uniqueID); |
24 virtual ~SkImage_Base(); | 26 virtual ~SkImage_Base(); |
25 | 27 |
26 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const {
return nullptr; } | 28 virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const {
return nullptr; } |
27 | 29 |
28 // Default impl calls onDraw | 30 // Default impl calls onDraw |
29 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, | 31 virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRowBytes, |
30 int srcX, int srcY) const; | 32 int srcX, int srcY) const; |
31 | 33 |
32 virtual GrTexture* peekTexture() const { return nullptr; } | 34 virtual GrTexture* peekTexture() const { return nullptr; } |
33 | 35 |
34 // return a read-only copy of the pixels. We promise to not modify them, | 36 // return a read-only copy of the pixels. We promise to not modify them, |
35 // but only inspect them (or encode them). | 37 // but only inspect them (or encode them). |
36 virtual bool getROPixels(SkBitmap*) const = 0; | 38 virtual bool getROPixels(SkBitmap*) const = 0; |
37 | 39 |
38 // Caller must call unref when they are done. | 40 // Caller must call unref when they are done. |
39 virtual GrTexture* asTextureRef(GrContext*, SkImageUsageType) const = 0; | 41 virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const =
0; |
40 | 42 |
41 virtual SkImage* onNewSubset(const SkIRect&) const = 0; | 43 virtual SkImage* onNewSubset(const SkIRect&) const = 0; |
42 | 44 |
43 virtual SkData* onRefEncoded() const { return nullptr; } | 45 virtual SkData* onRefEncoded() const { return nullptr; } |
44 | 46 |
45 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; | 47 virtual bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const; |
46 | 48 |
47 virtual bool onIsLazyGenerated() const { return false; } | 49 virtual bool onIsLazyGenerated() const { return false; } |
48 | 50 |
49 // Call when this image is part of the key to a resourcecache entry. This al
lows the cache | 51 // Call when this image is part of the key to a resourcecache entry. This al
lows the cache |
(...skipping 11 matching lines...) Expand all Loading... |
61 | 63 |
62 static inline SkImage_Base* as_IB(SkImage* image) { | 64 static inline SkImage_Base* as_IB(SkImage* image) { |
63 return static_cast<SkImage_Base*>(image); | 65 return static_cast<SkImage_Base*>(image); |
64 } | 66 } |
65 | 67 |
66 static inline const SkImage_Base* as_IB(const SkImage* image) { | 68 static inline const SkImage_Base* as_IB(const SkImage* image) { |
67 return static_cast<const SkImage_Base*>(image); | 69 return static_cast<const SkImage_Base*>(image); |
68 } | 70 } |
69 | 71 |
70 #endif | 72 #endif |
OLD | NEW |