| 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 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
| 14 | 14 |
| 15 class GrContext; | 15 class GrContext; |
| 16 class GrTexture; |
| 17 class GrTextureParams; |
| 16 class SkBitmap; | 18 class SkBitmap; |
| 17 class SkData; | 19 class SkData; |
| 18 class GrTexture; | |
| 19 class SkImageGenerator; | 20 class SkImageGenerator; |
| 20 class SkMatrix; | 21 class SkMatrix; |
| 21 class SkPaint; | 22 class SkPaint; |
| 22 class SkPicture; | 23 class SkPicture; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Takes ownership of SkImageGenerator. If this method fails for | 26 * Takes ownership of SkImageGenerator. If this method fails for |
| 26 * whatever reason, it will return false and immediatetely delete | 27 * whatever reason, it will return false and immediatetely delete |
| 27 * the generator. If it succeeds, it will modify destination | 28 * the generator. If it succeeds, it will modify destination |
| 28 * bitmap. | 29 * bitmap. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 * | 136 * |
| 136 * The caller may pass NULL for the context. In that case the generator may
assume that its | 137 * The caller may pass NULL for the context. In that case the generator may
assume that its |
| 137 * internal context is current. If it has no internal context, then it shou
ld just return | 138 * internal context is current. If it has no internal context, then it shou
ld just return |
| 138 * null. | 139 * null. |
| 139 * | 140 * |
| 140 * If the caller passes a non-null context, then the generator should only
succeed if: | 141 * If the caller passes a non-null context, then the generator should only
succeed if: |
| 141 * - it has no intrinsic context, and will use the caller's | 142 * - it has no intrinsic context, and will use the caller's |
| 142 * - its internal context is the same | 143 * - its internal context is the same |
| 143 * - it can somehow convert its texture into one that is valid for the prov
ided context. | 144 * - it can somehow convert its texture into one that is valid for the prov
ided context. |
| 144 * | 145 * |
| 145 * Regarding the SkImageUsageType parameter: | 146 * Regarding the GrTextureParams parameter: |
| 146 * | 147 * |
| 147 * If the context (the provided one or the generator's intrinsic one) deter
mines that to | 148 * If the context (the provided one or the generator's intrinsic one) deter
mines that to |
| 148 * support the specified usage, it must return a different sized texture it
may, | 149 * support the specified usage, it must return a different sized texture it
may, |
| 149 * so the caller must inspect the texture's width/height and compare them t
o the generator's | 150 * so the caller must inspect the texture's width/height and compare them t
o the generator's |
| 150 * getInfo() width/height. | 151 * getInfo() width/height. For readback usage use GrTextureParams::ClampNoF
ilter() |
| 151 */ | 152 */ |
| 152 GrTexture* generateTexture(GrContext*, SkImageUsageType, const SkIRect* subs
et = nullptr); | 153 GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect
* subset = nullptr); |
| 153 | 154 |
| 154 /** | 155 /** |
| 155 * If the default image decoder system can interpret the specified (encoded
) data, then | 156 * If the default image decoder system can interpret the specified (encoded
) data, then |
| 156 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way | 157 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E
ither way |
| 157 * the caller is still responsible for managing their ownership of the data
. | 158 * the caller is still responsible for managing their ownership of the data
. |
| 158 */ | 159 */ |
| 159 static SkImageGenerator* NewFromEncoded(SkData*); | 160 static SkImageGenerator* NewFromEncoded(SkData*); |
| 160 | 161 |
| 161 /** Return a new image generator backed by the specified picture. If the si
ze is empty or | 162 /** Return a new image generator backed by the specified picture. If the si
ze is empty or |
| 162 * the picture is NULL, this returns NULL. | 163 * the picture is NULL, this returns NULL. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 187 SkImageGenerator(const SkImageInfo& info); | 188 SkImageGenerator(const SkImageInfo& info); |
| 188 | 189 |
| 189 virtual SkData* onRefEncodedData(); | 190 virtual SkData* onRefEncodedData(); |
| 190 | 191 |
| 191 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, | 192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, |
| 192 SkPMColor ctable[], int* ctableCount); | 193 SkPMColor ctable[], int* ctableCount); |
| 193 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
| 194 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], |
| 195 SkYUVColorSpace* colorSpace); | 196 SkYUVColorSpace* colorSpace); |
| 196 | 197 |
| 197 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI
Rect*) { | 198 virtual GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, con
st SkIRect*) { |
| 198 return nullptr; | 199 return nullptr; |
| 199 } | 200 } |
| 200 | 201 |
| 201 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm
ap::Allocator*); | 202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm
ap::Allocator*); |
| 202 | 203 |
| 203 private: | 204 private: |
| 204 const SkImageInfo fInfo; | 205 const SkImageInfo fInfo; |
| 205 const uint32_t fUniqueID; | 206 const uint32_t fUniqueID; |
| 206 | 207 |
| 207 // This is our default impl, which may be different on different platforms. | 208 // This is our default impl, which may be different on different platforms. |
| 208 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. | 209 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. |
| 209 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. | 210 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. |
| 210 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 211 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
| 211 }; | 212 }; |
| 212 | 213 |
| 213 #endif // SkImageGenerator_DEFINED | 214 #endif // SkImageGenerator_DEFINED |
| OLD | NEW |