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 |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
13 | 13 |
| 14 //#define SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API |
| 15 |
14 class SkBitmap; | 16 class SkBitmap; |
15 class SkData; | 17 class SkData; |
16 class SkImageGenerator; | 18 class SkImageGenerator; |
17 | 19 |
18 /** | 20 /** |
19 * Takes ownership of SkImageGenerator. If this method fails for | 21 * Takes ownership of SkImageGenerator. If this method fails for |
20 * whatever reason, it will return false and immediatetely delete | 22 * whatever reason, it will return false and immediatetely delete |
21 * the generator. If it succeeds, it will modify destination | 23 * the generator. If it succeeds, it will modify destination |
22 * bitmap. | 24 * bitmap. |
23 * | 25 * |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 * unsupported. | 102 * unsupported. |
101 */ | 103 */ |
102 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, | 104 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
103 SkPMColor ctable[], int* ctableCount); | 105 SkPMColor ctable[], int* ctableCount); |
104 | 106 |
105 /** | 107 /** |
106 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType. | 108 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType. |
107 */ | 109 */ |
108 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 110 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
109 | 111 |
| 112 #ifdef SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API |
110 /** | 113 /** |
111 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an
y entry in rowBytes | 114 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an
y entry in rowBytes |
112 * is 0, this imagegenerator should output the sizes and return true if it
can efficiently | 115 * is 0, this imagegenerator should output the sizes and return true if it
can efficiently |
113 * return YUV planar data. If it cannot, it should return false. Note that
either planes and | 116 * return YUV planar data. If it cannot, it should return false. Note that
either planes and |
114 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL
or have NULL or 0 | 117 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL
or have NULL or 0 |
115 * entries only. Having only partial planes/rowBytes information is not sup
ported. | 118 * entries only. Having only partial planes/rowBytes information is not sup
ported. |
116 * | 119 * |
117 * If all planes and rowBytes entries are non NULL or non 0, then it should
copy the | 120 * If all planes and rowBytes entries are non NULL or non 0, then it should
copy the |
118 * associated YUV data into those planes of memory supplied by the caller.
It should validate | 121 * associated YUV data into those planes of memory supplied by the caller.
It should validate |
119 * that the sizes match what it expected. If the sizes do not match, it sho
uld return false. | 122 * that the sizes match what it expected. If the sizes do not match, it sho
uld return false. |
120 */ | 123 */ |
121 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 124 bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
122 SkYUVColorSpace* colorSpace); | 125 SkYUVColorSpace* colorSpace); |
| 126 #endif |
| 127 |
| 128 /** |
| 129 * If this generator supports returning planar YUV data, return true, and r
eturn |
| 130 * the logicalSizes (if not NULL) and the optimalAllocationSizes (if not NU
LL), where each |
| 131 * array represents [0]=Y, [1]=U, [2]=V. Each Size is a width/height in pix
els for its plane. |
| 132 * |
| 133 * The optimalAllocationSizes may be the same as the logicalSizes, but they
may also be larger |
| 134 * if that will aid the generator (for performance). |
| 135 * |
| 136 * If this returns false, the value of the (optional) sizes parameters is u
ndefined. |
| 137 */ |
| 138 bool queryYUV8(SkISize logicalSizes[3], SkISize optimalAllocationSizes[3]); |
| 139 |
| 140 /** |
| 141 * If this generator supports returning planar YUV data, and can fulfill th
e requested |
| 142 * sizes for each plane, return true and write the YUV data into the planes
. |
| 143 * |
| 144 * Calling queryYUV8() will return both the logical sizes (W/H) and the opt
imal-allocation |
| 145 * sizes for the 3 planes. For getYUV8(), it is legal to pass the logical s
izes |
| 146 * (though smaller than those will return false). However, this may |
| 147 * (depending on the implementation) be slower than passing in the optimal-
allocation sizes |
| 148 * (or larger). The extra space may allow the implementation to run faster
at the cost of |
| 149 * slightly more ram being allocated. There should be no performance penalt
y for the |
| 150 * allocationSizes to larger than the values in optimalAllocationSizes, as
they are just the |
| 151 * minimum sizes for best performance. |
| 152 * |
| 153 * If colorSpace is not NULL, return the corresponding colorSpace for the Y
UV data. |
| 154 */ |
| 155 bool getYUV8(const SkISize allocationSizes[3], void* planes[3], SkYUVColorSp
ace* colorSpace); |
123 | 156 |
124 /** | 157 /** |
125 * If the default image decoder system can interpret the specified (encoded
) data, then | 158 * If the default image decoder system can interpret the specified (encoded
) data, then |
126 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way | 159 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way |
127 * the caller is still responsible for managing their ownership of the data
. | 160 * the caller is still responsible for managing their ownership of the data
. |
128 */ | 161 */ |
129 static SkImageGenerator* NewFromData(SkData*); | 162 static SkImageGenerator* NewFromData(SkData*); |
130 | 163 |
131 protected: | 164 protected: |
132 virtual SkData* onRefEncodedData(); | 165 virtual SkData* onRefEncodedData(); |
133 virtual bool onGetInfo(SkImageInfo* info); | 166 virtual bool onGetInfo(SkImageInfo* info); |
134 virtual bool onGetPixels(const SkImageInfo& info, | 167 virtual bool onGetPixels(const SkImageInfo& info, |
135 void* pixels, size_t rowBytes, | 168 void* pixels, size_t rowBytes, |
136 SkPMColor ctable[], int* ctableCount); | 169 SkPMColor ctable[], int* ctableCount); |
| 170 // logicalSizes and optimalAllocationSizes will be non-null |
| 171 virtual bool onQueryYUV8(SkISize logicalSizes[3], SkISize optimalAllocationS
izes[3]); |
| 172 // logicalSizes and optimalAllocationSizes and planes will be non-null. |
| 173 // colorSpace may still be null. |
| 174 virtual bool onGetYUV8(const SkISize allocationSizes[3], void* planes[3], |
| 175 SkYUVColorSpace* colorSpace); |
| 176 #ifdef SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API |
137 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 177 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
138 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 178 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
139 SkYUVColorSpace* colorSpace); | 179 SkYUVColorSpace* colorSpace); |
| 180 #endif |
140 }; | 181 }; |
141 | 182 |
142 #endif // SkImageGenerator_DEFINED | 183 #endif // SkImageGenerator_DEFINED |
OLD | NEW |