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 #ifndef SkImageGenerator_DEFINED | 8 #ifndef SkImageGenerator_DEFINED |
| 9 #define SkImageGenerator_DEFINED | 9 #define SkImageGenerator_DEFINED |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 * | 101 * |
| 102 * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount | 102 * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount |
| 103 * is not null, it will be set to 0. | 103 * is not null, it will be set to 0. |
| 104 * | 104 * |
| 105 * @return true on success. | 105 * @return true on success. |
| 106 */ | 106 */ |
| 107 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, | 107 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
| 108 SkPMColor ctable[], int* ctableCount); | 108 SkPMColor ctable[], int* ctableCount); |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Some generators can efficiently scale their contents and provide multipl e | |
| 112 * different pixel formats while decoding. | |
| 113 * If scaling is supported, the generator may only support certain scaled d imensions. | |
| 114 * Call this with the desired scale and color type, and it will return true if scaling | |
| 115 * and specified color type is supported. | |
| 116 * | |
| 117 * @param colorType A description of the color type expected by the caller. | |
| 118 * Returns true if it is the same as getInfo() or if decoder impleme ntations | |
| 119 * support this output. | |
| 120 * | |
| 121 * @param scale Vale larger than 0 and less or equal to 1. | |
| 122 * | |
| 123 * @param availableSize If specified colorType and scale on decode is suppo rted, | |
| 124 * this holds a value of equal or nearest larger possible decode out put. | |
| 125 * Can be NULL, in which case caller specifies no interest in gettin g the value. | |
| 126 * | |
| 127 * @param lowerSize If specified colorType and scale on decode is supported , | |
| 128 * this holds a value of nearest lower possible decode output. | |
| 129 * Can be NULL, in which case caller specifies no interest in gettin g the value. | |
| 130 * | |
| 131 * Disclaimer: This method was added later to this class and it is possible | |
| 132 * that some of the SkImageGenerator implementations are not overriding it to | |
| 133 * precisely declare supported decoding. Purpose of this call is an attempt to prevent | |
| 134 * fruitless memory allocations (from within Skia) before calling getPixels - it is | |
| 135 * still OK to call getPixels even this method is not overridden in generat or implementation. | |
| 136 */ | |
| 137 bool canDecodeAndScale(const SkColorType colorType, const SkScalar scale = S K_Scalar1, | |
|
scroggo
2015/10/15 16:26:32
Should this also specify an alpha type? Or should
| |
| 138 SkISize *availableSize = nullptr, SkISize *lowerSize = nullptr); | |
|
scroggo
2015/10/15 16:26:32
I like that the sizes are named to distinguish wha
| |
| 139 | |
| 140 /** | |
| 111 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and | 141 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and |
| 112 * uses the default Options. | 142 * uses the default Options. |
| 113 */ | 143 */ |
| 114 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 144 bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
| 115 | 145 |
| 116 /** | 146 /** |
| 117 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes | 147 * If planes or rowBytes is NULL or if any entry in planes is NULL or if an y entry in rowBytes |
| 118 * is 0, this imagegenerator should output the sizes and return true if it can efficiently | 148 * is 0, this imagegenerator should output the sizes and return true if it can efficiently |
| 119 * return YUV planar data. If it cannot, it should return false. Note that either planes and | 149 * return YUV planar data. If it cannot, it should return false. Note that either planes and |
| 120 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL or have NULL or 0 | 150 * rowBytes are both fully defined and non NULL/non 0 or they are both NULL or have NULL or 0 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 221 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, |
| 192 SkPMColor ctable[], int* ctableCount); | 222 SkPMColor ctable[], int* ctableCount); |
| 193 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); | 223 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); |
| 194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | 224 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], |
| 195 SkYUVColorSpace* colorSpace); | 225 SkYUVColorSpace* colorSpace); |
| 196 | 226 |
| 197 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI Rect*) { | 227 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI Rect*) { |
| 198 return nullptr; | 228 return nullptr; |
| 199 } | 229 } |
| 200 | 230 |
| 231 virtual bool onCanDecodeAndScale(const SkColorType colorType, const SkScalar scale, | |
| 232 SkISize *availableSize, SkISize *lowerSize); | |
| 233 | |
| 201 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); | 234 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); |
| 202 | 235 |
| 203 private: | 236 private: |
| 204 const SkImageInfo fInfo; | 237 const SkImageInfo fInfo; |
| 205 const uint32_t fUniqueID; | 238 const uint32_t fUniqueID; |
| 206 | 239 |
| 207 // This is our default impl, which may be different on different platforms. | 240 // This is our default impl, which may be different on different platforms. |
| 208 // It is called from NewFromEncoded() after it has checked for any runtime f actory. | 241 // It is called from NewFromEncoded() after it has checked for any runtime f actory. |
| 209 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. | 242 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. |
| 210 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 243 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
| 211 }; | 244 }; |
| 212 | 245 |
| 213 #endif // SkImageGenerator_DEFINED | 246 #endif // SkImageGenerator_DEFINED |
| OLD | NEW |