Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: include/core/SkImageGenerator.h

Issue 1862133002: Add whitelist parameter to refEncodedData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkEncodedFormat.h ('k') | src/codec/SkCodecImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « include/core/SkEncodedFormat.h ('k') | src/codec/SkCodecImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698