blob: 51bb234b7339c36a3008cbd7b95ca1a0a6766d21 [file] [log] [blame]
yujieqin916de9f2016-01-25 08:26:16 -08001/*
2 * Copyright 2016 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 SkRawCodec_DEFINED
9#define SkRawCodec_DEFINED
10
11#include "SkCodec.h"
msarettad8bcfe2016-03-07 07:09:03 -080012#include "SkColorSpace.h"
yujieqin916de9f2016-01-25 08:26:16 -080013#include "SkImageInfo.h"
14#include "SkTypes.h"
15
16class SkDngImage;
17class SkStream;
18
19/*
20 *
21 * This class implements the decoding for RAW images
22 *
23 */
24class SkRawCodec : public SkCodec {
25public:
26
27 /*
28 * Creates a RAW decoder
29 * Takes ownership of the stream
30 */
31 static SkCodec* NewFromStream(SkStream*);
32
33 ~SkRawCodec() override;
34
35protected:
36
37 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
38 SkPMColor*, int*, int*) override;
39
Hal Canarydb683012016-11-23 08:55:18 -070040 SkEncodedImageFormat onGetEncodedFormat() const override {
41 return SkEncodedImageFormat::kDNG;
yujieqin916de9f2016-01-25 08:26:16 -080042 }
43
44 SkISize onGetScaledDimensions(float desiredScale) const override;
45
46 bool onDimensionsSupported(const SkISize&) override;
47
48private:
49
50 /*
51 * Creates an instance of the decoder
52 * Called only by NewFromStream, takes ownership of dngImage.
53 */
54 SkRawCodec(SkDngImage* dngImage);
55
Ben Wagner145dbcd2016-11-03 14:40:50 -040056 std::unique_ptr<SkDngImage> fDngImage;
yujieqin916de9f2016-01-25 08:26:16 -080057
58 typedef SkCodec INHERITED;
59};
60
61#endif