Don't instantiate shaders with non-invertible local matrix
Change-Id: If11f7d57cbf45929632d858f91c02d8f5fa9f442 Reviewed-on: https://skia-review.googlesource.com/7885 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
41511604ae
commit
ebfbba9bbd
@ -241,11 +241,17 @@ sk_sp<SkShader> SkShader::MakeColorShader(SkColor color) { return sk_make_sp<SkC
|
|||||||
|
|
||||||
sk_sp<SkShader> SkShader::MakeBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
|
sk_sp<SkShader> SkShader::MakeBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
|
||||||
const SkMatrix* localMatrix) {
|
const SkMatrix* localMatrix) {
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return SkMakeBitmapShader(src, tmx, tmy, localMatrix, kIfMutable_SkCopyPixelsMode, nullptr);
|
return SkMakeBitmapShader(src, tmx, tmy, localMatrix, kIfMutable_SkCopyPixelsMode, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkShader> SkShader::MakePictureShader(sk_sp<SkPicture> src, TileMode tmx, TileMode tmy,
|
sk_sp<SkShader> SkShader::MakePictureShader(sk_sp<SkPicture> src, TileMode tmx, TileMode tmy,
|
||||||
const SkMatrix* localMatrix, const SkRect* tile) {
|
const SkMatrix* localMatrix, const SkRect* tile) {
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return SkPictureShader::Make(std::move(src), tmx, tmy, localMatrix, tile);
|
return SkPictureShader::Make(std::move(src), tmx, tmy, localMatrix, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,6 +944,9 @@ sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2],
|
|||||||
if (1 == colorCount) {
|
if (1 == colorCount) {
|
||||||
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
||||||
|
|
||||||
@ -980,6 +983,9 @@ sk_sp<SkShader> SkGradientShader::MakeRadial(const SkPoint& center, SkScalar rad
|
|||||||
if (1 == colorCount) {
|
if (1 == colorCount) {
|
||||||
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
||||||
|
|
||||||
@ -1026,6 +1032,9 @@ sk_sp<SkShader> SkGradientShader::MakeTwoPointConical(const SkPoint& start,
|
|||||||
return SkShader::MakeEmptyShader();
|
return SkShader::MakeEmptyShader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
EXPAND_1_COLOR(colorCount);
|
EXPAND_1_COLOR(colorCount);
|
||||||
|
|
||||||
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
ColorStopOptimizer opt(colors, pos, colorCount, mode);
|
||||||
@ -1086,6 +1095,9 @@ sk_sp<SkShader> SkGradientShader::MakeSweep(SkScalar cx, SkScalar cy,
|
|||||||
if (1 == colorCount) {
|
if (1 == colorCount) {
|
||||||
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
return SkShader::MakeColorShader(colors[0], std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto mode = SkShader::kClamp_TileMode;
|
auto mode = SkShader::kClamp_TileMode;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user