blob: b3b06374326a2f7c73556ac62a5aa5ec89a725b7 [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
msarett26ad17b2015-10-22 07:29:19 -070011#include "SkBitmap.h"
msarett5cb48852015-11-06 08:56:32 -080012#include "SkBitmapRegionDecoder.h"
msarett26ad17b2015-10-22 07:29:19 -070013#include "SkAndroidCodec.h"
14
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,
28 SkColorType colorType, bool requireUnpremul) override;
msarett26ad17b2015-10-22 07:29:19 -070029
30 bool conversionSupported(SkColorType colorType) override;
31
Hal Canary1fcc4042016-11-30 17:07:59 -050032 SkEncodedImageFormat getEncodedFormat() override { return fCodec->getEncodedFormat(); }
msarett3f65e932015-10-27 13:12:59 -070033
msarett26ad17b2015-10-22 07:29:19 -070034private:
35
Ben Wagner145dbcd2016-11-03 14:40:50 -040036 std::unique_ptr<SkAndroidCodec> fCodec;
msarett26ad17b2015-10-22 07:29:19 -070037
msarett5cb48852015-11-06 08:56:32 -080038 typedef SkBitmapRegionDecoder INHERITED;
msarett26ad17b2015-10-22 07:29:19 -070039
40};
Hal Canary03a7f5f2017-02-10 09:06:38 -050041#endif // SkBitmapRegionCodec_DEFINED