msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
Hal Canary | 03a7f5f | 2017-02-10 09:06:38 -0500 | [diff] [blame] | 7 | #ifndef SkCodecImageGenerator_DEFINED |
| 8 | #define SkCodecImageGenerator_DEFINED |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 9 | |
| 10 | #include "SkCodec.h" |
Leon Scroggins III | 20a7ecc | 2016-12-19 15:04:06 -0500 | [diff] [blame] | 11 | #include "SkColorTable.h" |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 12 | #include "SkData.h" |
| 13 | #include "SkImageGenerator.h" |
| 14 | |
| 15 | class SkCodecImageGenerator : public SkImageGenerator { |
| 16 | public: |
| 17 | /* |
| 18 | * If this data represents an encoded image that we know how to decode, |
| 19 | * return an SkCodecImageGenerator. Otherwise return nullptr. |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 20 | */ |
Mike Reed | 185130c | 2017-02-15 15:14:16 -0500 | [diff] [blame] | 21 | static std::unique_ptr<SkImageGenerator> MakeFromEncodedCodec(sk_sp<SkData>); |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 22 | |
| 23 | protected: |
Brian Osman | 2feb796 | 2017-04-25 16:41:47 -0400 | [diff] [blame] | 24 | SkData* onRefEncodedData() override; |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 25 | |
Matt Sarett | d531ca0 | 2017-03-24 16:31:19 -0400 | [diff] [blame] | 26 | bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) |
| 27 | override; |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 28 | |
msarett | 4984c3c | 2016-03-10 05:44:43 -0800 | [diff] [blame] | 29 | bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; |
| 30 | |
| 31 | bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 32 | |
| 33 | private: |
| 34 | /* |
| 35 | * Takes ownership of codec |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 36 | */ |
reed | 42943c8 | 2016-09-12 12:01:44 -0700 | [diff] [blame] | 37 | SkCodecImageGenerator(SkCodec* codec, sk_sp<SkData>); |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 38 | |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 39 | std::unique_ptr<SkCodec> fCodec; |
bungeman | ffae30d | 2016-08-03 13:32:32 -0700 | [diff] [blame] | 40 | sk_sp<SkData> fData; |
Leon Scroggins III | 20a7ecc | 2016-12-19 15:04:06 -0500 | [diff] [blame] | 41 | sk_sp<SkColorTable> fColorTable; |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 42 | |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 43 | typedef SkImageGenerator INHERITED; |
| 44 | }; |
Hal Canary | 03a7f5f | 2017-02-10 09:06:38 -0500 | [diff] [blame] | 45 | #endif // SkCodecImageGenerator_DEFINED |