aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPictureShader.cpp5
-rw-r--r--src/core/SkShader.cpp10
-rw-r--r--src/image/SkImageShader.cpp4
3 files changed, 11 insertions, 8 deletions
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 71026824cd..6aa5c45245 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -106,7 +106,10 @@ SkPictureShader::SkPictureShader(sk_sp<SkPicture> picture, TileMode tmx, TileMod
sk_sp<SkShader> SkPictureShader::Make(sk_sp<SkPicture> picture, TileMode tmx, TileMode tmy,
const SkMatrix* localMatrix, const SkRect* tile) {
- if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
+ if (!picture ||
+ picture->cullRect().isEmpty() ||
+ (tile && tile->isEmpty()) ||
+ (localMatrix && !localMatrix->invert(nullptr))) {
return SkShader::MakeEmptyShader();
}
return sk_sp<SkShader>(new SkPictureShader(std::move(picture), tmx, tmy, localMatrix, tile));
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 81aae116d5..1b12f01969 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -45,13 +45,11 @@ static inline void dec_shader_counter() {
#endif
}
-SkShader::SkShader(const SkMatrix* localMatrix) {
+SkShader::SkShader(const SkMatrix* localMatrix)
+ : fLocalMatrix(localMatrix ? *localMatrix : SkMatrix::I()) {
+ SkASSERT(!localMatrix || localMatrix->invert(nullptr));
+
inc_shader_counter();
- if (localMatrix) {
- fLocalMatrix = *localMatrix;
- } else {
- fLocalMatrix.reset();
- }
// Pre-cache so future calls to fLocalMatrix.getType() are threadsafe.
(void)fLocalMatrix.getType();
}
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 64a09dd2dc..733889df0b 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -100,7 +100,9 @@ sk_sp<SkShader> SkImageShader::Make(sk_sp<SkImage> image, TileMode tx, TileMode
const SkMatrix* localMatrix,
SkTBlitterAllocator* allocator) {
SkShader* shader;
- if (!image || bitmap_is_too_big(image->width(), image->height())) {
+ if (!image ||
+ bitmap_is_too_big(image->width(), image->height()) ||
+ (localMatrix && !localMatrix->invert(nullptr))) {
if (nullptr == allocator) {
shader = new SkEmptyShader;
} else {