SkStubHeifDecoderAPI.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef SkStubHeifDecoderAPI_DEFINED
  8. #define SkStubHeifDecoderAPI_DEFINED
  9. // This stub implementation of HeifDecoderAPI.h lets us compile SkHeifCodec.cpp
  10. // even when libheif is not available. It, of course, does nothing and fails to decode.
  11. #include <memory>
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. enum HeifColorFormat {
  15. kHeifColorFormat_RGB565,
  16. kHeifColorFormat_RGBA_8888,
  17. kHeifColorFormat_BGRA_8888,
  18. };
  19. struct HeifStream {
  20. virtual ~HeifStream() {}
  21. virtual size_t read(void*, size_t) = 0;
  22. virtual bool rewind() = 0;
  23. virtual bool seek(size_t) = 0;
  24. virtual bool hasLength() const = 0;
  25. virtual size_t getLength() const = 0;
  26. };
  27. struct HeifFrameInfo {
  28. int mRotationAngle;
  29. int mWidth;
  30. int mHeight;
  31. int mBytesPerPixel;
  32. size_t mIccSize;
  33. std::unique_ptr<char[]> mIccData;
  34. };
  35. struct HeifDecoder {
  36. bool init(HeifStream* stream, HeifFrameInfo*) {
  37. delete stream;
  38. return false;
  39. }
  40. bool decode(HeifFrameInfo*) {
  41. return false;
  42. }
  43. bool setOutputColor(HeifColorFormat) {
  44. return false;
  45. }
  46. bool getScanline(uint8_t*) {
  47. return false;
  48. }
  49. int skipScanlines(int) {
  50. return 0;
  51. }
  52. };
  53. static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; }
  54. #endif//SkStubHeifDecoderAPI_DEFINED