Chromium Code Reviews| 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; | 16 class GrTexture; |
| 17 class GrTextureParams; | 17 class GrTextureParams; |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 class SkData; | 19 class SkData; |
| 20 class SkImageGenerator; | 20 class SkImageGenerator; |
| 21 class SkMatrix; | 21 class SkMatrix; |
| 22 class SkPaint; | 22 class SkPaint; |
| 23 class SkPicture; | 23 class SkPicture; |
| 24 | 24 |
| 25 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX | |
| 26 #define SK_REFENCODEDDATA_CTXPARAM | |
| 27 #else | |
| 28 #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx | |
| 29 #endif | |
| 30 | |
| 25 /** | 31 /** |
| 26 * Takes ownership of SkImageGenerator. If this method fails for | 32 * Takes ownership of SkImageGenerator. If this method fails for |
| 27 * whatever reason, it will return false and immediatetely delete | 33 * whatever reason, it will return false and immediatetely delete |
| 28 * the generator. If it succeeds, it will modify destination | 34 * the generator. If it succeeds, it will modify destination |
| 29 * bitmap. | 35 * bitmap. |
| 30 * | 36 * |
| 31 * If generator is NULL, will safely return false. | 37 * If generator is NULL, will safely return false. |
| 32 * | 38 * |
| 33 * If this fails or when the SkDiscardablePixelRef that is | 39 * If this fails or when the SkDiscardablePixelRef that is |
| 34 * installed into destination is destroyed, it will | 40 * installed into destination is destroyed, it will |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 57 /** | 63 /** |
| 58 * The PixelRef which takes ownership of this SkImageGenerator | 64 * The PixelRef which takes ownership of this SkImageGenerator |
| 59 * will call the image generator's destructor. | 65 * will call the image generator's destructor. |
| 60 */ | 66 */ |
| 61 virtual ~SkImageGenerator() { } | 67 virtual ~SkImageGenerator() { } |
| 62 | 68 |
| 63 uint32_t uniqueID() const { return fUniqueID; } | 69 uint32_t uniqueID() const { return fUniqueID; } |
| 64 | 70 |
| 65 /** | 71 /** |
| 66 * Return a ref to the encoded (i.e. compressed) representation, | 72 * Return a ref to the encoded (i.e. compressed) representation, |
| 67 * of this data. | 73 * of this data. |
|
robertphillips
2016/01/05 16:25:49
doc 'ctx' param ?
reed1
2016/01/05 17:00:15
Done.
| |
| 68 * | 74 * |
| 69 * If non-NULL is returned, the caller is responsible for calling | 75 * If non-NULL is returned, the caller is responsible for calling |
| 70 * unref() on the data when it is finished. | 76 * unref() on the data when it is finished. |
| 71 */ | 77 */ |
| 72 SkData* refEncodedData() { return this->onRefEncodedData(); } | 78 SkData* refEncodedData(GrContext* ctx = nullptr) { |
| 79 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX | |
| 80 return this->onRefEncodedData(); | |
| 81 #else | |
| 82 return this->onRefEncodedData(ctx); | |
| 83 #endif | |
| 84 } | |
| 73 | 85 |
| 74 /** | 86 /** |
| 75 * Return the ImageInfo associated with this generator. | 87 * Return the ImageInfo associated with this generator. |
| 76 */ | 88 */ |
| 77 const SkImageInfo& getInfo() const { return fInfo; } | 89 const SkImageInfo& getInfo() const { return fInfo; } |
| 78 | 90 |
| 79 /** | 91 /** |
| 80 * Decode into the given pixels, a block of memory of size at | 92 * Decode into the given pixels, a block of memory of size at |
| 81 * least (info.fHeight - 1) * rowBytes + (info.fWidth * | 93 * least (info.fHeight - 1) * rowBytes + (info.fWidth * |
| 82 * bytesPerPixel) | 94 * bytesPerPixel) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 } | 235 } |
| 224 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) { | 236 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) { |
| 225 if (!this->tryGenerateBitmap(bm, &info, nullptr)) { | 237 if (!this->tryGenerateBitmap(bm, &info, nullptr)) { |
| 226 sk_throw(); | 238 sk_throw(); |
| 227 } | 239 } |
| 228 } | 240 } |
| 229 | 241 |
| 230 protected: | 242 protected: |
| 231 SkImageGenerator(const SkImageInfo& info); | 243 SkImageGenerator(const SkImageInfo& info); |
| 232 | 244 |
| 233 virtual SkData* onRefEncodedData(); | 245 virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM); |
| 234 | 246 |
| 235 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 247 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, |
| 236 SkPMColor ctable[], int* ctableCount); | 248 SkPMColor ctable[], int* ctableCount); |
| 237 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); | 249 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); |
| 238 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | 250 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], |
| 239 SkYUVColorSpace* colorSpace); | 251 SkYUVColorSpace* colorSpace); |
| 240 | 252 |
| 241 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { | 253 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { |
| 242 return nullptr; | 254 return nullptr; |
| 243 } | 255 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 255 const SkImageInfo fInfo; | 267 const SkImageInfo fInfo; |
| 256 const uint32_t fUniqueID; | 268 const uint32_t fUniqueID; |
| 257 | 269 |
| 258 // This is our default impl, which may be different on different platforms. | 270 // This is our default impl, which may be different on different platforms. |
| 259 // It is called from NewFromEncoded() after it has checked for any runtime f actory. | 271 // It is called from NewFromEncoded() after it has checked for any runtime f actory. |
| 260 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. | 272 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. |
| 261 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 273 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
| 262 }; | 274 }; |
| 263 | 275 |
| 264 #endif // SkImageGenerator_DEFINED | 276 #endif // SkImageGenerator_DEFINED |
| OLD | NEW |