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 #ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI | 10 #ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
owBytes) { | 51 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
owBytes) { |
52 SkASSERT(kIndex_8_SkColorType != info.colorType()); | 52 SkASSERT(kIndex_8_SkColorType != info.colorType()); |
53 if (kIndex_8_SkColorType == info.colorType()) { | 53 if (kIndex_8_SkColorType == info.colorType()) { |
54 return false; | 54 return false; |
55 } | 55 } |
56 return this->getPixels(info, pixels, rowBytes, NULL, NULL); | 56 return this->getPixels(info, pixels, rowBytes, NULL, NULL); |
57 } | 57 } |
58 #endif | 58 #endif |
59 | 59 |
60 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3]) { | 60 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r
owBytes[3], |
| 61 SkYUVColorSpace* colorSpace) { |
61 #ifdef SK_DEBUG | 62 #ifdef SK_DEBUG |
62 // In all cases, we need the sizes array | 63 // In all cases, we need the sizes array |
63 SkASSERT(sizes); | 64 SkASSERT(sizes); |
64 | 65 |
65 bool isValidWithPlanes = (planes) && (rowBytes) && | 66 bool isValidWithPlanes = (planes) && (rowBytes) && |
66 ((planes[0]) && (planes[1]) && (planes[2]) && | 67 ((planes[0]) && (planes[1]) && (planes[2]) && |
67 (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])); | 68 (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])); |
68 bool isValidWithoutPlanes = | 69 bool isValidWithoutPlanes = |
69 ((NULL == planes) || | 70 ((NULL == planes) || |
70 ((NULL == planes[0]) && (NULL == planes[1]) && (NULL == planes[2]))) && | 71 ((NULL == planes[0]) && (NULL == planes[1]) && (NULL == planes[2]))) && |
(...skipping 11 matching lines...) Expand all Loading... |
82 (sizes[0].fHeight >= 0) && | 83 (sizes[0].fHeight >= 0) && |
83 (sizes[1].fWidth >= 0) && | 84 (sizes[1].fWidth >= 0) && |
84 (sizes[1].fHeight >= 0) && | 85 (sizes[1].fHeight >= 0) && |
85 (sizes[2].fWidth >= 0) && | 86 (sizes[2].fWidth >= 0) && |
86 (sizes[2].fHeight >= 0) && | 87 (sizes[2].fHeight >= 0) && |
87 (rowBytes[0] >= (size_t)sizes[0].fWidth) && | 88 (rowBytes[0] >= (size_t)sizes[0].fWidth) && |
88 (rowBytes[1] >= (size_t)sizes[1].fWidth) && | 89 (rowBytes[1] >= (size_t)sizes[1].fWidth) && |
89 (rowBytes[2] >= (size_t)sizes[2].fWidth))); | 90 (rowBytes[2] >= (size_t)sizes[2].fWidth))); |
90 #endif | 91 #endif |
91 | 92 |
92 return this->onGetYUV8Planes(sizes, planes, rowBytes); | 93 return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace); |
93 } | 94 } |
94 | 95 |
95 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t
rowBytes[3]) { | 96 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t
rowBytes[3]) { |
96 return false; | 97 return false; |
97 } | 98 } |
98 | 99 |
| 100 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t
rowBytes[3], |
| 101 SkYUVColorSpace* colorSpace) { |
| 102 // In order to maintain compatibility with clients that implemented the orig
inal |
| 103 // onGetYUV8Planes interface, we assume that the color space is JPEG. |
| 104 // TODO(rileya): remove this and the old onGetYUV8Planes once clients switch
over to |
| 105 // the new interface. |
| 106 if (colorSpace) { |
| 107 *colorSpace = kJPEG_SkYUVColorSpace; |
| 108 } |
| 109 return this->onGetYUV8Planes(sizes, planes, rowBytes); |
| 110 } |
| 111 |
99 ////////////////////////////////////////////////////////////////////////////////
///////////// | 112 ////////////////////////////////////////////////////////////////////////////////
///////////// |
100 | 113 |
101 SkData* SkImageGenerator::onRefEncodedData() { | 114 SkData* SkImageGenerator::onRefEncodedData() { |
102 return NULL; | 115 return NULL; |
103 } | 116 } |
104 | 117 |
105 bool SkImageGenerator::onGetInfo(SkImageInfo*) { | 118 bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
106 return false; | 119 return false; |
107 } | 120 } |
108 | 121 |
109 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*
, int*) { | 122 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*
, int*) { |
110 return false; | 123 return false; |
111 } | 124 } |
OLD | NEW |