| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/NinePieceImageGrid.h" | 5 #include "core/paint/NinePieceImageGrid.h" |
| 6 | 6 |
| 7 #include "core/style/ComputedStyle.h" | 7 #include "core/style/ComputedStyle.h" |
| 8 #include "core/style/NinePieceImage.h" | 8 #include "core/style/NinePieceImage.h" |
| 9 #include "platform/LengthFunctions.h" | 9 #include "platform/LengthFunctions.h" |
| 10 #include "platform/geometry/FloatSize.h" | 10 #include "platform/geometry/FloatSize.h" |
| 11 #include "platform/geometry/IntSize.h" | 11 #include "platform/geometry/IntSize.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 static int computeEdgeWidth(const BorderImageLength& borderSlice, | 15 static int computeEdgeWidth(const BorderImageLength& borderSlice, |
| 16 int borderSide, | 16 int borderSide, |
| 17 int imageSide, | 17 int imageSide, |
| 18 int boxExtent) { | 18 int boxExtent) { |
| 19 if (borderSlice.isNumber()) | 19 if (borderSlice.isNumber()) |
| 20 return borderSlice.number() * borderSide; | 20 return borderSlice.number() * borderSide; |
| 21 if (borderSlice.length().isAuto()) | 21 if (borderSlice.length().isAuto()) |
| 22 return imageSide; | 22 return imageSide; |
| 23 return valueForLength(borderSlice.length(), LayoutUnit(boxExtent)).toInt(); | 23 return valueForLength(borderSlice.length(), LayoutUnit(boxExtent)).round(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 static int computeEdgeSlice(const Length& slice, int maximum) { | 26 static int computeEdgeSlice(const Length& slice, int maximum) { |
| 27 return std::min<int>(maximum, | 27 return std::min<int>(maximum, |
| 28 valueForLength(slice, LayoutUnit(maximum)).toInt()); | 28 valueForLength(slice, LayoutUnit(maximum)).round()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 NinePieceImageGrid::NinePieceImageGrid(const NinePieceImage& ninePieceImage, | 31 NinePieceImageGrid::NinePieceImageGrid(const NinePieceImage& ninePieceImage, |
| 32 IntSize imageSize, | 32 IntSize imageSize, |
| 33 IntRect borderImageArea, | 33 IntRect borderImageArea, |
| 34 const IntRectOutsets& borderWidths) | 34 const IntRectOutsets& borderWidths) |
| 35 : m_borderImageArea(borderImageArea), | 35 : m_borderImageArea(borderImageArea), |
| 36 m_imageSize(imageSize), | 36 m_imageSize(imageSize), |
| 37 m_horizontalTileRule((Image::TileRule)ninePieceImage.horizontalRule()), | 37 m_horizontalTileRule((Image::TileRule)ninePieceImage.horizontalRule()), |
| 38 m_verticalTileRule((Image::TileRule)ninePieceImage.verticalRule()), | 38 m_verticalTileRule((Image::TileRule)ninePieceImage.verticalRule()), |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 drawInfo.source.scale(imageScaleFactor); | 300 drawInfo.source.scale(imageScaleFactor); |
| 301 | 301 |
| 302 // Compensate for source scaling by scaling down the individual tiles. | 302 // Compensate for source scaling by scaling down the individual tiles. |
| 303 drawInfo.tileScale.scale(1 / imageScaleFactor); | 303 drawInfo.tileScale.scale(1 / imageScaleFactor); |
| 304 } | 304 } |
| 305 | 305 |
| 306 return drawInfo; | 306 return drawInfo; |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |