aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-05-12 11:41:27 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-12 16:48:17 +0000
commitebb1b5c297e394ab19f99d807095672b7f5d8aef (patch)
tree5f2fcd7f15da445df1efd5861b708df8f35c5ba0 /include
parent7c8460e10135c05a42d0744b84838bbc24398ac2 (diff)
Add new SkImageGenerator::getPixels() API, deprecate the old
This is fairly aggressive in that it will break any client that is currently using SkImageGenerator with kIndex8. I'm guessing that we don't have any clients doing that. Bug: skia:6620 Change-Id: Ifd16f5232bb3a9f759c225315c57492d917ed9ca Reviewed-on: https://skia-review.googlesource.com/16601 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkImageGenerator.h64
1 files changed, 34 insertions, 30 deletions
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 8e875daf04..8b2ca7d13e 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -66,7 +66,7 @@ public:
* Repeated calls to this function should give the same results,
* allowing the PixelRef to be immutable.
*
- * @param info A description of the format (config, size)
+ * @param info A description of the format
* expected by the caller. This can simply be identical
* to the info returned by getInfo().
*
@@ -76,26 +76,31 @@ public:
*
* A size that does not match getInfo() implies a request
* to scale. If the generator cannot perform this scale,
- * it will return kInvalidScale.
+ * it will return false.
*
- * If info is kIndex8_SkColorType, then the caller must provide storage for up to 256
- * SkPMColor values in ctable. On success the generator must copy N colors into that storage,
- * (where N is the logical number of table entries) and set ctableCount to N.
- *
- * If info is not kIndex8_SkColorType, then the last two parameters may be NULL. If ctableCount
- * is not null, it will be set to 0.
+ * kIndex_8_SkColorType is not supported.
*
* @return true on success.
*/
- bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- SkPMColor ctable[], int* ctableCount);
+ struct Options {
+ Options()
+ : fBehavior(SkTransferFunctionBehavior::kIgnore)
+ {}
+
+ SkTransferFunctionBehavior fBehavior;
+ };
+ bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options* options);
/**
- * Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
- * uses the default Options.
+ * Simplified version of getPixels() that uses the default Options.
*/
bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
+#ifdef SK_SUPPORT_LEGACY_IMGEN_API
+ bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
+ int* ctableCount);
+#endif
+
/**
* If decoding to YUV is supported, this returns true. Otherwise, this
* returns false and does not modify any of the parameters.
@@ -171,30 +176,29 @@ protected:
virtual SkData* onRefEncodedData() { return nullptr; }
- virtual bool onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor[], int*) { return false; }
+#ifdef SK_SUPPORT_LEGACY_IMGEN_API
+ virtual bool onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) {
+ return false;
+ }
+#endif
+
+#ifdef SK_SUPPORT_LEGACY_IMGEN_API
+ virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ const Options&) {
+
+ return this->onGetPixels(info, pixels, rowBytes, nullptr, nullptr);
+ }
+#else
+ virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) {
+ return false;
+ }
+#endif
virtual bool onIsValid(GrContext*) const { return true; }
virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { return false; }
virtual bool onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { return false; }
- struct Options {
- Options()
- : fColorTable(nullptr)
- , fColorTableCount(nullptr)
- , fBehavior(SkTransferFunctionBehavior::kRespect)
- {}
-
- SkPMColor* fColorTable;
- int* fColorTableCount;
- SkTransferFunctionBehavior fBehavior;
- };
- bool getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options* opts);
- virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const Options& opts) {
- return this->onGetPixels(info, pixels, rowBytes, opts.fColorTable, opts.fColorTableCount);
- }
-
#if SK_SUPPORT_GPU
virtual bool onCanGenerateTexture() const { return false; }
virtual sk_sp<GrTextureProxy> onGenerateTexture(GrContext*, const SkImageInfo&,