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 #include "SkData.h" | 8 #include "SkData.h" |
9 #include "SkDecodingImageGenerator.h" | 9 #include "SkDecodingImageGenerator.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 const SkImageInfo& info, | 35 const SkImageInfo& info, |
36 int sampleSize, | 36 int sampleSize, |
37 bool ditherImage); | 37 bool ditherImage); |
38 | 38 |
39 protected: | 39 protected: |
40 SkData* onRefEncodedData() SK_OVERRIDE; | 40 SkData* onRefEncodedData() SK_OVERRIDE; |
41 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 41 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
42 *info = fInfo; | 42 *info = fInfo; |
43 return true; | 43 return true; |
44 } | 44 } |
45 virtual bool onGetPixels(const SkImageInfo& info, | 45 bool onGetPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkPMColo r ctable[], |
46 void* pixels, size_t rowBytes, | 46 int* ctableCount) SK_OVERRIDE; |
47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE; | 47 bool onQueryYUV8(SkISize logical[3], SkISize optimal[3]) SK_OVERRIDE; |
48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | 48 bool onGetYUV8(const SkISize sizes[3], void* planes[3], SkYUVColorSpace*) SK _OVERRIDE; |
scroggo
2015/01/22 19:47:47
#ifdef SK_SUPPORT_LEGACY_IMAGEGENERATOR_YUV_API ?
| |
49 SkYUVColorSpace* colorSpace) SK_OVERRIDE; | |
50 | 49 |
51 private: | 50 private: |
52 typedef SkImageGenerator INHERITED; | 51 typedef SkImageGenerator INHERITED; |
53 }; | 52 }; |
54 | 53 |
55 /** | 54 /** |
56 * Special allocator used by getPixels(). Uses preallocated memory | 55 * Special allocator used by getPixels(). Uses preallocated memory |
57 * provided if possible, else fall-back on the default allocator | 56 * provided if possible, else fall-back on the default allocator |
58 */ | 57 */ |
59 class TargetAllocator : public SkBitmap::Allocator { | 58 class TargetAllocator : public SkBitmap::Allocator { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 if (NULL == ctable) { | 196 if (NULL == ctable) { |
198 return false; | 197 return false; |
199 } | 198 } |
200 const int count = ctable->count(); | 199 const int count = ctable->count(); |
201 memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor)); | 200 memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor)); |
202 *ctableCount = count; | 201 *ctableCount = count; |
203 } | 202 } |
204 return true; | 203 return true; |
205 } | 204 } |
206 | 205 |
207 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], | 206 bool DecodingImageGenerator::onQueryYUV8(SkISize logical[3], SkISize optimal[3]) { |
208 size_t rowBytes[3], SkYUVColorSpace * colorSpace) { | |
209 if (!fStream->rewind()) { | 207 if (!fStream->rewind()) { |
210 return false; | 208 return false; |
211 } | 209 } |
212 | 210 |
213 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream)); | 211 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream)); |
214 if (NULL == decoder.get()) { | 212 if (NULL == decoder.get()) { |
215 return false; | 213 return false; |
216 } | 214 } |
217 | 215 |
218 return decoder->decodeYUV8Planes(fStream, sizes, planes, rowBytes, colorSpac e); | 216 return false;//decoder->decodeYUV8Planes(fStream, sizes, planes, rowBytes, c olorSpace); |
219 } | 217 } |
220 | 218 |
219 bool DecodingImageGenerator::onGetYUV8(const SkISize sizes[3], void* planes[3], | |
220 SkYUVColorSpace* colorSpace) { | |
221 if (!fStream->rewind()) { | |
222 return false; | |
223 } | |
224 | |
225 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream)); | |
226 if (NULL == decoder.get()) { | |
227 return false; | |
228 } | |
229 | |
230 return false;//decoder->decodeYUV8Planes(fStream, sizes, planes, rowBytes, c olorSpace); | |
231 } | |
232 | |
221 // A contructor-type function that returns NULL on failure. This | 233 // A contructor-type function that returns NULL on failure. This |
222 // prevents the returned SkImageGenerator from ever being in a bad | 234 // prevents the returned SkImageGenerator from ever being in a bad |
223 // state. Called by both Create() functions | 235 // state. Called by both Create() functions |
224 SkImageGenerator* CreateDecodingImageGenerator( | 236 SkImageGenerator* CreateDecodingImageGenerator( |
225 SkData* data, | 237 SkData* data, |
226 SkStreamRewindable* stream, | 238 SkStreamRewindable* stream, |
227 const SkDecodingImageGenerator::Options& opts) { | 239 const SkDecodingImageGenerator::Options& opts) { |
228 SkASSERT(stream); | 240 SkASSERT(stream); |
229 SkAutoTDelete<SkStreamRewindable> autoStream(stream); // always delete this | 241 SkAutoTDelete<SkStreamRewindable> autoStream(stream); // always delete this |
230 SkAssertResult(autoStream->rewind()); | 242 SkAssertResult(autoStream->rewind()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 296 |
285 SkImageGenerator* SkDecodingImageGenerator::Create( | 297 SkImageGenerator* SkDecodingImageGenerator::Create( |
286 SkStreamRewindable* stream, | 298 SkStreamRewindable* stream, |
287 const SkDecodingImageGenerator::Options& opts) { | 299 const SkDecodingImageGenerator::Options& opts) { |
288 SkASSERT(stream != NULL); | 300 SkASSERT(stream != NULL); |
289 if (stream == NULL) { | 301 if (stream == NULL) { |
290 return NULL; | 302 return NULL; |
291 } | 303 } |
292 return CreateDecodingImageGenerator(NULL, stream, opts); | 304 return CreateDecodingImageGenerator(NULL, stream, opts); |
293 } | 305 } |
OLD | NEW |