blob: d1c5131afa8989874fb9e716060da1a97443b7a3 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/codec/SkCodec.h"
12#include "include/core/SkColorSpace.h"
13#include "include/core/SkImageInfo.h"
14#include "include/core/SkTypes.h"
yujieqin916de9f2016-01-25 08:26:16 -080015
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 */
Mike Reedede7bac2017-07-23 15:30:02 -040031 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
yujieqin916de9f2016-01-25 08:26:16 -080032
33 ~SkRawCodec() override;
34
35protected:
36
37 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
Leon Scroggins571b30f2017-07-11 17:35:31 +000038 int*) override;
yujieqin916de9f2016-01-25 08:26:16 -080039
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
Leon Scroggins III96765962018-12-07 14:04:47 -050048 // SkCodec only applies the colorXform if it's necessary for color space
49 // conversion. SkRawCodec will always convert, so tell SkCodec not to.
50 bool usesColorXform() const override { return false; }
51
yujieqin916de9f2016-01-25 08:26:16 -080052private:
53
54 /*
55 * Creates an instance of the decoder
56 * Called only by NewFromStream, takes ownership of dngImage.
57 */
58 SkRawCodec(SkDngImage* dngImage);
59
Ben Wagner145dbcd2016-11-03 14:40:50 -040060 std::unique_ptr<SkDngImage> fDngImage;
yujieqin916de9f2016-01-25 08:26:16 -080061
62 typedef SkCodec INHERITED;
63};
64
65#endif