SkBitmapRegionCodec.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 SkBitmapRegionCodec_DEFINED
  8. #define SkBitmapRegionCodec_DEFINED
  9. #include "include/android/SkBitmapRegionDecoder.h"
  10. #include "include/codec/SkAndroidCodec.h"
  11. #include "include/core/SkBitmap.h"
  12. /*
  13. * This class implements SkBitmapRegionDecoder using an SkAndroidCodec.
  14. */
  15. class SkBitmapRegionCodec : public SkBitmapRegionDecoder {
  16. public:
  17. /*
  18. * Takes ownership of pointer to codec
  19. */
  20. SkBitmapRegionCodec(SkAndroidCodec* codec);
  21. bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
  22. const SkIRect& desiredSubset, int sampleSize,
  23. SkColorType colorType, bool requireUnpremul,
  24. sk_sp<SkColorSpace> prefColorSpace) override;
  25. SkEncodedImageFormat getEncodedFormat() override { return fCodec->getEncodedFormat(); }
  26. SkColorType computeOutputColorType(SkColorType requestedColorType) override {
  27. return fCodec->computeOutputColorType(requestedColorType);
  28. }
  29. sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
  30. sk_sp<SkColorSpace> prefColorSpace = nullptr) override {
  31. return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
  32. }
  33. private:
  34. std::unique_ptr<SkAndroidCodec> fCodec;
  35. typedef SkBitmapRegionDecoder INHERITED;
  36. };
  37. #endif // SkBitmapRegionCodec_DEFINED