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>
17 
18 enum HeifColorFormat {
19     kHeifColorFormat_RGB565,
20     kHeifColorFormat_RGBA_8888,
21     kHeifColorFormat_BGRA_8888,
22 };
23 
24 struct HeifStream {
~HeifStreamHeifStream25     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 {
35     int mRotationAngle;
36     int mWidth;
37     int mHeight;
38     int mBytesPerPixel;
39 
40     size_t                  mIccSize;
41     std::unique_ptr<char[]> mIccData;
42 };
43 
44 struct HeifDecoder {
initHeifDecoder45     bool init(HeifStream* stream, HeifFrameInfo*) {
46         delete stream;
47         return false;
48     }
49 
decodeHeifDecoder50     bool decode(HeifFrameInfo*) {
51         return false;
52     }
53 
setOutputColorHeifDecoder54     bool setOutputColor(HeifColorFormat) {
55         return false;
56     }
57 
getScanlineHeifDecoder58     bool getScanline(uint8_t*) {
59         return false;
60     }
61 
skipScanlinesHeifDecoder62     int skipScanlines(int) {
63         return 0;
64     }
65 };
66 
createHeifDecoder()67 static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; }
68 
69 #endif//SkStubHeifDecoderAPI_DEFINED
70