• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, BRDAllocator* allocator,
24                       const SkIRect& desiredSubset, int sampleSize,
25                       SkColorType colorType, bool requireUnpremul,
26                       sk_sp<SkColorSpace> prefColorSpace);
27 
getEncodedFormat()28     SkEncodedImageFormat getEncodedFormat() { return fCodec->getEncodedFormat(); }
29 
computeOutputColorType(SkColorType requestedColorType)30     SkColorType computeOutputColorType(SkColorType requestedColorType) {
31         return fCodec->computeOutputColorType(requestedColorType);
32     }
33 
34     sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
35             sk_sp<SkColorSpace> prefColorSpace = nullptr) {
36         return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
37     }
38 
39     int width() const;
40     int height() const;
41 
42 private:
43     BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec);
44 
45     std::unique_ptr<SkAndroidCodec> fCodec;
46 };
47 
48 } // namespace skia
49 } // namespace android
50 #endif  // BitmapRegionDecoder_DEFINED
51