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 8 #ifndef BitmapRegionDecoder_DEFINED 9 #define BitmapRegionDecoder_DEFINED 10 11 #include "client_utils/android/BRDAllocator.h" 12 #include "include/codec/SkAndroidCodec.h" 13 #include "include/core/SkBitmap.h" 14 #include "include/core/SkData.h" 15 16 namespace android { 17 namespace skia { 18 19 class BitmapRegionDecoder final { 20 public: 21 static std::unique_ptr<BitmapRegionDecoder> Make(sk_sp<SkData> data); 22 23 bool decodeRegion(SkBitmap* bitmap, 24 BRDAllocator* allocator, 25 const SkIRect& desiredSubset, 26 int sampleSize, 27 SkColorType colorType, 28 bool requireUnpremul, 29 sk_sp<SkColorSpace> prefColorSpace); 30 getEncodedFormat()31 SkEncodedImageFormat getEncodedFormat() { return fCodec->getEncodedFormat(); } 32 computeOutputColorType(SkColorType requestedColorType)33 SkColorType computeOutputColorType(SkColorType requestedColorType) { 34 return fCodec->computeOutputColorType(requestedColorType); 35 } 36 37 sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType, 38 sk_sp<SkColorSpace> prefColorSpace = nullptr) { 39 return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace); 40 } 41 42 int width() const; 43 int height() const; 44 getAndroidGainmap(SkGainmapInfo * outInfo,std::unique_ptr<SkStream> * outGainmapImageStream)45 bool getAndroidGainmap(SkGainmapInfo* outInfo, 46 std::unique_ptr<SkStream>* outGainmapImageStream) { 47 return fCodec->getAndroidGainmap(outInfo, outGainmapImageStream); 48 } 49 50 private: 51 BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec); 52 53 std::unique_ptr<SkAndroidCodec> fCodec; 54 }; 55 56 } // namespace skia 57 } // namespace android 58 #endif // BitmapRegionDecoder_DEFINED 59