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 26 matching lines...) Expand all Loading... |
37 case ReflectionLeft: | 37 case ReflectionLeft: |
38 direction = BoxReflection::HorizontalReflection; | 38 direction = BoxReflection::HorizontalReflection; |
39 offset = -floatValueForLength(reflectStyle->offset(), frameRect.width())
; | 39 offset = -floatValueForLength(reflectStyle->offset(), frameRect.width())
; |
40 break; | 40 break; |
41 case ReflectionRight: | 41 case ReflectionRight: |
42 direction = BoxReflection::HorizontalReflection; | 42 direction = BoxReflection::HorizontalReflection; |
43 offset = 2 * frameRect.width() + floatValueForLength(reflectStyle->offse
t(), frameRect.width()); | 43 offset = 2 * frameRect.width() + floatValueForLength(reflectStyle->offse
t(), frameRect.width()); |
44 break; | 44 break; |
45 } | 45 } |
46 | 46 |
47 RefPtr<SkPicture> mask; | 47 sk_sp<SkPicture> mask; |
48 const NinePieceImage& maskNinePiece = reflectStyle->mask(); | 48 const NinePieceImage& maskNinePiece = reflectStyle->mask(); |
49 if (maskNinePiece.hasImage()) { | 49 if (maskNinePiece.hasImage()) { |
50 LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size()); | 50 LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size()); |
51 LayoutRect maskBoundingRect(maskRect); | 51 LayoutRect maskBoundingRect(maskRect); |
52 maskBoundingRect.expand(style.imageOutsets(maskNinePiece)); | 52 maskBoundingRect.expand(style.imageOutsets(maskNinePiece)); |
53 FloatRect maskBoundingFloatRect(maskBoundingRect); | 53 FloatRect maskBoundingFloatRect(maskBoundingRect); |
54 | 54 |
55 // TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive. | 55 // TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive. |
56 // If NinePieceImagePainter operated on SkCanvas, we'd only need an | 56 // If NinePieceImagePainter operated on SkCanvas, we'd only need an |
57 // SkPictureRecorder here. | 57 // SkPictureRecorder here. |
58 SkPictureBuilder recorder(maskBoundingFloatRect); | 58 SkPictureBuilder recorder(maskBoundingFloatRect); |
59 { | 59 { |
60 GraphicsContext& context = recorder.context(); | 60 GraphicsContext& context = recorder.context(); |
61 DrawingRecorder drawingRecorder(context, *layer.layoutObject(), Disp
layItem::kReflectionMask, maskBoundingFloatRect); | 61 DrawingRecorder drawingRecorder(context, *layer.layoutObject(), Disp
layItem::kReflectionMask, maskBoundingFloatRect); |
62 NinePieceImagePainter(*layer.layoutObject()).paint( | 62 NinePieceImagePainter(*layer.layoutObject()).paint( |
63 recorder.context(), maskRect, style, maskNinePiece, SkXfermode::
kSrcOver_Mode); | 63 recorder.context(), maskRect, style, maskNinePiece, SkXfermode::
kSrcOver_Mode); |
64 } | 64 } |
65 mask = recorder.endRecording(); | 65 mask = recorder.endRecording(); |
66 } | 66 } |
67 | 67 |
68 return BoxReflection(direction, offset, mask); | 68 return BoxReflection(direction, offset, std::move(mask)); |
69 } | 69 } |
70 | 70 |
71 } // namespace blink | 71 } // namespace blink |
OLD | NEW |