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

Unified Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

Issue 2677633004: Handle shader construction failures gracefully (Closed)
Patch Set: comment Created 3 years, 10 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 | « third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Image.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Image.cpp b/third_party/WebKit/Source/platform/graphics/Image.cpp
index c3dc079a280203837cafa1731e543f5121c6fc8e..b87996e7110e5cb732f8d5c5f8fcc75781c9d5fb 100644
--- a/third_party/WebKit/Source/platform/graphics/Image.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Image.cpp
@@ -303,20 +303,24 @@ void Image::drawPattern(GraphicsContext& context,
const auto tmy = computeTileMode(destRect.y(), destRect.maxY(), adjustedY,
adjustedY + tileSize.height());
- {
- PaintFlags paint = context.fillPaint();
- paint.setColor(SK_ColorBLACK);
- paint.setBlendMode(compositeOp);
- paint.setFilterQuality(
- context.computeFilterQuality(this, destRect, normSrcRect));
- paint.setAntiAlias(context.shouldAntialias());
- paint.setShader(
- createPatternShader(image.get(), localMatrix, paint,
- FloatSize(repeatSpacing.width() / scale.width(),
- repeatSpacing.height() / scale.height()),
- tmx, tmy));
- context.drawRect(destRect, paint);
- }
+ PaintFlags paint = context.fillPaint();
+ paint.setColor(SK_ColorBLACK);
+ paint.setBlendMode(compositeOp);
+ paint.setFilterQuality(
+ context.computeFilterQuality(this, destRect, normSrcRect));
+ paint.setAntiAlias(context.shouldAntialias());
+ paint.setShader(
+ createPatternShader(image.get(), localMatrix, paint,
+ FloatSize(repeatSpacing.width() / scale.width(),
+ repeatSpacing.height() / scale.height()),
+ tmx, tmy));
+ // If the shader could not be instantiated (e.g. non-invertible matrix),
+ // draw transparent.
+ // Note: we can't simply bail, because of arbitrary blend mode.
+ if (!paint.getShader())
+ paint.setColor(SK_ColorTRANSPARENT);
+
+ context.drawRect(destRect, paint);
if (currentFrameIsLazyDecoded())
PlatformInstrumentation::didDrawLazyPixelRef(imageID);
@@ -339,6 +343,8 @@ bool Image::applyShader(SkPaint& paint,
paint.setShader(image->makeShader(SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode, &localMatrix));
+ if (!paint.getShader())
+ return false;
// Animation is normally refreshed in draw() impls, which we don't call when
// painting via shaders.
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698