OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkImageGenerator_DEFINED | 8 #ifndef SkImageGenerator_DEFINED |
9 #define SkImageGenerator_DEFINED | 9 #define SkImageGenerator_DEFINED |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 * SkDiscardablePixelRef) to decode and re-decode an image as needed. | 41 * SkDiscardablePixelRef) to decode and re-decode an image as needed. |
42 */ | 42 */ |
43 class SK_API SkImageGenerator { | 43 class SK_API SkImageGenerator { |
44 public: | 44 public: |
45 /** | 45 /** |
46 * The PixelRef which takes ownership of this SkImageGenerator | 46 * The PixelRef which takes ownership of this SkImageGenerator |
47 * will call the image generator's destructor. | 47 * will call the image generator's destructor. |
48 */ | 48 */ |
49 virtual ~SkImageGenerator() { } | 49 virtual ~SkImageGenerator() { } |
50 | 50 |
51 #ifdef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI | |
52 virtual SkData* refEncodedData() { return this->onRefEncodedData(); } | |
53 virtual bool getInfo(SkImageInfo* info) { return this->onGetInfo(info); } | |
54 virtual bool getPixels(const SkImageInfo& info, void* pixels, size_t rowByte
s) { | |
55 return this->onGetPixels(info, pixels, rowBytes, NULL, NULL); | |
56 } | |
57 #else | |
58 /** | 51 /** |
59 * Return a ref to the encoded (i.e. compressed) representation, | 52 * Return a ref to the encoded (i.e. compressed) representation, |
60 * of this data. | 53 * of this data. |
61 * | 54 * |
62 * If non-NULL is returned, the caller is responsible for calling | 55 * If non-NULL is returned, the caller is responsible for calling |
63 * unref() on the data when it is finished. | 56 * unref() on the data when it is finished. |
64 */ | 57 */ |
65 SkData* refEncodedData() { return this->onRefEncodedData(); } | 58 SkData* refEncodedData() { return this->onRefEncodedData(); } |
66 | 59 |
67 /** | 60 /** |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 * @return false if anything goes wrong or if the image info is | 94 * @return false if anything goes wrong or if the image info is |
102 * unsupported. | 95 * unsupported. |
103 */ | 96 */ |
104 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, | 97 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
105 SkPMColor ctable[], int* ctableCount); | 98 SkPMColor ctable[], int* ctableCount); |
106 | 99 |
107 /** | 100 /** |
108 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType. | 101 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType. |
109 */ | 102 */ |
110 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 103 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
111 #endif | |
112 | 104 |
113 /** | 105 /** |
114 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an
y entry in rowBytes | 106 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an
y entry in rowBytes |
115 * is 0, this imagegenerator should output the sizes and return true if it
can efficiently | 107 * is 0, this imagegenerator should output the sizes and return true if it
can efficiently |
116 * return YUV planar data. If it cannot, it should return false. Note that
either planes and | 108 * return YUV planar data. If it cannot, it should return false. Note that
either planes and |
117 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL
or have NULL or 0 | 109 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL
or have NULL or 0 |
118 * entries only. Having only partial planes/rowBytes information is not sup
ported. | 110 * entries only. Having only partial planes/rowBytes information is not sup
ported. |
119 * | 111 * |
120 * If all planes and rowBytes entries are non NULL or non 0, then it should
copy the | 112 * If all planes and rowBytes entries are non NULL or non 0, then it should
copy the |
121 * associated YUV data into those planes of memory supplied by the caller.
It should validate | 113 * associated YUV data into those planes of memory supplied by the caller.
It should validate |
122 * that the sizes match what it expected. If the sizes do not match, it sho
uld return false. | 114 * that the sizes match what it expected. If the sizes do not match, it sho
uld return false. |
123 */ | 115 */ |
124 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 116 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
125 SkYUVColorSpace* colorSpace); | 117 SkYUVColorSpace* colorSpace); |
126 | 118 |
127 protected: | 119 protected: |
128 virtual SkData* onRefEncodedData(); | 120 virtual SkData* onRefEncodedData(); |
129 virtual bool onGetInfo(SkImageInfo* info); | 121 virtual bool onGetInfo(SkImageInfo* info); |
130 virtual bool onGetPixels(const SkImageInfo& info, | 122 virtual bool onGetPixels(const SkImageInfo& info, |
131 void* pixels, size_t rowBytes, | 123 void* pixels, size_t rowBytes, |
132 SkPMColor ctable[], int* ctableCount); | 124 SkPMColor ctable[], int* ctableCount); |
133 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 125 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
134 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 126 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
135 SkYUVColorSpace* colorSpace); | 127 SkYUVColorSpace* colorSpace); |
136 }; | 128 }; |
137 | 129 |
138 #endif // SkImageGenerator_DEFINED | 130 #endif // SkImageGenerator_DEFINED |
OLD | NEW |