SkJpegDecoderMgr.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2015 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 SkJpegDecoderMgr_DEFINED
  8. #define SkJpegDecoderMgr_DEFINED
  9. #include "include/codec/SkCodec.h"
  10. #include "src/codec/SkCodecPriv.h"
  11. #include <stdio.h>
  12. #include "src/codec/SkJpegUtility.h"
  13. extern "C" {
  14. #include "jpeglib.h"
  15. }
  16. class JpegDecoderMgr : SkNoncopyable {
  17. public:
  18. /*
  19. * Print a useful error message and return false
  20. */
  21. bool returnFalse(const char caller[]);
  22. /*
  23. * Print a useful error message and return a decode failure
  24. */
  25. SkCodec::Result returnFailure(const char caller[], SkCodec::Result result);
  26. /*
  27. * Create the decode manager
  28. * Does not take ownership of stream
  29. */
  30. JpegDecoderMgr(SkStream* stream);
  31. /*
  32. * Initialize decompress struct
  33. * Initialize the source manager
  34. */
  35. void init();
  36. /*
  37. * Returns true if it successfully sets outColor to the encoded color,
  38. * and false otherwise.
  39. */
  40. bool getEncodedColor(SkEncodedInfo::Color* outColor);
  41. /*
  42. * Free memory used by the decode manager
  43. */
  44. ~JpegDecoderMgr();
  45. /*
  46. * Get the skjpeg_error_mgr in order to set an error return jmp_buf
  47. */
  48. skjpeg_error_mgr* errorMgr() { return &fErrorMgr; }
  49. /*
  50. * Get function for the decompress info struct
  51. */
  52. jpeg_decompress_struct* dinfo() { return &fDInfo; }
  53. private:
  54. jpeg_decompress_struct fDInfo;
  55. skjpeg_source_mgr fSrcMgr;
  56. skjpeg_error_mgr fErrorMgr;
  57. jpeg_progress_mgr fProgressMgr;
  58. bool fInit;
  59. };
  60. #endif