| Index: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
|
| index 1d30391b3b0e3387e42aa38e8a3fd3f04157c6fb..4a1127e03f5870ff9b9a36c30738817fe91c94c9 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
|
| @@ -27,6 +27,8 @@
|
| #include "platform/graphics/GraphicsContext.h"
|
|
|
| #include "platform/TraceEvent.h"
|
| +#include "platform/geometry/FloatRect.h"
|
| +#include "platform/geometry/FloatRoundedRect.h"
|
| #include "platform/geometry/IntRect.h"
|
| #include "platform/graphics/ColorSpace.h"
|
| #include "platform/graphics/Gradient.h"
|
| @@ -809,6 +811,49 @@ void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
|
| m_paintController.setImagePainted();
|
| }
|
|
|
| +void GraphicsContext::drawImageRRect(Image* image, const FloatRoundedRect& dest,
|
| + const FloatRect& srcRect, SkXfermode::Mode op, RespectImageOrientationEnum respectOrientation)
|
| +{
|
| + if (contextDisabled() || !image)
|
| + return;
|
| +
|
| + if (!dest.isRounded()) {
|
| + drawImage(image, dest.rect(), &srcRect, op, respectOrientation);
|
| + return;
|
| + }
|
| +
|
| + DCHECK(dest.isRenderable());
|
| +
|
| + const FloatRect visibleSrc = intersection(srcRect, image->rect());
|
| + if (dest.isEmpty() || visibleSrc.isEmpty())
|
| + return;
|
| +
|
| + SkPaint imagePaint = immutableState()->fillPaint();
|
| + imagePaint.setXfermodeMode(op);
|
| + imagePaint.setColor(SK_ColorBLACK);
|
| + imagePaint.setFilterQuality(computeFilterQuality(image, dest.rect(), srcRect));
|
| + imagePaint.setAntiAlias(shouldAntialias());
|
| +
|
| + bool useShader = (visibleSrc == srcRect) && (respectOrientation == DoNotRespectImageOrientation);
|
| + if (useShader) {
|
| + const SkMatrix localMatrix =
|
| + SkMatrix::MakeRectToRect(visibleSrc, dest.rect(), SkMatrix::kFill_ScaleToFit);
|
| + useShader = image->applyShader(imagePaint, localMatrix.isIdentity() ? nullptr : &localMatrix);
|
| + }
|
| +
|
| + if (useShader) {
|
| + // Shader-based fast path.
|
| + m_canvas->drawRRect(dest, imagePaint);
|
| + } else {
|
| + // Clip-based fallback.
|
| + SkAutoCanvasRestore autoRestore(m_canvas, true);
|
| + m_canvas->clipRRect(dest, SkRegion::kIntersect_Op, imagePaint.isAntiAlias());
|
| + image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation, Image::ClampImageToSourceRect);
|
| + }
|
| +
|
| + m_paintController.setImagePainted();
|
| +}
|
| +
|
| SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatRect& dest, const FloatRect& src) const
|
| {
|
| InterpolationQuality resampling;
|
|
|