OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkData.h" | 8 #include "SkData.h" |
9 #include "SkDecodingImageGenerator.h" | 9 #include "SkDecodingImageGenerator.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const int fSampleSize; | 30 const int fSampleSize; |
31 const bool fDitherImage; | 31 const bool fDitherImage; |
32 | 32 |
33 DecodingImageGenerator(SkData* data, | 33 DecodingImageGenerator(SkData* data, |
34 SkStreamRewindable* stream, | 34 SkStreamRewindable* stream, |
35 const SkImageInfo& info, | 35 const SkImageInfo& info, |
36 int sampleSize, | 36 int sampleSize, |
37 bool ditherImage); | 37 bool ditherImage); |
38 | 38 |
39 protected: | 39 protected: |
40 SkData* onRefEncodedData() override; | 40 SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override; |
41 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, | 41 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
42 SkPMColor ctable[], int* ctableCount) override; | 42 SkPMColor ctable[], int* ctableCount) override; |
43 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], | 43 bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], |
44 SkYUVColorSpace* colorSpace) override; | 44 SkYUVColorSpace* colorSpace) override; |
45 | 45 |
46 private: | 46 private: |
47 typedef SkImageGenerator INHERITED; | 47 typedef SkImageGenerator INHERITED; |
48 }; | 48 }; |
49 | 49 |
50 /** | 50 /** |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 , fDitherImage(ditherImage) | 119 , fDitherImage(ditherImage) |
120 { | 120 { |
121 SkASSERT(stream != nullptr); | 121 SkASSERT(stream != nullptr); |
122 SkSafeRef(fData); // may be nullptr. | 122 SkSafeRef(fData); // may be nullptr. |
123 } | 123 } |
124 | 124 |
125 DecodingImageGenerator::~DecodingImageGenerator() { | 125 DecodingImageGenerator::~DecodingImageGenerator() { |
126 SkSafeUnref(fData); | 126 SkSafeUnref(fData); |
127 } | 127 } |
128 | 128 |
129 SkData* DecodingImageGenerator::onRefEncodedData() { | 129 SkData* DecodingImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) { |
130 // This functionality is used in `gm --serialize` | 130 // This functionality is used in `gm --serialize` |
131 // Does not encode options. | 131 // Does not encode options. |
132 if (nullptr == fData) { | 132 if (nullptr == fData) { |
133 // TODO(halcanary): SkStreamRewindable needs a refData() function | 133 // TODO(halcanary): SkStreamRewindable needs a refData() function |
134 // which returns a cheap copy of the underlying data. | 134 // which returns a cheap copy of the underlying data. |
135 if (!fStream->rewind()) { | 135 if (!fStream->rewind()) { |
136 return nullptr; | 136 return nullptr; |
137 } | 137 } |
138 size_t length = fStream->getLength(); | 138 size_t length = fStream->getLength(); |
139 if (length) { | 139 if (length) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 SkImageGenerator* SkDecodingImageGenerator::Create( | 280 SkImageGenerator* SkDecodingImageGenerator::Create( |
281 SkStreamRewindable* stream, | 281 SkStreamRewindable* stream, |
282 const SkDecodingImageGenerator::Options& opts) { | 282 const SkDecodingImageGenerator::Options& opts) { |
283 SkASSERT(stream != nullptr); | 283 SkASSERT(stream != nullptr); |
284 if (stream == nullptr) { | 284 if (stream == nullptr) { |
285 return nullptr; | 285 return nullptr; |
286 } | 286 } |
287 return CreateDecodingImageGenerator(nullptr, stream, opts); | 287 return CreateDecodingImageGenerator(nullptr, stream, opts); |
288 } | 288 } |
OLD | NEW |