OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/BoxReflectionUtils.h" | 5 #include "core/paint/BoxReflectionUtils.h" |
6 | 6 |
7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
8 #include "core/paint/NinePieceImagePainter.h" | 8 #include "core/paint/NinePieceImagePainter.h" |
9 #include "core/paint/PaintLayer.h" | 9 #include "core/paint/PaintLayer.h" |
10 #include "platform/LengthFunctions.h" | 10 #include "platform/LengthFunctions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 offset = | 44 offset = |
45 -FloatValueForLength(reflect_style->Offset(), frame_rect.Width()); | 45 -FloatValueForLength(reflect_style->Offset(), frame_rect.Width()); |
46 break; | 46 break; |
47 case kReflectionRight: | 47 case kReflectionRight: |
48 direction = BoxReflection::kHorizontalReflection; | 48 direction = BoxReflection::kHorizontalReflection; |
49 offset = 2 * frame_rect.Width() + | 49 offset = 2 * frame_rect.Width() + |
50 FloatValueForLength(reflect_style->Offset(), frame_rect.Width()); | 50 FloatValueForLength(reflect_style->Offset(), frame_rect.Width()); |
51 break; | 51 break; |
52 } | 52 } |
53 | 53 |
| 54 sk_sp<PaintRecord> mask; |
54 const NinePieceImage& mask_nine_piece = reflect_style->Mask(); | 55 const NinePieceImage& mask_nine_piece = reflect_style->Mask(); |
55 if (!mask_nine_piece.HasImage()) | 56 if (mask_nine_piece.HasImage()) { |
56 return BoxReflection(direction, offset, nullptr, FloatRect()); | 57 LayoutRect mask_rect(LayoutPoint(), frame_layout_rect.Size()); |
| 58 LayoutRect mask_bounding_rect(mask_rect); |
| 59 mask_bounding_rect.Expand(style.ImageOutsets(mask_nine_piece)); |
| 60 FloatRect mask_bounding_float_rect(mask_bounding_rect); |
57 | 61 |
58 LayoutRect mask_rect(LayoutPoint(), frame_layout_rect.Size()); | 62 // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. |
59 LayoutRect mask_bounding_rect(mask_rect); | 63 // If NinePieceImagePainter operated on SkCanvas, we'd only need a |
60 mask_bounding_rect.Expand(style.ImageOutsets(mask_nine_piece)); | 64 // PictureRecorder here. |
61 FloatRect mask_bounding_float_rect(mask_bounding_rect); | 65 PaintRecordBuilder builder(mask_bounding_float_rect); |
| 66 { |
| 67 GraphicsContext& context = builder.Context(); |
| 68 DrawingRecorder drawing_recorder(context, layer.GetLayoutObject(), |
| 69 DisplayItem::kReflectionMask, |
| 70 mask_bounding_float_rect); |
| 71 NinePieceImagePainter().Paint(builder.Context(), layer.GetLayoutObject(), |
| 72 mask_rect, style, mask_nine_piece, |
| 73 SkBlendMode::kSrcOver); |
| 74 } |
| 75 mask = builder.EndRecording(); |
| 76 } |
62 | 77 |
63 // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. | 78 return BoxReflection(direction, offset, std::move(mask)); |
64 // If NinePieceImagePainter operated on SkCanvas, we'd only need a | |
65 // PictureRecorder here. | |
66 PaintRecordBuilder builder(mask_bounding_float_rect); | |
67 { | |
68 GraphicsContext& context = builder.Context(); | |
69 DrawingRecorder drawing_recorder(context, layer.GetLayoutObject(), | |
70 DisplayItem::kReflectionMask, | |
71 mask_bounding_float_rect); | |
72 NinePieceImagePainter().Paint(builder.Context(), layer.GetLayoutObject(), | |
73 mask_rect, style, mask_nine_piece, | |
74 SkBlendMode::kSrcOver); | |
75 } | |
76 return BoxReflection(direction, offset, builder.EndRecording(), | |
77 mask_bounding_float_rect); | |
78 } | 79 } |
79 | 80 |
80 } // namespace blink | 81 } // namespace blink |
OLD | NEW |