SkRawCodec.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2016 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 SkRawCodec_DEFINED
  8. #define SkRawCodec_DEFINED
  9. #include "include/codec/SkCodec.h"
  10. #include "include/core/SkColorSpace.h"
  11. #include "include/core/SkImageInfo.h"
  12. #include "include/core/SkTypes.h"
  13. class SkDngImage;
  14. class SkStream;
  15. /*
  16. *
  17. * This class implements the decoding for RAW images
  18. *
  19. */
  20. class SkRawCodec : public SkCodec {
  21. public:
  22. /*
  23. * Creates a RAW decoder
  24. * Takes ownership of the stream
  25. */
  26. static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
  27. ~SkRawCodec() override;
  28. protected:
  29. Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
  30. int*) override;
  31. SkEncodedImageFormat onGetEncodedFormat() const override {
  32. return SkEncodedImageFormat::kDNG;
  33. }
  34. SkISize onGetScaledDimensions(float desiredScale) const override;
  35. bool onDimensionsSupported(const SkISize&) override;
  36. // SkCodec only applies the colorXform if it's necessary for color space
  37. // conversion. SkRawCodec will always convert, so tell SkCodec not to.
  38. bool usesColorXform() const override { return false; }
  39. private:
  40. /*
  41. * Creates an instance of the decoder
  42. * Called only by NewFromStream, takes ownership of dngImage.
  43. */
  44. SkRawCodec(SkDngImage* dngImage);
  45. std::unique_ptr<SkDngImage> fDngImage;
  46. typedef SkCodec INHERITED;
  47. };
  48. #endif