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 #ifndef SkImageGenerator_DEFINED | 8 #ifndef SkImageGenerator_DEFINED |
9 #define SkImageGenerator_DEFINED | 9 #define SkImageGenerator_DEFINED |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 * of this data. | 67 * of this data. |
68 * | 68 * |
69 * If non-NULL is returned, the caller is responsible for calling | 69 * If non-NULL is returned, the caller is responsible for calling |
70 * unref() on the data when it is finished. | 70 * unref() on the data when it is finished. |
71 */ | 71 */ |
72 SkData* refEncodedData() { return this->onRefEncodedData(); } | 72 SkData* refEncodedData() { return this->onRefEncodedData(); } |
73 | 73 |
74 /** | 74 /** |
75 * Return the ImageInfo associated with this generator. | 75 * Return the ImageInfo associated with this generator. |
76 */ | 76 */ |
77 const SkImageInfo& getInfo() const { return fInfo; } | 77 const SkImageInfo& getInfo() { |
78 SkColorType colorType; | |
79 if ((colorType = onGetColorType()) != fInfo.colorType()) | |
80 fInfo = fInfo.makeColorType(colorType); | |
81 return fInfo; | |
82 } | |
78 | 83 |
79 /** | 84 /** |
80 * Decode into the given pixels, a block of memory of size at | 85 * Decode into the given pixels, a block of memory of size at |
81 * least (info.fHeight - 1) * rowBytes + (info.fWidth * | 86 * least (info.fHeight - 1) * rowBytes + (info.fWidth * |
82 * bytesPerPixel) | 87 * bytesPerPixel) |
83 * | 88 * |
84 * Repeated calls to this function should give the same results, | 89 * Repeated calls to this function should give the same results, |
85 * allowing the PixelRef to be immutable. | 90 * allowing the PixelRef to be immutable. |
86 * | 91 * |
87 * @param info A description of the format (config, size) | 92 * @param info A description of the format (config, size) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 197 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, |
193 SkPMColor ctable[], int* ctableCount); | 198 SkPMColor ctable[], int* ctableCount); |
194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); | 199 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); |
195 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | 200 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], |
196 SkYUVColorSpace* colorSpace); | 201 SkYUVColorSpace* colorSpace); |
197 | 202 |
198 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { | 203 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { |
199 return nullptr; | 204 return nullptr; |
200 } | 205 } |
201 | 206 |
207 virtual SkColorType onGetColorType() { return fInfo.colorType(); } | |
aleksandar.stojiljkovic
2015/12/07 19:31:02
Does this look better?
Implemented the chromium pa
| |
208 | |
202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); | 209 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); |
203 | 210 |
204 private: | 211 private: |
205 const SkImageInfo fInfo; | 212 SkImageInfo fInfo; |
206 const uint32_t fUniqueID; | 213 const uint32_t fUniqueID; |
207 | 214 |
208 // This is our default impl, which may be different on different platforms. | 215 // This is our default impl, which may be different on different platforms. |
209 // It is called from NewFromEncoded() after it has checked for any runtime f actory. | 216 // It is called from NewFromEncoded() after it has checked for any runtime f actory. |
210 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. | 217 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. |
211 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 218 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
212 }; | 219 }; |
213 | 220 |
214 #endif // SkImageGenerator_DEFINED | 221 #endif // SkImageGenerator_DEFINED |
OLD | NEW |