| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/SVGRootPainter.h" | 5 #include "core/paint/SVGRootPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/svg/LayoutSVGRoot.h" | 7 #include "core/layout/svg/LayoutSVGRoot.h" |
| 8 #include "core/layout/svg/SVGLayoutSupport.h" | 8 #include "core/layout/svg/SVGLayoutSupport.h" |
| 9 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
| 10 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 IntRect SVGRootPainter::pixelSnappedSize(const LayoutPoint& paintOffset) const | 21 IntRect SVGRootPainter::pixelSnappedSize(const LayoutPoint& paintOffset) const |
| 22 { | 22 { |
| 23 return pixelSnappedIntRect(paintOffset, m_layoutSVGRoot.size()); | 23 return pixelSnappedIntRect(paintOffset, m_layoutSVGRoot.size()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 AffineTransform SVGRootPainter::transformToPixelSnappedBorderBox(const LayoutPoi
nt& paintOffset) const | 26 AffineTransform SVGRootPainter::transformToPixelSnappedBorderBox(const LayoutPoi
nt& paintOffset) const |
| 27 { | 27 { |
| 28 const IntRect snappedSize = pixelSnappedSize(paintOffset); | 28 const IntRect snappedSize = pixelSnappedSize(paintOffset); |
| 29 AffineTransform paintOffsetToBorderBox = | 29 AffineTransform paintOffsetToBorderBox = |
| 30 AffineTransform::translation(snappedSize.x(), snappedSize.y()); | 30 AffineTransform::translation(snappedSize.x(), snappedSize.y()); |
| 31 paintOffsetToBorderBox.scale( | 31 LayoutSize size = m_layoutSVGRoot.size(); |
| 32 snappedSize.width() / m_layoutSVGRoot.size().width().toFloat(), | 32 if (!size.isEmpty()) { |
| 33 snappedSize.height() / m_layoutSVGRoot.size().height().toFloat()); | 33 paintOffsetToBorderBox.scale( |
| 34 snappedSize.width() / size.width().toFloat(), |
| 35 snappedSize.height() / size.height().toFloat()); |
| 36 } |
| 34 paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform())
; | 37 paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform())
; |
| 35 return paintOffsetToBorderBox; | 38 return paintOffsetToBorderBox; |
| 36 } | 39 } |
| 37 | 40 |
| 38 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 41 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 39 { | 42 { |
| 40 // An empty viewport disables rendering. | 43 // An empty viewport disables rendering. |
| 41 if (pixelSnappedSize(paintOffset).isEmpty()) | 44 if (pixelSnappedSize(paintOffset).isEmpty()) |
| 42 return; | 45 return; |
| 43 | 46 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.
applyClipMaskAndFilterIfNecessary()) | 72 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.
applyClipMaskAndFilterIfNecessary()) |
| 70 return; | 73 return; |
| 71 | 74 |
| 72 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); | 75 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); |
| 73 | 76 |
| 74 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t
opDocument()); | 77 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t
opDocument()); |
| 75 timing.markFirstContentfulPaint(); | 78 timing.markFirstContentfulPaint(); |
| 76 } | 79 } |
| 77 | 80 |
| 78 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |