SkBmpMaskCodec.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 SkBmpMaskCodec_DEFINED
  8. #define SkBmpMaskCodec_DEFINED
  9. #include "include/core/SkImageInfo.h"
  10. #include "include/core/SkTypes.h"
  11. #include "src/codec/SkBmpBaseCodec.h"
  12. #include "src/codec/SkMaskSwizzler.h"
  13. /*
  14. * This class implements the decoding for bmp images using bit masks
  15. */
  16. class SkBmpMaskCodec : public SkBmpBaseCodec {
  17. public:
  18. /*
  19. * Creates an instance of the decoder
  20. *
  21. * Called only by SkBmpCodec::MakeFromStream
  22. * There should be no other callers despite this being public
  23. *
  24. * @param info contains properties of the encoded data
  25. * @param stream the stream of encoded image data
  26. * @param bitsPerPixel the number of bits used to store each pixel
  27. * @param masks color masks for certain bmp formats
  28. * @param rowOrder indicates whether rows are ordered top-down or bottom-up
  29. */
  30. SkBmpMaskCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream>,
  31. uint16_t bitsPerPixel, SkMasks* masks,
  32. SkCodec::SkScanlineOrder rowOrder);
  33. protected:
  34. Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
  35. size_t dstRowBytes, const Options&,
  36. int*) override;
  37. SkCodec::Result onPrepareToDecode(const SkImageInfo& dstInfo,
  38. const SkCodec::Options& options) override;
  39. private:
  40. SkSampler* getSampler(bool createIfNecessary) override {
  41. SkASSERT(fMaskSwizzler);
  42. return fMaskSwizzler.get();
  43. }
  44. int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
  45. const Options& opts) override;
  46. std::unique_ptr<SkMasks> fMasks;
  47. std::unique_ptr<SkMaskSwizzler> fMaskSwizzler;
  48. typedef SkBmpBaseCodec INHERITED;
  49. };
  50. #endif // SkBmpMaskCodec_DEFINED