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