blob: 4f936090b031490cce4064f8ffdbfaf937f4394c [file] [log] [blame]
Mike Klein36f182f2017-10-20 12:33:53 -04001/*
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 Klein36f182f2017-10-20 12:33:53 -040017
18enum HeifColorFormat {
19 kHeifColorFormat_RGB565,
20 kHeifColorFormat_RGBA_8888,
21 kHeifColorFormat_BGRA_8888,
22};
23
24struct 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
34struct HeifFrameInfo {
Leon Scroggins III6154ac42019-08-14 11:29:29 -040035#ifdef SK_LEGACY_HEIF_API
Mike Klein36f182f2017-10-20 12:33:53 -040036 int mRotationAngle;
37 int mWidth;
38 int mHeight;
39 int mBytesPerPixel;
40
41 size_t mIccSize;
42 std::unique_ptr<char[]> mIccData;
Leon Scroggins III6154ac42019-08-14 11:29:29 -040043#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 Klein36f182f2017-10-20 12:33:53 -040051};
52
53struct HeifDecoder {
54 bool init(HeifStream* stream, HeifFrameInfo*) {
55 delete stream;
56 return false;
57 }
58
Leon Scroggins III6154ac42019-08-14 11:29:29 -040059#ifndef SK_LEGACY_HEIF_API
60 bool getSequenceInfo(HeifFrameInfo* frameInfo, size_t *frameCount) {
61 return false;
62 }
63#endif
64
Mike Klein36f182f2017-10-20 12:33:53 -040065 bool decode(HeifFrameInfo*) {
66 return false;
67 }
68
Leon Scroggins III6154ac42019-08-14 11:29:29 -040069#ifndef SK_LEGACY_HEIF_API
70 bool decodeSequence(int frameIndex, HeifFrameInfo* frameInfo) {
71 return false;
72 }
73#endif
74
Mike Klein36f182f2017-10-20 12:33:53 -040075 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
88static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; }
89
90#endif//SkStubHeifDecoderAPI_DEFINED