Index: include/core/SkImageGenerator.h |
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h |
index e04e05ea0b383d59959397bdf12cf7ef94e86218..e4588313e582f86e98f5c6f0f547dd95b4952cd9 100644 |
--- a/include/core/SkImageGenerator.h |
+++ b/include/core/SkImageGenerator.h |
@@ -153,6 +153,30 @@ public: |
GrTexture* generateTexture(GrContext*, const GrTextureParams&, const SkIRect* subset = nullptr); |
/** |
+ * Some generators can efficiently scale their contents. If this is supported, the generator |
+ * may only support certain scaled dimensions. Call this with the desired scale factor, |
+ * and it will return true if scaling is supported, and in supportedSizes[] it will return |
+ * the two nearest supported dimensions. If scaling is not supported, or scale is invalid |
msarett
2015/10/13 21:43:22
Would we want to return one supportedSize that is
aleksandar.stojiljkovic
2015/10/14 15:32:35
Another option would be to always return equal or
reed1
2015/10/15 18:21:28
Yea, I like the idea of having the results be sort
reed1
2015/10/28 18:01:51
Your last suggestion makes sense to me. I'll updat
msarett
2015/10/28 18:27:19
I'm not sure I see an update to the comment?
|
+ * this will return false, and supportedSizes[] will be undefined. |
msarett
2015/10/13 21:43:22
Can we define an "invalid scale" as <= 0.0f or > 1
reed1
2015/10/15 18:21:28
Done.
|
+ */ |
+ bool computeScaledDimensions(SkScalar scale, SkISize supportedSizes[2]); |
aleksandar.stojiljkovic
2015/10/14 15:32:35
since getPixels could be already (implicitly thoug
reed1
2015/10/28 18:01:51
Perhaps we do want more query methods, but this on
|
+ |
+ /** |
+ * Request the pixels, scaled to fit into the specified scaledInfo dimensions. |
+ * If scaledSubset is not null, it specifies the subset of the scaled pixels that should |
msarett
2015/10/13 21:43:23
nit: scaledClip
reed1
2015/10/28 18:01:51
Done.
|
+ * be returned. It will be in the scaled coordinate system (not the original), and is only |
+ * valid if it is entire contained inside the scaled dimensions... |
msarett
2015/10/13 21:43:23
nit: entirely
reed1
2015/10/28 18:01:51
Done.
|
+ * |
+ * SkIRect scaledBounds = SkIRect::MakeWH(0, 0, scaledInfo.width(), scaledInfo.height()); |
+ * bool valid = scaledBounds.contains(scaledClip); |
+ * |
+ * If the requested scaledInfo is not supported by the generator, it it encounters an error, |
msarett
2015/10/13 21:43:23
nit: it it
reed1
2015/10/28 18:01:51
Done.
|
+ * or the scaledClip is invalid, this returns false and the contents of pixels is undefined. |
msarett
2015/10/13 21:50:31
In the case of an incomplete image, will this retu
reed1
2015/10/28 18:01:51
Good question. I *think* at the image-generator le
msarett
2015/10/28 18:27:19
From what I've seen, *most* of the incomplete imag
|
+ */ |
+ bool generateScaledPixels(const SkImageInfo& scaledInfo, void* pixels, size_t rowBytes, |
msarett
2015/10/13 21:43:23
I have one concern about this that I thought of af
scroggo
2015/10/14 14:11:28
Agreed. I thought the conclusion we came to was th
aleksandar.stojiljkovic
2015/10/27 13:42:25
Related to 1412423008 and 1403393004 (downsample &
reed1
2015/10/28 18:01:51
Ah, I had a different idea.
I think one of the ke
reed1
2015/10/28 18:01:52
The older android decoders (SkImageDecoder) follow
msarett
2015/10/28 18:27:19
I think whatever decision is made here should and
|
+ const SkIRect* scaledClip); |
+ |
+ /** |
* If the default image decoder system can interpret the specified (encoded) data, then |
* this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way |
* the caller is still responsible for managing their ownership of the data. |
@@ -199,6 +223,14 @@ protected: |
return nullptr; |
} |
+ virtual bool onComputeScaledDimensions(SkScalar scale, SkISize supportedSizes[2]) { |
+ return false; |
+ } |
+ virtual bool onGenerateScaledPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
+ const SkIRect* subset) { |
+ return false; |
+ } |
+ |
bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitmap::Allocator*); |
private: |