yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 1 | /* |
| 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" |
msarett | ad8bcfe | 2016-03-07 07:09:03 -0800 | [diff] [blame] | 12 | #include "SkColorSpace.h" |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 13 | #include "SkImageInfo.h" |
| 14 | #include "SkTypes.h" |
| 15 | |
| 16 | class SkDngImage; |
| 17 | class SkStream; |
| 18 | |
| 19 | /* |
| 20 | * |
| 21 | * This class implements the decoding for RAW images |
| 22 | * |
| 23 | */ |
| 24 | class SkRawCodec : public SkCodec { |
| 25 | public: |
| 26 | |
| 27 | /* |
| 28 | * Creates a RAW decoder |
| 29 | * Takes ownership of the stream |
| 30 | */ |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 31 | static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*); |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 32 | |
| 33 | ~SkRawCodec() override; |
| 34 | |
| 35 | protected: |
| 36 | |
| 37 | Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&, |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 38 | int*) override; |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 39 | |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 40 | SkEncodedImageFormat onGetEncodedFormat() const override { |
| 41 | return SkEncodedImageFormat::kDNG; |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | SkISize onGetScaledDimensions(float desiredScale) const override; |
| 45 | |
| 46 | bool onDimensionsSupported(const SkISize&) override; |
| 47 | |
Leon Scroggins III | 9676596 | 2018-12-07 14:04:47 -0500 | [diff] [blame] | 48 | // 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 | |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 52 | private: |
| 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 Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 60 | std::unique_ptr<SkDngImage> fDngImage; |
yujieqin | 916de9f | 2016-01-25 08:26:16 -0800 | [diff] [blame] | 61 | |
| 62 | typedef SkCodec INHERITED; |
| 63 | }; |
| 64 | |
| 65 | #endif |