don't draw non-finite contexts in imagefilters
Bug: skia:7507 Change-Id: Ifc210951c17f74770f15de1c2e13b42117a3354e Reviewed-on: https://skia-review.googlesource.com/101202 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
e41e1769e7
commit
2f5b8d81c2
@ -66,6 +66,16 @@ public:
|
||||
SkImageFilterCache* cache() const { return fCache; }
|
||||
const OutputProperties& outputProperties() const { return fOutputProperties; }
|
||||
|
||||
/**
|
||||
* Since a context can be build directly, its constructor has no chance to
|
||||
* "return null" if it's given invalid or unsupported inputs. Call this to
|
||||
* know of the the context can be used.
|
||||
*
|
||||
* The SkImageFilterCache Key, for example, requires a finite ctm (no infinities
|
||||
* or NaN), so that test is part of isValid.
|
||||
*/
|
||||
bool isValid() const { return fCTM.isFinite(); }
|
||||
|
||||
private:
|
||||
SkMatrix fCTM;
|
||||
SkIRect fClipBounds;
|
||||
|
@ -197,6 +197,9 @@ void SkImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||
sk_sp<SkSpecialImage> SkImageFilter::filterImage(SkSpecialImage* src, const Context& context,
|
||||
SkIPoint* offset) const {
|
||||
SkASSERT(src && offset);
|
||||
if (!context.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t srcGenID = fUsesSrcInput ? src->uniqueID() : 0;
|
||||
const SkIRect srcSubset = fUsesSrcInput ? src->subset() : SkIRect::MakeWH(0, 0);
|
||||
|
@ -28,6 +28,7 @@ struct SkImageFilterCacheKey {
|
||||
sizeof(SkIRect) + sizeof(uint32_t) + 4 * sizeof(int32_t),
|
||||
"image_filter_key_tight_packing");
|
||||
fMatrix.getType(); // force initialization of type, so hashes match
|
||||
SkASSERT(fMatrix.isFinite()); // otherwise we can't rely on == self when comparing keys
|
||||
}
|
||||
|
||||
uint32_t fUniqueID;
|
||||
|
Loading…
Reference in New Issue
Block a user