| Index: include/core/SkImageGenerator.h
|
| diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
|
| index 1a46f6b9cd7dfc39c753170b7da6046ed0877bb2..032be1b90746e7ea1cb0464e0ccfaf204d0dafaf 100644
|
| --- a/include/core/SkImageGenerator.h
|
| +++ b/include/core/SkImageGenerator.h
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "SkBitmap.h"
|
| #include "SkColor.h"
|
| +#include "SkEncodedFormat.h"
|
| #include "SkImageInfo.h"
|
| #include "SkYUVSizeInfo.h"
|
|
|
| @@ -26,7 +27,7 @@ class SkPicture;
|
| #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
|
| #define SK_REFENCODEDDATA_CTXPARAM
|
| #else
|
| - #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx
|
| + #define SK_REFENCODEDDATA_CTXPARAM RefEncodedWhitelist* whitelist
|
| #endif
|
|
|
| /**
|
| @@ -70,19 +71,37 @@ public:
|
| uint32_t uniqueID() const { return fUniqueID; }
|
|
|
| /**
|
| - * Return a ref to the encoded (i.e. compressed) representation,
|
| - * of this data. If the GrContext is non-null, then the caller is only interested in
|
| - * gpu-specific formats, so the impl may return null even if they have encoded data,
|
| - * assuming they know it is not suitable for the gpu.
|
| + * A callback object passed to refEncodedData to determine whether the caller wants its format.
|
| + */
|
| + class RefEncodedWhitelist {
|
| + public:
|
| + virtual ~RefEncodedWhitelist() {}
|
| +
|
| + /**
|
| + * An implementation of onRefEncodedData may call this with the SkEncodedFormat representing
|
| + * its encoded data. If the method returns false, the implementation need not return its data.
|
| + */
|
| + virtual bool includes(SkEncodedFormat) = 0;
|
| + };
|
| +
|
| + /**
|
| + * Return a ref to the encoded (i.e. compressed) representation of the image, or null if
|
| + * no such encoded form is readily available. This is not meant to trigger a full-blown
|
| + * encoding step, as the caller can always perform that itself. This is meant to give the
|
| + * caller quick access to the encoded version iff it is already available.
|
| *
|
| - * If non-NULL is returned, the caller is responsible for calling
|
| - * unref() on the data when it is finished.
|
| + * If whitelist is non-null, then the implementation may call it to preflight if the client
|
| + * wants its format. If the generator readily has the encoded data available, it may ignore
|
| + * the whitelist and just return its data. However, if there is a performance or other
|
| + * constraint on returning the encoded data (e.g. the encoded data already exists, but is
|
| + * not contiguous), calling the whitelist allows the generator to discover if its format is
|
| + * not whitelisted, in which case the generator should just return null.
|
| */
|
| - SkData* refEncodedData(GrContext* ctx = nullptr) {
|
| + SkData* refEncodedData(RefEncodedWhitelist* whitelist = nullptr) {
|
| #ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
|
| return this->onRefEncodedData();
|
| #else
|
| - return this->onRefEncodedData(ctx);
|
| + return this->onRefEncodedData(whitelist);
|
| #endif
|
| }
|
|
|
|
|