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

Unified Diff: include/core/SkImageGenerator.h

Issue 1412423008: Handling large jpegs in CPU raster - downsample to display res and 565 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/SkDevice.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 3d508ddfb1c7ec7f1ceb34b9a12d3ce3d50f6060..ddcd882f8d3069c66d584913bc86926d2bcc01b9 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -109,6 +109,58 @@ public:
SkPMColor ctable[], int* ctableCount);
/**
+ * Used to describe the result of a call to canDecodeAndScale().
+ */
+ enum Result {
+ /**
+ * Cannot decode neither scale.
+ */
+ kNotAvailable = 0,
+ /**
+ * Can scale with color type defined in getInfo.
+ */
+ kScale,
+ /**
+ * Can convert to requested colorType, but cannot scale.
+ */
+ kDecode,
+ /**
+ * The generator can scale and decode to requested.
+ */
+ kAvailable = kScale | kDecode,
+ };
+
+ /**
+ * 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.
+ */
+ Result canDecodeAndScale(const SkColorType colorType, const SkScalar scale = SK_Scalar1,
+ SkISize* availableSize = nullptr, SkISize* lowerSize = nullptr);
+
+ /**
* Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
* uses the default Options.
*/
@@ -199,6 +251,9 @@ protected:
return nullptr;
}
+ virtual Result 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/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698