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 24 matching lines...) Expand all Loading... |
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() SK_OVERRIDE; | 40 SkData* onRefEncodedData() SK_OVERRIDE; |
41 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 41 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
42 *info = fInfo; | 42 *info = fInfo; |
43 return true; | 43 return true; |
44 } | 44 } |
45 virtual Result onGetPixelsEnum(const SkImageInfo& info, | 45 virtual Result onGetPixels(const SkImageInfo& info, |
46 void* pixels, size_t rowBytes, | 46 void* pixels, size_t rowBytes, |
47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE; | 47 SkPMColor ctable[], int* ctableCount) SK_OVERRIDE
; |
48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 48 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
49 SkYUVColorSpace* colorSpace) SK_OVERRIDE; | 49 SkYUVColorSpace* colorSpace) SK_OVERRIDE; |
50 | 50 |
51 private: | 51 private: |
52 typedef SkImageGenerator INHERITED; | 52 typedef SkImageGenerator INHERITED; |
53 }; | 53 }; |
54 | 54 |
55 /** | 55 /** |
56 * Special allocator used by getPixels(). Uses preallocated memory | 56 * Special allocator used by getPixels(). Uses preallocated memory |
57 * provided if possible, else fall-back on the default allocator | 57 * provided if possible, else fall-back on the default allocator |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return NULL; | 140 return NULL; |
141 } | 141 } |
142 size_t length = fStream->getLength(); | 142 size_t length = fStream->getLength(); |
143 if (length) { | 143 if (length) { |
144 fData = SkData::NewFromStream(fStream, length); | 144 fData = SkData::NewFromStream(fStream, length); |
145 } | 145 } |
146 } | 146 } |
147 return SkSafeRef(fData); | 147 return SkSafeRef(fData); |
148 } | 148 } |
149 | 149 |
150 SkImageGenerator::Result DecodingImageGenerator::onGetPixelsEnum(const SkImageIn
fo& info, | 150 SkImageGenerator::Result DecodingImageGenerator::onGetPixels(const SkImageInfo&
info, |
151 void* pixels, size_t rowBytes, SkPMColor ctableEntries[], int* ctableCou
nt) { | 151 void* pixels, size_t rowBytes, SkPMColor ctableEntries[], int* ctableCou
nt) { |
152 if (fInfo != info) { | 152 if (fInfo != info) { |
153 // The caller has specified a different info. This is an | 153 // The caller has specified a different info. This is an |
154 // error for this kind of SkImageGenerator. Use the Options | 154 // error for this kind of SkImageGenerator. Use the Options |
155 // to change the settings. | 155 // to change the settings. |
156 if (info.dimensions() != fInfo.dimensions()) { | 156 if (info.dimensions() != fInfo.dimensions()) { |
157 return kInvalidScale; | 157 return kInvalidScale; |
158 } | 158 } |
159 return kInvalidConversion; | 159 return kInvalidConversion; |
160 } | 160 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 SkImageGenerator* SkDecodingImageGenerator::Create( | 291 SkImageGenerator* SkDecodingImageGenerator::Create( |
292 SkStreamRewindable* stream, | 292 SkStreamRewindable* stream, |
293 const SkDecodingImageGenerator::Options& opts) { | 293 const SkDecodingImageGenerator::Options& opts) { |
294 SkASSERT(stream != NULL); | 294 SkASSERT(stream != NULL); |
295 if (stream == NULL) { | 295 if (stream == NULL) { |
296 return NULL; | 296 return NULL; |
297 } | 297 } |
298 return CreateDecodingImageGenerator(NULL, stream, opts); | 298 return CreateDecodingImageGenerator(NULL, stream, opts); |
299 } | 299 } |
OLD | NEW |