Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: Source/core/paint/SVGRootPainter.cpp

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/paint/SVGRootPainter.h" 6 #include "core/paint/SVGRootPainter.h"
7 7
8 #include "core/layout/svg/LayoutSVGRoot.h" 8 #include "core/layout/svg/LayoutSVGRoot.h"
9 #include "core/layout/svg/SVGResources.h" 9 #include "core/layout/svg/SVGResources.h"
10 #include "core/layout/svg/SVGResourcesCache.h" 10 #include "core/layout/svg/SVGResourcesCache.h"
11 #include "core/paint/BoxPainter.h" 11 #include "core/paint/BoxPainter.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.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 "wtf/Optional.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 21 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
21 { 22 {
22 // An empty viewport disables rendering. 23 // An empty viewport disables rendering.
23 if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty()) 24 if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty())
24 return; 25 return;
25 26
26 // SVG outlines are painted during PaintPhaseForeground. 27 // SVG outlines are painted during PaintPhaseForeground.
(...skipping 10 matching lines...) Expand all
37 // Don't paint if we don't have kids, except if we have filters we should pa int those. 38 // Don't paint if we don't have kids, except if we have filters we should pa int those.
38 if (!m_layoutSVGRoot.firstChild()) { 39 if (!m_layoutSVGRoot.firstChild()) {
39 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(&m_layoutSVGRoot); 40 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(&m_layoutSVGRoot);
40 if (!resources || !resources->filter()) 41 if (!resources || !resources->filter())
41 return; 42 return;
42 } 43 }
43 44
44 PaintInfo paintInfoBeforeFiltering(paintInfo); 45 PaintInfo paintInfoBeforeFiltering(paintInfo);
45 46
46 // Apply initial viewport clip. 47 // Apply initial viewport clip.
47 OwnPtr<ClipRecorder> clipRecorder; 48 Optional<ClipRecorder> clipRecorder;
48 if (m_layoutSVGRoot.shouldApplyViewportClip()) { 49 if (m_layoutSVGRoot.shouldApplyViewportClip()) {
49 // TODO(pdr): Clip the paint info cull rect here. 50 // TODO(pdr): Clip the paint info cull rect here.
50 clipRecorder = adoptPtr(new ClipRecorder(*paintInfoBeforeFiltering.conte xt, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), Layo utRect(pixelSnappedIntRect(m_layoutSVGRoot.overflowClipRect(paintOffset))))); 51 clipRecorder.emplace(*paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedI ntRect(m_layoutSVGRoot.overflowClipRect(paintOffset))));
51 } 52 }
52 53
53 // 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).
54 // 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.
55 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); 56 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
56 AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjust edPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTr ansform(); 57 AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjust edPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTr ansform();
57 paintInfoBeforeFiltering.updateCullRectForSVGTransform(paintOffsetToBorderBo x); 58 paintInfoBeforeFiltering.updateCullRectForSVGTransform(paintOffsetToBorderBo x);
58 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGRoot, paintOffsetToBorderBox); 59 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGRoot, paintOffsetToBorderBox);
59 60
60 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); 61 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering);
61 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) 62 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary())
62 return; 63 return;
63 64
64 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); 65 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint());
65 } 66 }
66 67
67 } // namespace blink 68 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698