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" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 ASSERT(svg); | 38 ASSERT(svg); |
| 39 if (svg->hasEmptyViewBox()) | 39 if (svg->hasEmptyViewBox()) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 // Don't paint if we don't have kids, except if we have filters we should pa int those. | 42 // 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)) | 43 if (!m_layoutSVGRoot.firstChild() && !SVGLayoutSupport::hasFilterResource(m_ layoutSVGRoot)) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 PaintInfo paintInfoBeforeFiltering(paintInfo); | 46 PaintInfo paintInfoBeforeFiltering(paintInfo); |
| 47 | 47 |
| 48 Optional<ScopedPaintChunkProperties> transformPropertyScope; | 48 Optional<ScopedPaintChunkProperties> propertyScope; |
| 49 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 49 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 50 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties(); | 50 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties(); |
| 51 if (objectProperties && objectProperties->svgLocalTransform()) { | 51 // If a transform exists, we can rely on a layer existing to apply it. |
| 52 DCHECK(!objectProperties || !objectProperties->transform() || m_layoutSV GRoot.hasLayer()); | |
|
jbroman
2016/06/10 18:33:52
To be clear, "layer" here is blink::PaintLayer, ri
pdr.
2016/06/10 19:45:46
Yeah. I updated the comment to specify "paint laye
| |
| 53 if (objectProperties && objectProperties->svgLocalToBorderBoxTransform() ) { | |
| 52 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon troller(); | 54 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon troller(); |
| 53 PaintChunkProperties properties(paintController.currentPaintChunkPro perties()); | 55 PaintChunkProperties properties(paintController.currentPaintChunkPro perties()); |
| 54 properties.transform = objectProperties->svgLocalTransform(); | 56 properties.transform = objectProperties->svgLocalToBorderBoxTransfor m(); |
| 55 transformPropertyScope.emplace(paintController, properties); | 57 propertyScope.emplace(paintController, properties); |
| 56 } else if (objectProperties && objectProperties->paintOffsetTranslation( ) && !m_layoutSVGRoot.hasLayer()) { | |
| 57 // TODO(pdr): Always create an svgLocalTransform and remove this pai nt offset quirk. | |
| 58 // At the HTML->SVG boundary, SVGRoot will have a paint offset trans form | |
| 59 // paint property but may not have a PaintLayer, so we need to updat e the | |
| 60 // paint properties here since they will not be updated by PaintLaye r | |
| 61 // (See: PaintPropertyTreeBuilder::createPaintOffsetTranslationIfNee ded). | |
| 62 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon troller(); | |
| 63 PaintChunkProperties properties(paintController.currentPaintChunkPro perties()); | |
| 64 properties.transform = objectProperties->paintOffsetTranslation(); | |
| 65 transformPropertyScope.emplace(paintController, properties); | |
| 66 } | 58 } |
| 67 } | 59 } |
| 68 | 60 |
| 69 // Apply initial viewport clip. | 61 // Apply initial viewport clip. |
| 70 Optional<ClipRecorder> clipRecorder; | 62 Optional<ClipRecorder> clipRecorder; |
| 71 if (m_layoutSVGRoot.shouldApplyViewportClip()) { | 63 if (m_layoutSVGRoot.shouldApplyViewportClip()) { |
| 72 // TODO(pdr): Clip the paint info cull rect here. | 64 // TODO(pdr): Clip the paint info cull rect here. |
| 73 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), pixelSnappedIntRect(m_lay outSVGRoot.overflowClipRect(paintOffset))); | 65 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), pixelSnappedIntRect(m_lay outSVGRoot.overflowClipRect(paintOffset))); |
| 74 } | 66 } |
| 75 | 67 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 90 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) | 82 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) |
| 91 return; | 83 return; |
| 92 | 84 |
| 93 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); | 85 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); |
| 94 | 86 |
| 95 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); | 87 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); |
| 96 timing.markFirstContentfulPaint(); | 88 timing.markFirstContentfulPaint(); |
| 97 } | 89 } |
| 98 | 90 |
| 99 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |