OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
11 | 11 |
12 class SkCodecImageGenerator : public SkImageGenerator { | 12 class SkCodecImageGenerator : public SkImageGenerator { |
13 public: | 13 public: |
14 /* | 14 /* |
15 * If this data represents an encoded image that we know how to decode, | 15 * If this data represents an encoded image that we know how to decode, |
16 * return an SkCodecImageGenerator. Otherwise return nullptr. | 16 * return an SkCodecImageGenerator. Otherwise return nullptr. |
17 * | 17 * |
18 * Refs the data if an image generator can be returned. Otherwise does | 18 * Refs the data if an image generator can be returned. Otherwise does |
19 * not affect the data. | 19 * not affect the data. |
20 */ | 20 */ |
21 static SkImageGenerator* NewFromEncodedCodec(SkData* data); | 21 static SkImageGenerator* NewFromEncodedCodec(SkData* data); |
22 | 22 |
23 protected: | 23 protected: |
24 SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override; | 24 SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override; |
25 | 25 |
26 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP
MColor ctable[], | 26 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP
MColor ctable[], |
27 int* ctableCount) override; | 27 int* ctableCount) override; |
28 | 28 |
29 bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const override; | 29 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
30 | 30 SkYUVColorSpace* colorSpace) override; |
31 bool onGetYUV8Planes(const SkYUVSizeInfo&, void* planes[3]) override; | |
32 | 31 |
33 private: | 32 private: |
34 /* | 33 /* |
35 * Takes ownership of codec | 34 * Takes ownership of codec |
36 * Refs the data | 35 * Refs the data |
37 */ | 36 */ |
38 SkCodecImageGenerator(SkCodec* codec, SkData* data); | 37 SkCodecImageGenerator(SkCodec* codec, SkData* data); |
39 | 38 |
40 SkAutoTDelete<SkCodec> fCodec; | 39 SkAutoTDelete<SkCodec> fCodec; |
41 SkAutoTUnref<SkData> fData; | 40 SkAutoTUnref<SkData> fData; |
42 | 41 |
| 42 // FIXME: These fields are necessary only until we change the API of SkImage
Generator |
| 43 // to match SkCodec. Once the API is changed, they should be removed
. |
| 44 int fYWidth; |
| 45 int fUWidth; |
| 46 int fVWidth; |
| 47 |
43 typedef SkImageGenerator INHERITED; | 48 typedef SkImageGenerator INHERITED; |
44 }; | 49 }; |
OLD | NEW |