| 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; | |
| 55 const NinePieceImage& mask_nine_piece = reflect_style->Mask(); | 54 const NinePieceImage& mask_nine_piece = reflect_style->Mask(); |
| 56 if (mask_nine_piece.HasImage()) { | 55 if (!mask_nine_piece.HasImage()) |
| 57 LayoutRect mask_rect(LayoutPoint(), frame_layout_rect.Size()); | 56 return BoxReflection(direction, offset, nullptr, FloatRect()); |
| 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); | |
| 61 | 57 |
| 62 // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. | 58 LayoutRect mask_rect(LayoutPoint(), frame_layout_rect.Size()); |
| 63 // If NinePieceImagePainter operated on SkCanvas, we'd only need a | 59 LayoutRect mask_bounding_rect(mask_rect); |
| 64 // PictureRecorder here. | 60 mask_bounding_rect.Expand(style.ImageOutsets(mask_nine_piece)); |
| 65 PaintRecordBuilder builder(mask_bounding_float_rect); | 61 FloatRect mask_bounding_float_rect(mask_bounding_rect); |
| 66 { | 62 |
| 67 GraphicsContext& context = builder.Context(); | 63 // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. |
| 68 DrawingRecorder drawing_recorder(context, layer.GetLayoutObject(), | 64 // If NinePieceImagePainter operated on SkCanvas, we'd only need a |
| 69 DisplayItem::kReflectionMask, | 65 // PictureRecorder here. |
| 70 mask_bounding_float_rect); | 66 PaintRecordBuilder builder(mask_bounding_float_rect); |
| 71 NinePieceImagePainter().Paint(builder.Context(), layer.GetLayoutObject(), | 67 { |
| 72 mask_rect, style, mask_nine_piece, | 68 GraphicsContext& context = builder.Context(); |
| 73 SkBlendMode::kSrcOver); | 69 DrawingRecorder drawing_recorder(context, layer.GetLayoutObject(), |
| 74 } | 70 DisplayItem::kReflectionMask, |
| 75 mask = builder.EndRecording(); | 71 mask_bounding_float_rect); |
| 72 NinePieceImagePainter().Paint(builder.Context(), layer.GetLayoutObject(), |
| 73 mask_rect, style, mask_nine_piece, |
| 74 SkBlendMode::kSrcOver); |
| 76 } | 75 } |
| 77 | 76 return BoxReflection(direction, offset, builder.EndRecording(), |
| 78 return BoxReflection(direction, offset, std::move(mask)); | 77 mask_bounding_float_rect); |
| 79 } | 78 } |
| 80 | 79 |
| 81 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |