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

Unified Diff: include/core/SkImageGenerator.h

Issue 1404923004: Proposal for SkImageGenerator::canDecodeAndScale API Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | src/core/SkImageGenerator.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 0e2a45e145c5fb6403355b0ec86e63e4248be654..9108cc95757f97e2f580b0ab7842d9cf312e2c5c 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -108,6 +108,36 @@ public:
SkPMColor ctable[], int* ctableCount);
/**
+ * Some generators can efficiently scale their contents and provide multiple
+ * different pixel formats while decoding.
+ * If scaling is supported, the generator may only support certain scaled dimensions.
+ * Call this with the desired scale and color type, and it will return true if scaling
+ * and specified color type is supported.
+ *
+ * @param colorType A description of the color type expected by the caller.
+ * Returns true if it is the same as getInfo() or if decoder implementations
+ * support this output.
+ *
+ * @param scale Vale larger than 0 and less or equal to 1.
+ *
+ * @param availableSize If specified colorType and scale on decode is supported,
+ * this holds a value of equal or nearest larger possible decode output.
+ * Can be NULL, in which case caller specifies no interest in getting the value.
+ *
+ * @param lowerSize If specified colorType and scale on decode is supported,
+ * this holds a value of nearest lower possible decode output.
+ * Can be NULL, in which case caller specifies no interest in getting the value.
+ *
+ * Disclaimer: This method was added later to this class and it is possible
+ * that some of the SkImageGenerator implementations are not overriding it to
+ * precisely declare supported decoding. Purpose of this call is an attempt to prevent
+ * fruitless memory allocations (from within Skia) before calling getPixels - it is
+ * still OK to call getPixels even this method is not overridden in generator implementation.
+ */
+ bool canDecodeAndScale(const SkColorType colorType, const SkScalar scale = SK_Scalar1,
scroggo 2015/10/15 16:26:32 Should this also specify an alpha type? Or should
+ SkISize *availableSize = nullptr, SkISize *lowerSize = nullptr);
scroggo 2015/10/15 16:26:32 I like that the sizes are named to distinguish wha
+
+ /**
* Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
* uses the default Options.
*/
@@ -198,6 +228,9 @@ protected:
return nullptr;
}
+ virtual bool onCanDecodeAndScale(const SkColorType colorType, const SkScalar scale,
+ SkISize *availableSize, SkISize *lowerSize);
+
bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitmap::Allocator*);
private:
« no previous file with comments | « no previous file | src/core/SkImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698