• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef SK_LEGACY_HEIF_API
36     int mRotationAngle;
37     int mWidth;
38     int mHeight;
39     int mBytesPerPixel;
40 
41     size_t                  mIccSize;
42     std::unique_ptr<char[]> mIccData;
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
51 };
52 
53 struct HeifDecoder {
initHeifDecoder54     bool init(HeifStream* stream, HeifFrameInfo*) {
55         delete stream;
56         return false;
57     }
58 
59 #ifndef SK_LEGACY_HEIF_API
getSequenceInfoHeifDecoder60     bool getSequenceInfo(HeifFrameInfo* frameInfo, size_t *frameCount) {
61         return false;
62     }
63 #endif
64 
decodeHeifDecoder65     bool decode(HeifFrameInfo*) {
66         return false;
67     }
68 
69 #ifndef SK_LEGACY_HEIF_API
decodeSequenceHeifDecoder70     bool decodeSequence(int frameIndex, HeifFrameInfo* frameInfo) {
71         return false;
72     }
73 #endif
74 
setOutputColorHeifDecoder75     bool setOutputColor(HeifColorFormat) {
76         return false;
77     }
78 
getScanlineHeifDecoder79     bool getScanline(uint8_t*) {
80         return false;
81     }
82 
skipScanlinesHeifDecoder83     int skipScanlines(int) {
84         return 0;
85     }
86 };
87 
createHeifDecoder()88 static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; }
89 
90 #endif//SkStubHeifDecoderAPI_DEFINED
91