| 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" | 
|  11 #include "platform/geometry/FloatRect.h" |  11 #include "platform/geometry/FloatRect.h" | 
|  12 #include "platform/geometry/LayoutPoint.h" |  12 #include "platform/geometry/LayoutPoint.h" | 
|  13 #include "platform/geometry/LayoutRect.h" |  13 #include "platform/geometry/LayoutRect.h" | 
|  14 #include "platform/graphics/BoxReflection.h" |  14 #include "platform/graphics/BoxReflection.h" | 
|  15 #include "platform/graphics/paint/DrawingRecorder.h" |  15 #include "platform/graphics/paint/DrawingRecorder.h" | 
|  16 #include "platform/graphics/paint/PaintRecordBuilder.h" |  16 #include "platform/graphics/paint/PaintRecordBuilder.h" | 
|  17  |  17  | 
|  18 namespace blink { |  18 namespace blink { | 
|  19  |  19  | 
|  20 BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer, |  20 BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer, | 
|  21                                          const ComputedStyle& style) { |  21                                          const ComputedStyle& style) { | 
|  22   const StyleReflection* reflectStyle = style.boxReflect(); |  22   const StyleReflection* reflectStyle = style.boxReflect(); | 
|  23  |  23  | 
|  24   LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject())->frameRect(); |  24   LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject()).frameRect(); | 
|  25   FloatRect frameRect(frameLayoutRect); |  25   FloatRect frameRect(frameLayoutRect); | 
|  26   BoxReflection::ReflectionDirection direction = |  26   BoxReflection::ReflectionDirection direction = | 
|  27       BoxReflection::VerticalReflection; |  27       BoxReflection::VerticalReflection; | 
|  28   float offset = 0; |  28   float offset = 0; | 
|  29   switch (reflectStyle->direction()) { |  29   switch (reflectStyle->direction()) { | 
|  30     case ReflectionAbove: |  30     case ReflectionAbove: | 
|  31       direction = BoxReflection::VerticalReflection; |  31       direction = BoxReflection::VerticalReflection; | 
|  32       offset = -floatValueForLength(reflectStyle->offset(), frameRect.height()); |  32       offset = -floatValueForLength(reflectStyle->offset(), frameRect.height()); | 
|  33       break; |  33       break; | 
|  34     case ReflectionBelow: |  34     case ReflectionBelow: | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  54     LayoutRect maskBoundingRect(maskRect); |  54     LayoutRect maskBoundingRect(maskRect); | 
|  55     maskBoundingRect.expand(style.imageOutsets(maskNinePiece)); |  55     maskBoundingRect.expand(style.imageOutsets(maskNinePiece)); | 
|  56     FloatRect maskBoundingFloatRect(maskBoundingRect); |  56     FloatRect maskBoundingFloatRect(maskBoundingRect); | 
|  57  |  57  | 
|  58     // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. |  58     // TODO(jbroman): PaintRecordBuilder + DrawingRecorder seems excessive. | 
|  59     // If NinePieceImagePainter operated on SkCanvas, we'd only need a |  59     // If NinePieceImagePainter operated on SkCanvas, we'd only need a | 
|  60     // PictureRecorder here. |  60     // PictureRecorder here. | 
|  61     PaintRecordBuilder builder(maskBoundingFloatRect); |  61     PaintRecordBuilder builder(maskBoundingFloatRect); | 
|  62     { |  62     { | 
|  63       GraphicsContext& context = builder.context(); |  63       GraphicsContext& context = builder.context(); | 
|  64       DrawingRecorder drawingRecorder(context, *layer.layoutObject(), |  64       DrawingRecorder drawingRecorder(context, layer.layoutObject(), | 
|  65                                       DisplayItem::kReflectionMask, |  65                                       DisplayItem::kReflectionMask, | 
|  66                                       maskBoundingFloatRect); |  66                                       maskBoundingFloatRect); | 
|  67       NinePieceImagePainter(*layer.layoutObject()) |  67       NinePieceImagePainter(layer.layoutObject()) | 
|  68           .paint(builder.context(), maskRect, style, maskNinePiece, |  68           .paint(builder.context(), maskRect, style, maskNinePiece, | 
|  69                  SkBlendMode::kSrcOver); |  69                  SkBlendMode::kSrcOver); | 
|  70     } |  70     } | 
|  71     mask = builder.endRecording(); |  71     mask = builder.endRecording(); | 
|  72   } |  72   } | 
|  73  |  73  | 
|  74   return BoxReflection(direction, offset, std::move(mask)); |  74   return BoxReflection(direction, offset, std::move(mask)); | 
|  75 } |  75 } | 
|  76  |  76  | 
|  77 }  // namespace blink |  77 }  // namespace blink | 
| OLD | NEW |