| 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 "SkEncodedFormat.h" |
| 13 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
| 14 #include "SkYUVSizeInfo.h" | 15 #include "SkYUVSizeInfo.h" |
| 15 | 16 |
| 16 class GrContext; | 17 class GrContext; |
| 17 class GrTexture; | 18 class GrTexture; |
| 18 class GrTextureParams; | 19 class GrTextureParams; |
| 19 class SkBitmap; | 20 class SkBitmap; |
| 20 class SkData; | 21 class SkData; |
| 21 class SkImageGenerator; | 22 class SkImageGenerator; |
| 22 class SkMatrix; | 23 class SkMatrix; |
| 23 class SkPaint; | 24 class SkPaint; |
| 24 class SkPicture; | 25 class SkPicture; |
| 25 | 26 |
| 26 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX | 27 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX |
| 27 #define SK_REFENCODEDDATA_CTXPARAM | 28 #define SK_REFENCODEDDATA_CTXPARAM |
| 28 #else | 29 #else |
| 29 #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx | 30 #define SK_REFENCODEDDATA_CTXPARAM RefEncodedWhitelist* whitelist |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * Takes ownership of SkImageGenerator. If this method fails for | 34 * Takes ownership of SkImageGenerator. If this method fails for |
| 34 * whatever reason, it will return false and immediatetely delete | 35 * whatever reason, it will return false and immediatetely delete |
| 35 * the generator. If it succeeds, it will modify destination | 36 * the generator. If it succeeds, it will modify destination |
| 36 * bitmap. | 37 * bitmap. |
| 37 * | 38 * |
| 38 * If generator is NULL, will safely return false. | 39 * If generator is NULL, will safely return false. |
| 39 * | 40 * |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 public: | 64 public: |
| 64 /** | 65 /** |
| 65 * The PixelRef which takes ownership of this SkImageGenerator | 66 * The PixelRef which takes ownership of this SkImageGenerator |
| 66 * will call the image generator's destructor. | 67 * will call the image generator's destructor. |
| 67 */ | 68 */ |
| 68 virtual ~SkImageGenerator() { } | 69 virtual ~SkImageGenerator() { } |
| 69 | 70 |
| 70 uint32_t uniqueID() const { return fUniqueID; } | 71 uint32_t uniqueID() const { return fUniqueID; } |
| 71 | 72 |
| 72 /** | 73 /** |
| 73 * Return a ref to the encoded (i.e. compressed) representation, | 74 * A callback object passed to refEncodedData to determine whether the call
er wants its format. |
| 74 * of this data. If the GrContext is non-null, then the caller is only inte
rested in | 75 */ |
| 75 * gpu-specific formats, so the impl may return null even if they have enco
ded data, | 76 class RefEncodedWhitelist { |
| 76 * assuming they know it is not suitable for the gpu. | 77 public: |
| 78 virtual ~RefEncodedWhitelist() {} |
| 79 |
| 80 /** |
| 81 * An implementation of onRefEncodedData may call this with the SkEncod
edFormat representing |
| 82 * its encoded data. If the method returns false, the implementation ne
ed not return its data. |
| 83 */ |
| 84 virtual bool includes(SkEncodedFormat) = 0; |
| 85 }; |
| 86 |
| 87 /** |
| 88 * Return a ref to the encoded (i.e. compressed) representation of the imag
e, or null if |
| 89 * no such encoded form is readily available. This is not meant to trigger
a full-blown |
| 90 * encoding step, as the caller can always perform that itself. This is mea
nt to give the |
| 91 * caller quick access to the encoded version iff it is already available. |
| 77 * | 92 * |
| 78 * If non-NULL is returned, the caller is responsible for calling | 93 * If whitelist is non-null, then the implementation may call it to preflig
ht if the client |
| 79 * unref() on the data when it is finished. | 94 * wants its format. If the generator readily has the encoded data availabl
e, it may ignore |
| 95 * the whitelist and just return its data. However, if there is a performan
ce or other |
| 96 * constraint on returning the encoded data (e.g. the encoded data already
exists, but is |
| 97 * not contiguous), calling the whitelist allows the generator to discover
if its format is |
| 98 * not whitelisted, in which case the generator should just return null. |
| 80 */ | 99 */ |
| 81 SkData* refEncodedData(GrContext* ctx = nullptr) { | 100 SkData* refEncodedData(RefEncodedWhitelist* whitelist = nullptr) { |
| 82 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX | 101 #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX |
| 83 return this->onRefEncodedData(); | 102 return this->onRefEncodedData(); |
| 84 #else | 103 #else |
| 85 return this->onRefEncodedData(ctx); | 104 return this->onRefEncodedData(whitelist); |
| 86 #endif | 105 #endif |
| 87 } | 106 } |
| 88 | 107 |
| 89 /** | 108 /** |
| 90 * Return the ImageInfo associated with this generator. | 109 * Return the ImageInfo associated with this generator. |
| 91 */ | 110 */ |
| 92 const SkImageInfo& getInfo() const { return fInfo; } | 111 const SkImageInfo& getInfo() const { return fInfo; } |
| 93 | 112 |
| 94 /** | 113 /** |
| 95 * Decode into the given pixels, a block of memory of size at | 114 * Decode into the given pixels, a block of memory of size at |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const SkImageInfo fInfo; | 301 const SkImageInfo fInfo; |
| 283 const uint32_t fUniqueID; | 302 const uint32_t fUniqueID; |
| 284 | 303 |
| 285 // This is our default impl, which may be different on different platforms. | 304 // This is our default impl, which may be different on different platforms. |
| 286 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. | 305 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. |
| 287 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. | 306 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. |
| 288 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 307 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
| 289 }; | 308 }; |
| 290 | 309 |
| 291 #endif // SkImageGenerator_DEFINED | 310 #endif // SkImageGenerator_DEFINED |
| OLD | NEW |