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 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
10 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, | 11 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, |
11 size_t rowBytes, const Opti
ons* options, | 12 size_t rowBytes, const Opti
ons* options, |
12 SkPMColor ctable[], int* ct
ableCount) { | 13 SkPMColor ctable[], int* ct
ableCount) { |
| 14 #else |
| 15 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
owBytes, |
| 16 SkPMColor ctable[], int* ctableCount) { |
| 17 #endif |
13 if (kUnknown_SkColorType == info.colorType()) { | 18 if (kUnknown_SkColorType == info.colorType()) { |
| 19 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
14 return kInvalidConversion; | 20 return kInvalidConversion; |
| 21 #else |
| 22 return false; |
| 23 #endif |
15 } | 24 } |
16 if (NULL == pixels) { | 25 if (NULL == pixels) { |
| 26 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
17 return kInvalidParameters; | 27 return kInvalidParameters; |
| 28 #else |
| 29 return false; |
| 30 #endif |
18 } | 31 } |
19 if (rowBytes < info.minRowBytes()) { | 32 if (rowBytes < info.minRowBytes()) { |
| 33 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
20 return kInvalidParameters; | 34 return kInvalidParameters; |
| 35 #else |
| 36 return false; |
| 37 #endif |
21 } | 38 } |
22 | 39 |
23 if (kIndex_8_SkColorType == info.colorType()) { | 40 if (kIndex_8_SkColorType == info.colorType()) { |
24 if (NULL == ctable || NULL == ctableCount) { | 41 if (NULL == ctable || NULL == ctableCount) { |
| 42 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
25 return kInvalidParameters; | 43 return kInvalidParameters; |
| 44 #else |
| 45 return false; |
| 46 #endif |
26 } | 47 } |
27 } else { | 48 } else { |
28 if (ctableCount) { | 49 if (ctableCount) { |
29 *ctableCount = 0; | 50 *ctableCount = 0; |
30 } | 51 } |
31 ctableCount = NULL; | 52 ctableCount = NULL; |
32 ctable = NULL; | 53 ctable = NULL; |
33 } | 54 } |
34 | 55 |
| 56 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
35 // Default options. | 57 // Default options. |
36 Options optsStorage; | 58 Options optsStorage; |
37 if (NULL == options) { | 59 if (NULL == options) { |
38 options = &optsStorage; | 60 options = &optsStorage; |
39 } | 61 } |
40 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct
able, ctableCount); | 62 const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ct
able, ctableCount); |
41 | 63 |
42 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { | 64 if ((kIncompleteInput == result || kSuccess == result) && ctableCount) { |
| 65 #else |
| 66 const bool result = this->onGetPixels(info, pixels, rowBytes, ctable, ctable
Count); |
| 67 if (result && ctableCount) { |
| 68 #endif |
43 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); | 69 SkASSERT(*ctableCount >= 0 && *ctableCount <= 256); |
44 } | 70 } |
45 return result; | 71 return result; |
46 } | 72 } |
47 | 73 |
48 SkImageGenerator::Result SkImageGenerator::getPixels(const SkImageInfo& info, vo
id* pixels, | 74 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
| 75 SkImageGenerator::Result |
| 76 #else |
| 77 bool |
| 78 #endif |
| 79 SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, |
49 size_t rowBytes) { | 80 size_t rowBytes) { |
50 SkASSERT(kIndex_8_SkColorType != info.colorType()); | 81 SkASSERT(kIndex_8_SkColorType != info.colorType()); |
51 if (kIndex_8_SkColorType == info.colorType()) { | 82 if (kIndex_8_SkColorType == info.colorType()) { |
| 83 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
52 return kInvalidConversion; | 84 return kInvalidConversion; |
| 85 #else |
| 86 return false; |
| 87 #endif |
53 } | 88 } |
| 89 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
54 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); | 90 return this->getPixels(info, pixels, rowBytes, NULL, NULL, NULL); |
| 91 #else |
| 92 return this->getPixels(info, pixels, rowBytes, NULL, NULL); |
| 93 #endif |
55 } | 94 } |
56 | 95 |
57 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3], | 96 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3], |
58 SkYUVColorSpace* colorSpace) { | 97 SkYUVColorSpace* colorSpace) { |
59 #ifdef SK_DEBUG | 98 #ifdef SK_DEBUG |
60 // In all cases, we need the sizes array | 99 // In all cases, we need the sizes array |
61 SkASSERT(sizes); | 100 SkASSERT(sizes); |
62 | 101 |
63 bool isValidWithPlanes = (planes) && (rowBytes) && | 102 bool isValidWithPlanes = (planes) && (rowBytes) && |
64 ((planes[0]) && (planes[1]) && (planes[2]) && | 103 ((planes[0]) && (planes[1]) && (planes[2]) && |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 144 } |
106 return this->onGetYUV8Planes(sizes, planes, rowBytes); | 145 return this->onGetYUV8Planes(sizes, planes, rowBytes); |
107 } | 146 } |
108 | 147 |
109 ////////////////////////////////////////////////////////////////////////////////
///////////// | 148 ////////////////////////////////////////////////////////////////////////////////
///////////// |
110 | 149 |
111 SkData* SkImageGenerator::onRefEncodedData() { | 150 SkData* SkImageGenerator::onRefEncodedData() { |
112 return NULL; | 151 return NULL; |
113 } | 152 } |
114 | 153 |
| 154 #ifdef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS |
115 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info,
void* dst, | 155 SkImageGenerator::Result SkImageGenerator::onGetPixels(const SkImageInfo& info,
void* dst, |
116 size_t rb, const Options&
options, | 156 size_t rb, const Options&
options, |
117 SkPMColor* colors, int* c
olorCount) { | 157 SkPMColor* colors, int* c
olorCount) { |
118 return kUnimplemented; | 158 return kUnimplemented; |
119 } | 159 } |
| 160 #else |
| 161 bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb
, |
| 162 SkPMColor* colors, int* colorCount) { |
| 163 return false; |
| 164 } |
| 165 #endif |
OLD | NEW |