| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
| 9 | 9 |
| 10 bool SkImageGenerator::getInfo(SkImageInfo* info) { | 10 bool SkImageGenerator::getInfo(SkImageInfo* info) { |
| 11 SkImageInfo dummy; | 11 SkImageInfo dummy; |
| 12 if (NULL == info) { | 12 if (NULL == info) { |
| 13 info = &dummy; | 13 info = &dummy; |
| 14 } | 14 } |
| 15 return this->onGetInfo(info); | 15 return this->onGetInfo(info); |
| 16 } | 16 } |
| 17 | 17 |
| 18 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, | 18 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, |
| 19 size_t rowBytes, SkPMColor
ctable[], | 19 size_t rowBytes, const Opti
ons* options, |
| 20 int* ctableCount) { | 20 SkPMColor ctable[], int* ct
ableCount) { |
| 21 if (kUnknown_SkColorType == info.colorType()) { | 21 if (kUnknown_SkColorType == info.colorType()) { |
| 22 return kInvalidConversion; | 22 return kInvalidConversion; |
| 23 } | 23 } |
| 24 if (NULL == pixels) { | 24 if (NULL == pixels) { |
| 25 return kInvalidParameters; | 25 return kInvalidParameters; |
| 26 } | 26 } |
| 27 if (rowBytes < info.minRowBytes()) { | 27 if (rowBytes < info.minRowBytes()) { |
| 28 return kInvalidParameters; | 28 return kInvalidParameters; |
| 29 } | 29 } |
| 30 | 30 |
| 31 if (kIndex_8_SkColorType == info.colorType()) { | 31 if (kIndex_8_SkColorType == info.colorType()) { |
| 32 if (NULL == ctable || NULL == ctableCount) { | 32 if (NULL == ctable || NULL == ctableCount) { |
| 33 return kInvalidParameters; | 33 return kInvalidParameters; |
| 34 } | 34 } |
| 35 } else { | 35 } else { |
| 36 if (ctableCount) { | 36 if (ctableCount) { |
| 37 *ctableCount = 0; | 37 *ctableCount = 0; |
| 38 } | 38 } |
| 39 ctableCount = NULL; | 39 ctableCount = NULL; |
| 40 ctable = NULL; | 40 ctable = NULL; |
| 41 } | 41 } |
| 42 | 42 |
| 43 const Result result = this->onGetPixels(info, pixels, rowBytes, ctable, ctab
leCount); | 43 // Default options. |
| 44 Options optsStorage; |
| 45 if (NULL == options) { |
| 46 options = &optsStorage; |
| 47 } |
| 48 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct
able, ctableCount); |
| 44 | 49 |
| 45 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { | 50 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
| 46 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); | 51 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
| 47 } | 52 } |
| 48 return result; | 53 return result; |
| 49 } | 54 } |
| 50 | 55 |
| 51 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, | 56 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, |
| 52 size_t rowBytes) { | 57 size_t rowBytes) { |
| 53 SkASSERT(kIndex_8_SkColorType != info.colorType()); | 58 SkASSERT(kIndex_8_SkColorType != info.colorType()); |
| 54 if (kIndex_8_SkColorType == info.colorType()) { | 59 if (kIndex_8_SkColorType == info.colorType()) { |
| 55 return kInvalidConversion; | 60 return kInvalidConversion; |
| 56 } | 61 } |
| 57 return this->getPixels(info, pixels, rowBytes, NULL, NULL); | 62 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); |
| 58 } | 63 } |
| 59 | 64 |
| 60 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3], | 65 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3], |
| 61 SkYUVColorSpace* colorSpace) { | 66 SkYUVColorSpace* colorSpace) { |
| 62 #ifdef SK_DEBUG | 67 #ifdef SK_DEBUG |
| 63 // In all cases, we need the sizes array | 68 // In all cases, we need the sizes array |
| 64 SkASSERT(sizes); | 69 SkASSERT(sizes); |
| 65 | 70 |
| 66 bool isValidWithPlanes = (planes) && (rowBytes) && | 71 bool isValidWithPlanes = (planes) && (rowBytes) && |
| 67 ((planes[0]) && (planes[1]) && (planes[2]) && | 72 ((planes[0]) && (planes[1]) && (planes[2]) && |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ////////////////////////////////////////////////////////////////////////////////
///////////// | 117 ////////////////////////////////////////////////////////////////////////////////
///////////// |
| 113 | 118 |
| 114 SkData* SkImageGenerator::onRefEncodedData() { | 119 SkData* SkImageGenerator::onRefEncodedData() { |
| 115 return NULL; | 120 return NULL; |
| 116 } | 121 } |
| 117 | 122 |
| 118 bool SkImageGenerator::onGetInfo(SkImageInfo*) { | 123 bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
| 119 return false; | 124 return false; |
| 120 } | 125 } |
| 121 | 126 |
| 127 #ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS |
| 122 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo&, void*
, size_t, | 128 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo&, void*
, size_t, |
| 123 SkPMColor*, int*) { | 129 SkPMColor*, int*) { |
| 124 return kUnimplemented; | 130 return kUnimplemented; |
| 125 } | 131 } |
| 132 #endif |
| 133 |
| 134 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info,
void* dst, |
| 135 size_t rb, const Options&
options, |
| 136 SkPMColor* colors, int* c
olorCount) { |
| 137 #ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS |
| 138 return this->onGetPixels(info, dst, rb, colors, colorCount); |
| 139 #else |
| 140 return kUnimplemented; |
| 141 #endif |
| 142 } |
| OLD | NEW |