Commit 937677e6 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Remove DstIn optimization when painting mask for inline flow box

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I7cdba1e84b853eeaff281093555e8757dc1616ed
Reviewed-on: https://chromium-review.googlesource.com/882396Reviewed-by: default avatarTien-Ren Chen <trchen@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532493}
parent 2477ec97
...@@ -70,8 +70,7 @@ BoxReflection BoxReflectionForPaintLayer(const PaintLayer& layer, ...@@ -70,8 +70,7 @@ BoxReflection BoxReflectionForPaintLayer(const PaintLayer& layer,
node = layout_object->GeneratingNode(); node = layout_object->GeneratingNode();
NinePieceImagePainter::Paint(builder.Context(), layer.GetLayoutObject(), NinePieceImagePainter::Paint(builder.Context(), layer.GetLayoutObject(),
layer.GetLayoutObject().GetDocument(), node, layer.GetLayoutObject().GetDocument(), node,
mask_rect, style, mask_nine_piece, mask_rect, style, mask_nine_piece);
SkBlendMode::kSrcOver);
} }
return BoxReflection(direction, offset, builder.EndRecording(), return BoxReflection(direction, offset, builder.EndRecording(),
FloatRect(mask_bounding_rect)); FloatRect(mask_bounding_rect));
......
...@@ -363,27 +363,16 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info, ...@@ -363,27 +363,16 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info,
// Figure out if we need to push a transparency layer to render our mask. // Figure out if we need to push a transparency layer to render our mask.
bool push_transparency_layer = false; bool push_transparency_layer = false;
SkBlendMode composite_op = SkBlendMode::kSrcOver; LayoutRect paint_rect = LayoutRect(adjusted_paint_offset, frame_rect.Size());
DCHECK(box_model.HasLayer()); DCHECK(box_model.HasLayer());
if (!box_model.Layer()->MaskBlendingAppliedByCompositor(paint_info)) { if (!box_model.Layer()->MaskBlendingAppliedByCompositor(paint_info)) {
if ((mask_box_image && box_model.StyleRef().MaskLayers().HasImage()) || push_transparency_layer = true;
box_model.StyleRef().MaskLayers().Next()) { FloatRect bounds(paint_rect);
push_transparency_layer = true; paint_info.context.BeginLayer(1.0f, SkBlendMode::kDstIn, &bounds);
paint_info.context.BeginLayer(1.0f, SkBlendMode::kDstIn);
} else {
// TODO(fmalita): passing a dst-in xfer mode down to
// paintFillLayers/paintNinePieceImage seems dangerous: it is only
// correct if applied atomically (single draw call). While the heuristic
// above presumably ensures that is the case, this approach seems super
// fragile. We should investigate dropping this optimization in favour
// of the more robust layer branch above.
composite_op = SkBlendMode::kDstIn;
}
} }
LayoutRect paint_rect = LayoutRect(adjusted_paint_offset, frame_rect.Size());
PaintFillLayers(paint_info, Color::kTransparent, PaintFillLayers(paint_info, Color::kTransparent,
box_model.StyleRef().MaskLayers(), paint_rect, composite_op); box_model.StyleRef().MaskLayers(), paint_rect);
bool has_box_image = mask_box_image && mask_box_image->CanRender(); bool has_box_image = mask_box_image && mask_box_image->CanRender();
if (!has_box_image || !mask_box_image->IsLoaded()) { if (!has_box_image || !mask_box_image->IsLoaded()) {
...@@ -398,7 +387,7 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info, ...@@ -398,7 +387,7 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info,
NinePieceImagePainter::Paint(paint_info.context, box_model, NinePieceImagePainter::Paint(paint_info.context, box_model,
box_model.GetDocument(), GetNode(&box_model), box_model.GetDocument(), GetNode(&box_model),
paint_rect, box_model.StyleRef(), paint_rect, box_model.StyleRef(),
mask_nine_piece_image, composite_op); mask_nine_piece_image);
} else { } else {
// We have a mask image that spans multiple lines. // We have a mask image that spans multiple lines.
// FIXME: What the heck do we do with RTL here? The math we're using is // FIXME: What the heck do we do with RTL here? The math we're using is
...@@ -413,7 +402,7 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info, ...@@ -413,7 +402,7 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info,
NinePieceImagePainter::Paint(paint_info.context, box_model, NinePieceImagePainter::Paint(paint_info.context, box_model,
box_model.GetDocument(), GetNode(&box_model), box_model.GetDocument(), GetNode(&box_model),
image_strip_paint_rect, box_model.StyleRef(), image_strip_paint_rect, box_model.StyleRef(),
mask_nine_piece_image, composite_op); mask_nine_piece_image);
} }
if (push_transparency_layer) if (push_transparency_layer)
......
...@@ -24,8 +24,7 @@ void PaintPieces(GraphicsContext& context, ...@@ -24,8 +24,7 @@ void PaintPieces(GraphicsContext& context,
const ComputedStyle& style, const ComputedStyle& style,
const NinePieceImage& nine_piece_image, const NinePieceImage& nine_piece_image,
Image* image, Image* image,
IntSize image_size, IntSize image_size) {
SkBlendMode op) {
IntRectOutsets border_widths(style.BorderTopWidth(), style.BorderRightWidth(), IntRectOutsets border_widths(style.BorderTopWidth(), style.BorderRightWidth(),
style.BorderBottomWidth(), style.BorderBottomWidth(),
style.BorderLeftWidth()); style.BorderLeftWidth());
...@@ -42,12 +41,12 @@ void PaintPieces(GraphicsContext& context, ...@@ -42,12 +41,12 @@ void PaintPieces(GraphicsContext& context,
// Since there is no way for the developer to specify decode behavior, // Since there is no way for the developer to specify decode behavior,
// use kSync by default. // use kSync by default.
context.DrawImage(image, Image::kSyncDecode, draw_info.destination, context.DrawImage(image, Image::kSyncDecode, draw_info.destination,
&draw_info.source, op); &draw_info.source);
} else { } else {
context.DrawTiledImage(image, draw_info.destination, draw_info.source, context.DrawTiledImage(image, draw_info.destination, draw_info.source,
draw_info.tile_scale, draw_info.tile_scale,
draw_info.tile_rule.horizontal, draw_info.tile_rule.horizontal,
draw_info.tile_rule.vertical, op); draw_info.tile_rule.vertical);
} }
} }
} }
...@@ -61,8 +60,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context, ...@@ -61,8 +60,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context,
Node* node, Node* node,
const LayoutRect& rect, const LayoutRect& rect,
const ComputedStyle& style, const ComputedStyle& style,
const NinePieceImage& nine_piece_image, const NinePieceImage& nine_piece_image) {
SkBlendMode op) {
StyleImage* style_image = nine_piece_image.GetImage(); StyleImage* style_image = nine_piece_image.GetImage();
if (!style_image) if (!style_image)
return false; return false;
...@@ -104,7 +102,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context, ...@@ -104,7 +102,7 @@ bool NinePieceImagePainter::Paint(GraphicsContext& graphics_context,
ScopedInterpolationQuality interpolation_quality_scope( ScopedInterpolationQuality interpolation_quality_scope(
graphics_context, style.GetInterpolationQuality()); graphics_context, style.GetInterpolationQuality());
PaintPieces(graphics_context, border_image_rect, style, nine_piece_image, PaintPieces(graphics_context, border_image_rect, style, nine_piece_image,
image.get(), image_size, op); image.get(), image_size);
return true; return true;
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define NinePieceImagePainter_h #define NinePieceImagePainter_h
#include "platform/heap/Heap.h" #include "platform/heap/Heap.h"
#include "third_party/skia/include/core/SkBlendMode.h"
namespace blink { namespace blink {
...@@ -28,8 +27,7 @@ class NinePieceImagePainter { ...@@ -28,8 +27,7 @@ class NinePieceImagePainter {
Node*, Node*,
const LayoutRect&, const LayoutRect&,
const ComputedStyle&, const ComputedStyle&,
const NinePieceImage&, const NinePieceImage&);
SkBlendMode = SkBlendMode::kSrcOver);
private: private:
NinePieceImagePainter() = default; NinePieceImagePainter() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment