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 | */ |
| 7 | |
| 8 | #include "SkCodec.h" |
| 9 | #include "SkData.h" |
| 10 | #include "SkImageGenerator.h" |
| 11 | |
| 12 | class SkCodecImageGenerator : public SkImageGenerator { |
| 13 | public: |
| 14 | /* |
| 15 | * If this data represents an encoded image that we know how to decode, |
| 16 | * return an SkCodecImageGenerator. Otherwise return nullptr. |
| 17 | * |
| 18 | * Refs the data if an image generator can be returned. Otherwise does |
| 19 | * not affect the data. |
| 20 | */ |
| 21 | static SkImageGenerator* NewFromEncodedCodec(SkData* data); |
| 22 | |
| 23 | protected: |
| 24 | SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override; |
| 25 | |
| 26 | bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[], |
| 27 | int* ctableCount) override; |
| 28 | |
msarett | 1590f3b | 2016-03-07 09:16:52 -0800 | [diff] [blame] | 29 | bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
| 30 | SkYUVColorSpace* colorSpace) override; |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 31 | |
| 32 | private: |
| 33 | /* |
| 34 | * Takes ownership of codec |
| 35 | * Refs the data |
| 36 | */ |
| 37 | SkCodecImageGenerator(SkCodec* codec, SkData* data); |
| 38 | |
| 39 | SkAutoTDelete<SkCodec> fCodec; |
| 40 | SkAutoTUnref<SkData> fData; |
| 41 | |
msarett | 1590f3b | 2016-03-07 09:16:52 -0800 | [diff] [blame] | 42 | // FIXME: These fields are necessary only until we change the API of SkImageGenerator |
| 43 | // to match SkCodec. Once the API is changed, they should be removed. |
| 44 | int fYWidth; |
| 45 | int fUWidth; |
| 46 | int fVWidth; |
| 47 | |
msarett | edd2dcf | 2016-01-14 13:12:26 -0800 | [diff] [blame] | 48 | typedef SkImageGenerator INHERITED; |
| 49 | }; |