Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 virtual SkData* onRefEncodedData() SK_OVERRIDE; | 40 virtual SkData* onRefEncodedData() SK_OVERRIDE; |
| 41 virtual bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 41 virtual 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 virtual bool onGetPixels(const SkImageInfo& info, |
| 46 void* pixels, size_t rowBytes, | 46 void* pixels, size_t rowBytes, |
| 47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE; | 47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE; |
| 48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | |
| 49 SkYUVColorSpace* colorSpace) SK_OVERRIDE; | |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 typedef SkImageGenerator INHERITED; | 52 typedef SkImageGenerator INHERITED; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 /** | 55 /** |
| 54 * Special allocator used by getPixels(). Uses preallocated memory | 56 * Special allocator used by getPixels(). Uses preallocated memory |
| 55 * provided if possible, else fall-back on the default allocator | 57 * provided if possible, else fall-back on the default allocator |
| 56 */ | 58 */ |
| 57 class TargetAllocator : public SkBitmap::Allocator { | 59 class TargetAllocator : public SkBitmap::Allocator { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 return false; | 199 return false; |
| 198 } | 200 } |
| 199 const int count = ctable->count(); | 201 const int count = ctable->count(); |
| 200 memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor)); | 202 memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor)); |
| 201 ctable->unlockColors(); | 203 ctable->unlockColors(); |
| 202 *ctableCount = count; | 204 *ctableCount = count; |
| 203 } | 205 } |
| 204 return true; | 206 return true; |
| 205 } | 207 } |
| 206 | 208 |
| 209 bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], | |
| 210 size_t rowBytes[3], SkYUVColorSpace * colorSpace) { | |
|
reed1
2014/10/13 13:15:35
where do we set colorSpace? Seems like we need the
sugoi1
2014/10/14 15:07:36
I set it here. For now I set it unconditionally to
reed1
2014/10/14 15:34:28
I don't see where "here" is.
sugoi1
2014/10/14 15:46:37
Sorry, I meant: in this function (next version of
| |
| 211 if (!fStream->rewind()) { | |
| 212 return false; | |
| 213 } | |
| 214 | |
| 215 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream)); | |
| 216 if (NULL == decoder.get()) { | |
| 217 return false; | |
| 218 } | |
| 219 | |
| 220 if (!planes || !planes[0]) { | |
| 221 return decoder->getYUVComponentSizes(fStream, sizes); | |
| 222 } | |
| 223 | |
| 224 return decoder->decodeToYUV(fStream, sizes, planes, rowBytes); | |
| 225 } | |
| 226 | |
| 207 // A contructor-type function that returns NULL on failure. This | 227 // A contructor-type function that returns NULL on failure. This |
| 208 // prevents the returned SkImageGenerator from ever being in a bad | 228 // prevents the returned SkImageGenerator from ever being in a bad |
| 209 // state. Called by both Create() functions | 229 // state. Called by both Create() functions |
| 210 SkImageGenerator* CreateDecodingImageGenerator( | 230 SkImageGenerator* CreateDecodingImageGenerator( |
| 211 SkData* data, | 231 SkData* data, |
| 212 SkStreamRewindable* stream, | 232 SkStreamRewindable* stream, |
| 213 const SkDecodingImageGenerator::Options& opts) { | 233 const SkDecodingImageGenerator::Options& opts) { |
| 214 SkASSERT(stream); | 234 SkASSERT(stream); |
| 215 SkAutoTUnref<SkStreamRewindable> autoStream(stream); // always unref this. | 235 SkAutoTUnref<SkStreamRewindable> autoStream(stream); // always unref this. |
| 216 SkAssertResult(autoStream->rewind()); | 236 SkAssertResult(autoStream->rewind()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 SkStreamRewindable* stream, | 293 SkStreamRewindable* stream, |
| 274 const SkDecodingImageGenerator::Options& opts) { | 294 const SkDecodingImageGenerator::Options& opts) { |
| 275 SkASSERT(stream != NULL); | 295 SkASSERT(stream != NULL); |
| 276 SkASSERT(stream->unique()); | 296 SkASSERT(stream->unique()); |
| 277 if ((stream == NULL) || !stream->unique()) { | 297 if ((stream == NULL) || !stream->unique()) { |
| 278 SkSafeUnref(stream); | 298 SkSafeUnref(stream); |
| 279 return NULL; | 299 return NULL; |
| 280 } | 300 } |
| 281 return CreateDecodingImageGenerator(NULL, stream, opts); | 301 return CreateDecodingImageGenerator(NULL, stream, opts); |
| 282 } | 302 } |
| OLD | NEW |