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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourcePattern.cpp

Issue 869323003: Oilpan: move RenderObjects off heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review-induced improvements Created 5 years, 10 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 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * Copyright 2014 The Chromium Authors. All rights reserved. 4 * Copyright 2014 The Chromium Authors. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 25 matching lines...) Expand all
36 struct PatternData { 36 struct PatternData {
37 WTF_MAKE_FAST_ALLOCATED; 37 WTF_MAKE_FAST_ALLOCATED;
38 public: 38 public:
39 RefPtr<Pattern> pattern; 39 RefPtr<Pattern> pattern;
40 AffineTransform transform; 40 AffineTransform transform;
41 }; 41 };
42 42
43 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node) 43 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node)
44 : RenderSVGResourcePaintServer(node) 44 : RenderSVGResourcePaintServer(node)
45 , m_shouldCollectPatternAttributes(true) 45 , m_shouldCollectPatternAttributes(true)
46 #if ENABLE(OILPAN)
47 , m_attributesWrapper(PatternAttributesWrapper::create())
48 #endif
46 { 49 {
47 } 50 }
48 51
49 void RenderSVGResourcePattern::trace(Visitor* visitor)
50 {
51 visitor->trace(m_attributes);
52 RenderSVGResourcePaintServer::trace(visitor);
53 }
54
55 void RenderSVGResourcePattern::removeAllClientsFromCache(bool markForInvalidatio n) 52 void RenderSVGResourcePattern::removeAllClientsFromCache(bool markForInvalidatio n)
56 { 53 {
57 m_patternMap.clear(); 54 m_patternMap.clear();
58 m_shouldCollectPatternAttributes = true; 55 m_shouldCollectPatternAttributes = true;
59 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare ntOnlyInvalidation); 56 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare ntOnlyInvalidation);
60 } 57 }
61 58
62 void RenderSVGResourcePattern::removeClientFromCache(RenderObject* client, bool markForInvalidation) 59 void RenderSVGResourcePattern::removeClientFromCache(RenderObject* client, bool markForInvalidation)
63 { 60 {
64 ASSERT(client); 61 ASSERT(client);
(...skipping 10 matching lines...) Expand all
75 // Hopefully that will be addressed at some point, and then we can optimize the lookup. 72 // Hopefully that will be addressed at some point, and then we can optimize the lookup.
76 if (PatternData* currentData = m_patternMap.get(&object)) 73 if (PatternData* currentData = m_patternMap.get(&object))
77 return currentData; 74 return currentData;
78 75
79 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu e.get(); 76 return m_patternMap.set(&object, buildPatternData(object)).storedValue->valu e.get();
80 } 77 }
81 78
82 PassOwnPtr<PatternData> RenderSVGResourcePattern::buildPatternData(const RenderO bject& object) 79 PassOwnPtr<PatternData> RenderSVGResourcePattern::buildPatternData(const RenderO bject& object)
83 { 80 {
84 // If we couldn't determine the pattern content element root, stop here. 81 // If we couldn't determine the pattern content element root, stop here.
85 if (!m_attributes.patternContentElement()) 82 const PatternAttributes& attributes = this->attributes();
83 if (!attributes.patternContentElement())
86 return nullptr; 84 return nullptr;
87 85
88 // An empty viewBox disables rendering. 86 // An empty viewBox disables rendering.
89 if (m_attributes.hasViewBox() && m_attributes.viewBox().isEmpty()) 87 if (attributes.hasViewBox() && attributes.viewBox().isEmpty())
90 return nullptr; 88 return nullptr;
91 89
92 ASSERT(element()); 90 ASSERT(element());
93 // Compute tile metrics. 91 // Compute tile metrics.
94 FloatRect clientBoundingBox = object.objectBoundingBox(); 92 FloatRect clientBoundingBox = object.objectBoundingBox();
95 FloatRect tileBounds = SVGLengthContext::resolveRectangle(element(), 93 FloatRect tileBounds = SVGLengthContext::resolveRectangle(element(),
96 m_attributes.patternUnits(), clientBoundingBox, 94 attributes.patternUnits(), clientBoundingBox,
97 m_attributes.x(), m_attributes.y(), m_attributes.width(), m_attributes.h eight()); 95 attributes.x(), attributes.y(), attributes.width(), attributes.height()) ;
98 if (tileBounds.isEmpty()) 96 if (tileBounds.isEmpty())
99 return nullptr; 97 return nullptr;
100 98
101 AffineTransform tileTransform; 99 AffineTransform tileTransform;
102 if (m_attributes.hasViewBox()) { 100 if (attributes.hasViewBox()) {
103 if (m_attributes.viewBox().isEmpty()) 101 if (attributes.viewBox().isEmpty())
104 return nullptr; 102 return nullptr;
105 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(m_attributes.vie wBox(), 103 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB ox(),
106 m_attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.h eight()); 104 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei ght());
107 } else { 105 } else {
108 // A viewbox overrides patternContentUnits, per spec. 106 // A viewbox overrides patternContentUnits, per spec.
109 if (m_attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OB JECTBOUNDINGBOX) 107 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE CTBOUNDINGBOX)
110 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei ght()); 108 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei ght());
111 } 109 }
112 110
113 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); 111 OwnPtr<PatternData> patternData = adoptPtr(new PatternData);
114 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t ileTransform)); 112 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t ileTransform));
115 113
116 // Compute pattern space transformation. 114 // Compute pattern space transformation.
117 patternData->transform.translate(tileBounds.x(), tileBounds.y()); 115 patternData->transform.translate(tileBounds.x(), tileBounds.y());
118 AffineTransform patternTransform = m_attributes.patternTransform(); 116 AffineTransform patternTransform = attributes.patternTransform();
119 if (!patternTransform.isIdentity()) 117 if (!patternTransform.isIdentity())
120 patternData->transform = patternTransform * patternData->transform; 118 patternData->transform = patternTransform * patternData->transform;
121 119
122 return patternData.release(); 120 return patternData.release();
123 } 121 }
124 122
125 SVGPaintServer RenderSVGResourcePattern::preparePaintServer(const RenderObject& object) 123 SVGPaintServer RenderSVGResourcePattern::preparePaintServer(const RenderObject& object)
126 { 124 {
127 clearInvalidationMask(); 125 clearInvalidationMask();
128 126
129 SVGPatternElement* patternElement = toSVGPatternElement(element()); 127 SVGPatternElement* patternElement = toSVGPatternElement(element());
130 if (!patternElement) 128 if (!patternElement)
131 return SVGPaintServer::invalid(); 129 return SVGPaintServer::invalid();
132 130
133 if (m_shouldCollectPatternAttributes) { 131 if (m_shouldCollectPatternAttributes) {
134 patternElement->synchronizeAnimatedSVGAttribute(anyQName()); 132 patternElement->synchronizeAnimatedSVGAttribute(anyQName());
135 133
134 #if ENABLE(OILPAN)
135 m_attributesWrapper->set(PatternAttributes());
136 #else
136 m_attributes = PatternAttributes(); 137 m_attributes = PatternAttributes();
137 patternElement->collectPatternAttributes(m_attributes); 138 #endif
139 patternElement->collectPatternAttributes(mutableAttributes());
138 m_shouldCollectPatternAttributes = false; 140 m_shouldCollectPatternAttributes = false;
139 } 141 }
140 142
141 // Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified, 143 // Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified,
142 // then the given effect (e.g. a gradient or a filter) will be ignored. 144 // then the given effect (e.g. a gradient or a filter) will be ignored.
143 FloatRect objectBoundingBox = object.objectBoundingBox(); 145 FloatRect objectBoundingBox = object.objectBoundingBox();
144 if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN GBOX && objectBoundingBox.isEmpty()) 146 if (attributes().patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN GBOX && objectBoundingBox.isEmpty())
145 return SVGPaintServer::invalid(); 147 return SVGPaintServer::invalid();
146 148
147 PatternData* patternData = patternForRenderer(object); 149 PatternData* patternData = patternForRenderer(object);
148 if (!patternData || !patternData->pattern) 150 if (!patternData || !patternData->pattern)
149 return SVGPaintServer::invalid(); 151 return SVGPaintServer::invalid();
150 152
151 patternData->pattern->setPatternSpaceTransform(patternData->transform); 153 patternData->pattern->setPatternSpaceTransform(patternData->transform);
152 154
153 return SVGPaintServer(patternData->pattern); 155 return SVGPaintServer(patternData->pattern);
154 } 156 }
155 157
156 PassRefPtr<const SkPicture> RenderSVGResourcePattern::asPicture(const FloatRect& tileBounds, 158 PassRefPtr<const SkPicture> RenderSVGResourcePattern::asPicture(const FloatRect& tileBounds,
157 const AffineTransform& tileTransform) const 159 const AffineTransform& tileTransform) const
158 { 160 {
159 ASSERT(!m_shouldCollectPatternAttributes); 161 ASSERT(!m_shouldCollectPatternAttributes);
160 162
161 AffineTransform contentTransform; 163 AffineTransform contentTransform;
162 if (m_attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECT BOUNDINGBOX) 164 if (attributes().patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECT BOUNDINGBOX)
163 contentTransform = tileTransform; 165 contentTransform = tileTransform;
164 166
165 // Draw the content into a Picture. 167 // Draw the content into a Picture.
166 OwnPtr<DisplayItemList> displayItemList; 168 OwnPtr<DisplayItemList> displayItemList;
167 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 169 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
168 displayItemList = DisplayItemList::create(); 170 displayItemList = DisplayItemList::create();
169 GraphicsContext recordingContext(nullptr, displayItemList.get()); 171 GraphicsContext recordingContext(nullptr, displayItemList.get());
170 recordingContext.beginRecording(FloatRect(FloatPoint(), tileBounds.size())); 172 recordingContext.beginRecording(FloatRect(FloatPoint(), tileBounds.size()));
171 173
172 ASSERT(m_attributes.patternContentElement()); 174 ASSERT(attributes().patternContentElement());
173 RenderSVGResourceContainer* patternRenderer = 175 RenderSVGResourceContainer* patternRenderer =
174 toRenderSVGResourceContainer(m_attributes.patternContentElement()->rende rer()); 176 toRenderSVGResourceContainer(attributes().patternContentElement()->rende rer());
175 ASSERT(patternRenderer); 177 ASSERT(patternRenderer);
176 ASSERT(!patternRenderer->needsLayout()); 178 ASSERT(!patternRenderer->needsLayout());
177 179
178 SubtreeContentTransformScope contentTransformScope(contentTransform); 180 SubtreeContentTransformScope contentTransformScope(contentTransform);
179 181
180 { 182 {
181 TransformRecorder transformRecorder(recordingContext, patternRenderer->d isplayItemClient(), tileTransform); 183 TransformRecorder transformRecorder(recordingContext, patternRenderer->d isplayItemClient(), tileTransform);
182 for (RenderObject* child = patternRenderer->firstChild(); child; child = child->nextSibling()) 184 for (RenderObject* child = patternRenderer->firstChild(); child; child = child->nextSibling())
183 SVGRenderingContext::renderSubtree(&recordingContext, child); 185 SVGRenderingContext::renderSubtree(&recordingContext, child);
184 } 186 }
185 187
186 if (displayItemList) 188 if (displayItemList)
187 displayItemList->replay(&recordingContext); 189 displayItemList->replay(&recordingContext);
188 return recordingContext.endRecording(); 190 return recordingContext.endRecording();
189 } 191 }
190 192
191 } 193 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGResourcePattern.h ('k') | Source/core/rendering/svg/RenderSVGResourceRadialGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698