Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkStubHeifDecoderAPI_DEFINED |
| 9 | #define SkStubHeifDecoderAPI_DEFINED |
| 10 | |
| 11 | // This stub implementation of HeifDecoderAPI.h lets us compile SkHeifCodec.cpp |
| 12 | // even when libheif is not available. It, of course, does nothing and fails to decode. |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <stddef.h> |
| 16 | #include <stdint.h> |
Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 17 | |
| 18 | enum HeifColorFormat { |
| 19 | kHeifColorFormat_RGB565, |
| 20 | kHeifColorFormat_RGBA_8888, |
| 21 | kHeifColorFormat_BGRA_8888, |
| 22 | }; |
| 23 | |
| 24 | struct HeifStream { |
| 25 | virtual ~HeifStream() {} |
| 26 | |
| 27 | virtual size_t read(void*, size_t) = 0; |
| 28 | virtual bool rewind() = 0; |
| 29 | virtual bool seek(size_t) = 0; |
| 30 | virtual bool hasLength() const = 0; |
| 31 | virtual size_t getLength() const = 0; |
| 32 | }; |
| 33 | |
| 34 | struct HeifFrameInfo { |
Leon Scroggins III | 6154ac4 | 2019-08-14 11:29:29 -0400 | [diff] [blame^] | 35 | #ifdef SK_LEGACY_HEIF_API |
Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 36 | int mRotationAngle; |
| 37 | int mWidth; |
| 38 | int mHeight; |
| 39 | int mBytesPerPixel; |
| 40 | |
| 41 | size_t mIccSize; |
| 42 | std::unique_ptr<char[]> mIccData; |
Leon Scroggins III | 6154ac4 | 2019-08-14 11:29:29 -0400 | [diff] [blame^] | 43 | #else |
| 44 | uint32_t mWidth; |
| 45 | uint32_t mHeight; |
| 46 | int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90 |
| 47 | uint32_t mBytesPerPixel; // Number of bytes for one pixel |
| 48 | int64_t mDurationUs; // Duration of the frame in us |
| 49 | std::vector<uint8_t> mIccData; // ICC data array |
| 50 | #endif |
Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct HeifDecoder { |
| 54 | bool init(HeifStream* stream, HeifFrameInfo*) { |
| 55 | delete stream; |
| 56 | return false; |
| 57 | } |
| 58 | |
Leon Scroggins III | 6154ac4 | 2019-08-14 11:29:29 -0400 | [diff] [blame^] | 59 | #ifndef SK_LEGACY_HEIF_API |
| 60 | bool getSequenceInfo(HeifFrameInfo* frameInfo, size_t *frameCount) { |
| 61 | return false; |
| 62 | } |
| 63 | #endif |
| 64 | |
Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 65 | bool decode(HeifFrameInfo*) { |
| 66 | return false; |
| 67 | } |
| 68 | |
Leon Scroggins III | 6154ac4 | 2019-08-14 11:29:29 -0400 | [diff] [blame^] | 69 | #ifndef SK_LEGACY_HEIF_API |
| 70 | bool decodeSequence(int frameIndex, HeifFrameInfo* frameInfo) { |
| 71 | return false; |
| 72 | } |
| 73 | #endif |
| 74 | |
Mike Klein | 36f182f | 2017-10-20 12:33:53 -0400 | [diff] [blame] | 75 | bool setOutputColor(HeifColorFormat) { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | bool getScanline(uint8_t*) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | int skipScanlines(int) { |
| 84 | return 0; |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; } |
| 89 | |
| 90 | #endif//SkStubHeifDecoderAPI_DEFINED |