Chromium Code Reviews| 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" |
| 11 #include "core/paint/PaintInfo.h" | 11 #include "core/paint/PaintInfo.h" |
| 12 #include "core/paint/PaintTiming.h" | 12 #include "core/paint/PaintTiming.h" |
| 13 #include "core/paint/SVGPaintContext.h" | 13 #include "core/paint/SVGPaintContext.h" |
| 14 #include "core/paint/TransformRecorder.h" | 14 #include "core/paint/TransformRecorder.h" |
| 15 #include "core/svg/SVGSVGElement.h" | 15 #include "core/svg/SVGSVGElement.h" |
| 16 #include "platform/graphics/paint/ClipRecorder.h" | 16 #include "platform/graphics/paint/ClipRecorder.h" |
| 17 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" | |
| 18 #include "wtf/Optional.h" | 17 #include "wtf/Optional.h" |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| 21 | 20 |
| 22 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) | 21 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) |
| 23 { | 22 { |
| 24 // Pixel-snap to match BoxPainter's alignment. | 23 // Pixel-snap to match BoxPainter's alignment. |
| 25 const IntRect adjustedRect = pixelSnappedIntRect(paintOffset, m_layoutSVGRoo t.size()); | 24 const IntRect adjustedRect = pixelSnappedIntRect(paintOffset, m_layoutSVGRoo t.size()); |
| 26 | 25 |
| 27 // An empty viewport disables rendering. | 26 // An empty viewport disables rendering. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 38 ASSERT(svg); | 37 ASSERT(svg); |
| 39 if (svg->hasEmptyViewBox()) | 38 if (svg->hasEmptyViewBox()) |
| 40 return; | 39 return; |
| 41 | 40 |
| 42 // Don't paint if we don't have kids, except if we have filters we should pa int those. | 41 // Don't paint if we don't have kids, except if we have filters we should pa int those. |
| 43 if (!m_layoutSVGRoot.firstChild() && !SVGLayoutSupport::hasFilterResource(m_ layoutSVGRoot)) | 42 if (!m_layoutSVGRoot.firstChild() && !SVGLayoutSupport::hasFilterResource(m_ layoutSVGRoot)) |
| 44 return; | 43 return; |
| 45 | 44 |
| 46 PaintInfo paintInfoBeforeFiltering(paintInfo); | 45 PaintInfo paintInfoBeforeFiltering(paintInfo); |
| 47 | 46 |
| 48 Optional<ScopedPaintChunkProperties> propertyScope; | |
| 49 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 50 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties(); | |
| 51 // If a transform exists, we can rely on a layer existing to apply it. | |
| 52 DCHECK(!objectProperties || !objectProperties->transform() || m_layoutSV GRoot.hasLayer()); | |
| 53 if (objectProperties && objectProperties->svgLocalToBorderBoxTransform() ) { | |
| 54 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon troller(); | |
| 55 PaintChunkProperties properties(paintController.currentPaintChunkPro perties()); | |
| 56 properties.transform = objectProperties->svgLocalToBorderBoxTransfor m(); | |
| 57 propertyScope.emplace(paintController, properties); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 // Apply initial viewport clip. | 47 // Apply initial viewport clip. |
| 62 Optional<ClipRecorder> clipRecorder; | 48 Optional<ClipRecorder> clipRecorder; |
| 63 if (m_layoutSVGRoot.shouldApplyViewportClip()) { | 49 if (m_layoutSVGRoot.shouldApplyViewportClip()) { |
| 64 // TODO(pdr): Clip the paint info cull rect here. | 50 // TODO(pdr): Clip the paint info cull rect here. |
| 65 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), pixelSnappedIntRect(m_lay outSVGRoot.overflowClipRect(paintOffset))); | 51 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), pixelSnappedIntRect(m_lay outSVGRoot.overflowClipRect(paintOffset))); |
| 66 } | 52 } |
| 67 | 53 |
| 68 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects). | 54 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects). |
| 69 // Transform from our paint container's coordinate system to our local coord s. | 55 // Transform from our paint container's coordinate system to our local coord s. |
| 70 AffineTransform paintOffsetToBorderBox = | 56 AffineTransform paintOffsetToBorderBox = |
| 71 AffineTransform::translation(adjustedRect.x(), adjustedRect.y()); | 57 AffineTransform::translation(adjustedRect.x(), adjustedRect.y()); |
| 72 // Compensate for size snapping. | 58 // Compensate for size snapping. |
| 73 paintOffsetToBorderBox.scale( | 59 paintOffsetToBorderBox.scale( |
| 74 adjustedRect.width() / m_layoutSVGRoot.size().width().toFloat(), | 60 adjustedRect.width() / m_layoutSVGRoot.size().width().toFloat(), |
| 75 adjustedRect.height() / m_layoutSVGRoot.size().height().toFloat()); | 61 adjustedRect.height() / m_layoutSVGRoot.size().height().toFloat()); |
| 76 paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform()) ; | 62 paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform()) ; |
|
trchen
2016/06/13 23:26:52
PaintPropertyTreeBuilder::updateSvgLocalToBorderBo
| |
| 77 | 63 |
| 78 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox); | 64 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox); |
| 79 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo utSVGRoot, paintOffsetToBorderBox); | 65 SVGTransformContext transformContext(paintInfoBeforeFiltering.context, m_lay outSVGRoot, paintOffsetToBorderBox); |
| 80 | 66 |
| 81 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); | 67 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); |
| 82 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) | 68 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) |
| 83 return; | 69 return; |
| 84 | 70 |
| 85 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); | 71 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); |
| 86 | 72 |
| 87 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); | 73 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); |
| 88 timing.markFirstContentfulPaint(); | 74 timing.markFirstContentfulPaint(); |
| 89 } | 75 } |
| 90 | 76 |
| 91 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |