blob: 21859514af9285831506c953d591c1c2d7d932e5 [file] [log] [blame]
msarett26ad17b2015-10-22 07:29:19 -07001/*
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
Hal Canary03a7f5f2017-02-10 09:06:38 -05008#ifndef SkBitmapRegionCodec_DEFINED
9#define SkBitmapRegionCodec_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/android/SkBitmapRegionDecoder.h"
12#include "include/codec/SkAndroidCodec.h"
13#include "include/core/SkBitmap.h"
msarett26ad17b2015-10-22 07:29:19 -070014
15/*
16 * This class implements SkBitmapRegionDecoder using an SkAndroidCodec.
17 */
msarett5cb48852015-11-06 08:56:32 -080018class SkBitmapRegionCodec : public SkBitmapRegionDecoder {
msarett26ad17b2015-10-22 07:29:19 -070019public:
20
21 /*
22 * Takes ownership of pointer to codec
23 */
24 SkBitmapRegionCodec(SkAndroidCodec* codec);
25
msarettcb8d7192015-11-11 13:30:43 -080026 bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
msarett35e5d1b2015-10-27 12:50:25 -070027 const SkIRect& desiredSubset, int sampleSize,
Matt Sarett68feef42017-04-11 09:51:32 -040028 SkColorType colorType, bool requireUnpremul,
29 sk_sp<SkColorSpace> prefColorSpace) override;
msarett26ad17b2015-10-22 07:29:19 -070030
Hal Canary1fcc4042016-11-30 17:07:59 -050031 SkEncodedImageFormat getEncodedFormat() override { return fCodec->getEncodedFormat(); }
msarett3f65e932015-10-27 13:12:59 -070032
Matt Sarett479366c2017-04-14 09:23:45 -040033 SkColorType computeOutputColorType(SkColorType requestedColorType) override {
34 return fCodec->computeOutputColorType(requestedColorType);
35 }
36
37 sk_sp<SkColorSpace> computeOutputColorSpace(SkColorType outputColorType,
38 sk_sp<SkColorSpace> prefColorSpace = nullptr) override {
39 return fCodec->computeOutputColorSpace(outputColorType, prefColorSpace);
40 }
41
msarett26ad17b2015-10-22 07:29:19 -070042private:
43
Ben Wagner145dbcd2016-11-03 14:40:50 -040044 std::unique_ptr<SkAndroidCodec> fCodec;
msarett26ad17b2015-10-22 07:29:19 -070045
msarett5cb48852015-11-06 08:56:32 -080046 typedef SkBitmapRegionDecoder INHERITED;
msarett26ad17b2015-10-22 07:29:19 -070047
48};
Hal Canary03a7f5f2017-02-10 09:06:38 -050049#endif // SkBitmapRegionCodec_DEFINED