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

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

Issue 1955683002: Avoid unnecessary clipping of gradient/generated images (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: expectations Created 4 years, 7 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/LayoutTests/TestExpectations ('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/GradientGeneratedImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/GradientGeneratedImage.cpp b/third_party/WebKit/Source/platform/graphics/GradientGeneratedImage.cpp
index a263f8208313e3f7ed1477691076542ed145c2f2..b4dff46a969ed0abb8b4b54df99ff6bffeec0ba8 100644
--- a/third_party/WebKit/Source/platform/graphics/GradientGeneratedImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GradientGeneratedImage.cpp
@@ -32,15 +32,18 @@ namespace blink {
void GradientGeneratedImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& destRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode)
{
- SkAutoCanvasRestore ar(canvas, true);
- canvas->clipRect(destRect);
- canvas->translate(destRect.x(), destRect.y());
- if (destRect.size() != srcRect.size())
- canvas->scale(destRect.width() / srcRect.width(), destRect.height() / srcRect.height());
- canvas->translate(-srcRect.x(), -srcRect.y());
+ SkRect visibleRect = srcRect;
+ if (!visibleRect.intersect(SkRect::MakeIWH(m_size.width(), m_size.height())))
+ return;
+
+ SkMatrix transform = SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit);
+ SkAutoCanvasRestore autoRestore(canvas, !transform.isIdentity());
+ canvas->concat(transform);
+
SkPaint gradientPaint(paint);
m_gradient->applyToPaint(gradientPaint);
- canvas->drawRect(SkRect::MakeWH(m_size.width(), m_size.height()), gradientPaint);
+
+ canvas->drawRect(visibleRect, gradientPaint);
}
void GradientGeneratedImage::drawTile(GraphicsContext& context, const FloatRect& srcRect)
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698