aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-01-05 09:16:19 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-05 09:16:19 -0800
commit05dd251e5e135626d170b9e77eb64729bd482169 (patch)
treeff63aec98f170d46fd53ae03ac77803aba0ed73a /include/core
parent20ccd40de96ca781dccf5690d215f3369e2a8182 (diff)
take gr-context parameter to refEncoded, indicating a desire for only gpu-specific formats
Prime motivator: - we always call refEncoded on the generator when trying to upload - we call it *before* we ask for raster or YUV - for blink, this call can be very slow, as they have to cons-up their SkData the first time (and grab a mutex to do it) - this parameter will indicate to them that we're only interested in gpu formats, which they will know if they have. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1556333004 Review URL: https://codereview.chromium.org/1556333004
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkImageGenerator.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 66db5e4884..86e3053a06 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -22,6 +22,12 @@ class SkMatrix;
class SkPaint;
class SkPicture;
+#ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
+ #define SK_REFENCODEDDATA_CTXPARAM
+#else
+ #define SK_REFENCODEDDATA_CTXPARAM GrContext* ctx
+#endif
+
/**
* Takes ownership of SkImageGenerator. If this method fails for
* whatever reason, it will return false and immediatetely delete
@@ -64,12 +70,20 @@ public:
/**
* Return a ref to the encoded (i.e. compressed) representation,
- * of this data.
+ * 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.
*
* If non-NULL is returned, the caller is responsible for calling
* unref() on the data when it is finished.
*/
- SkData* refEncodedData() { return this->onRefEncodedData(); }
+ SkData* refEncodedData(GrContext* ctx = nullptr) {
+#ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
+ return this->onRefEncodedData();
+#else
+ return this->onRefEncodedData(ctx);
+#endif
+ }
/**
* Return the ImageInfo associated with this generator.
@@ -230,7 +244,7 @@ public:
protected:
SkImageGenerator(const SkImageInfo& info);
- virtual SkData* onRefEncodedData();
+ virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM);
virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkPMColor ctable[], int* ctableCount);