| Index: third_party/WebKit/Source/core/paint/BoxPainter.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/BoxPainter.cpp b/third_party/WebKit/Source/core/paint/BoxPainter.cpp
|
| index 213c528534aa3e0ccd2a69b0cd82f42f829f7be9..d0281a0234b0a7d95e32d8509aa9d324cbebd5f0 100644
|
| --- a/third_party/WebKit/Source/core/paint/BoxPainter.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/BoxPainter.cpp
|
| @@ -108,6 +108,39 @@ bool bleedAvoidanceIsClipping(BackgroundBleedAvoidance bleedAvoidance) {
|
|
|
| } // anonymous namespace
|
|
|
| +// Sets a preferred composited raster scale for box with a background image,
|
| +// if possible.
|
| +// |srcRect| is the rect, in the space of the source image, to raster.
|
| +// |destRect| is the rect, in the local layout space of |obj|, to raster.
|
| +inline void updatePreferredRasterScaleFromImage(
|
| + const FloatRect srcRect,
|
| + const FloatRect& destRect,
|
| + const LayoutBoxModelObject& obj) {
|
| + if (!RuntimeEnabledFeatures::preferredImageRasterScaleEnabled())
|
| + return;
|
| + // Not yet implemented for SPv2.
|
| + if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
|
| + return;
|
| + if (destRect.width() == 0.0f || destRect.height() == 0.0f)
|
| + return;
|
| + float widthScale = srcRect.width() / destRect.width();
|
| + float heightScale = srcRect.height() / destRect.height();
|
| + float rasterScale = std::min(std::min(widthScale, heightScale), 10.0f);
|
| + if (PaintLayer* paintLayer = obj.layer()) {
|
| + if (paintLayer->compositingState() != PaintsIntoOwnBacking)
|
| + return;
|
| + paintLayer->graphicsLayerBacking()->setPreferredRasterScale(rasterScale);
|
| + }
|
| +}
|
| +
|
| +inline void clearPreferredRasterScale(const LayoutBox& obj) {
|
| + if (PaintLayer* paintLayer = obj.layer()) {
|
| + if (paintLayer->compositingState() != PaintsIntoOwnBacking)
|
| + return;
|
| + paintLayer->graphicsLayerBacking()->clearPreferredRasterScale();
|
| + }
|
| +}
|
| +
|
| void BoxPainter::paintBoxDecorationBackgroundWithRect(
|
| const PaintInfo& paintInfo,
|
| const LayoutPoint& paintOffset,
|
| @@ -144,6 +177,8 @@ void BoxPainter::paintBoxDecorationBackgroundWithRect(
|
| DisplayItem::kBoxDecorationBackground))
|
| return;
|
|
|
| + clearPreferredRasterScale(m_layoutBox);
|
| +
|
| DrawingRecorder recorder(
|
| paintInfo.context, displayItemClient,
|
| DisplayItem::kBoxDecorationBackground,
|
| @@ -621,6 +656,8 @@ inline bool paintFastBottomLayer(const LayoutBoxModelObject& obj,
|
| context.drawImageRRect(imageContext.image(), border, srcRect,
|
| imageContext.compositeOp());
|
|
|
| + updatePreferredRasterScaleFromImage(srcRect, border.rect(), obj);
|
| +
|
| return true;
|
| }
|
|
|
|
|