| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkCodec_DEFINED | 8 #ifndef SkCodec_DEFINED |
| 9 #define SkCodec_DEFINED | 9 #define SkCodec_DEFINED |
| 10 | 10 |
| 11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkEncodedFormat.h" | 13 #include "SkEncodedFormat.h" |
| 14 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
| 15 #include "SkSize.h" | 15 #include "SkSize.h" |
| 16 #include "SkStream.h" | 16 #include "SkStream.h" |
| 17 #include "SkTypes.h" | 17 #include "SkTypes.h" |
| 18 #include "SkYUVSizeInfo.h" |
| 18 | 19 |
| 19 class SkData; | 20 class SkData; |
| 20 class SkPngChunkReader; | 21 class SkPngChunkReader; |
| 21 class SkSampler; | 22 class SkSampler; |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Abstraction layer directly on top of an image codec. | 25 * Abstraction layer directly on top of an image codec. |
| 25 */ | 26 */ |
| 26 class SkCodec : SkNoncopyable { | 27 class SkCodec : SkNoncopyable { |
| 27 public: | 28 public: |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 */ | 271 */ |
| 271 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con
st Options*, | 272 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con
st Options*, |
| 272 SkPMColor ctable[], int* ctableCount); | 273 SkPMColor ctable[], int* ctableCount); |
| 273 | 274 |
| 274 /** | 275 /** |
| 275 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType and | 276 * Simplified version of getPixels() that asserts that info is NOT kIndex8_
SkColorType and |
| 276 * uses the default Options. | 277 * uses the default Options. |
| 277 */ | 278 */ |
| 278 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 279 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
| 279 | 280 |
| 280 struct YUVSizeInfo { | |
| 281 SkISize fYSize; | |
| 282 SkISize fUSize; | |
| 283 SkISize fVSize; | |
| 284 | |
| 285 /** | |
| 286 * While the widths of the Y, U, and V planes are not restricted, the | |
| 287 * implementation requires that the width of the memory allocated for | |
| 288 * each plane be a multiple of DCTSIZE (which is always 8). | |
| 289 * | |
| 290 * This struct allows us to inform the client how many "widthBytes" | |
| 291 * that we need. Note that we use the new idea of "widthBytes" | |
| 292 * because this idea is distinct from "rowBytes" (used elsewhere in | |
| 293 * Skia). "rowBytes" allow the last row of the allocation to not | |
| 294 * include any extra padding, while, in this case, every single row of | |
| 295 * the allocation must be at least "widthBytes". | |
| 296 */ | |
| 297 size_t fYWidthBytes; | |
| 298 size_t fUWidthBytes; | |
| 299 size_t fVWidthBytes; | |
| 300 }; | |
| 301 | |
| 302 /** | 281 /** |
| 303 * If decoding to YUV is supported, this returns true. Otherwise, this | 282 * If decoding to YUV is supported, this returns true. Otherwise, this |
| 304 * returns false and does not modify any of the parameters. | 283 * returns false and does not modify any of the parameters. |
| 305 * | 284 * |
| 306 * @param sizeInfo Output parameter indicating the sizes and required | 285 * @param sizeInfo Output parameter indicating the sizes and required |
| 307 * allocation widths of the Y, U, and V planes. | 286 * allocation widths of the Y, U, and V planes. |
| 308 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG, | 287 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG, |
| 309 * otherwise this is ignored. | 288 * otherwise this is ignored. |
| 310 */ | 289 */ |
| 311 bool queryYUV8(YUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { | 290 bool queryYUV8(YUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 * not affect ownership. | 664 * not affect ownership. |
| 686 * | 665 * |
| 687 * Only valid during scanline decoding. | 666 * Only valid during scanline decoding. |
| 688 */ | 667 */ |
| 689 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} | 668 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} |
| 690 | 669 |
| 691 friend class SkSampledCodec; | 670 friend class SkSampledCodec; |
| 692 friend class SkIcoCodec; | 671 friend class SkIcoCodec; |
| 693 }; | 672 }; |
| 694 #endif // SkCodec_DEFINED | 673 #endif // SkCodec_DEFINED |
| OLD | NEW |