OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "core/layout/svg/SVGResourcesCycleSolver.h" | 20 #include "core/layout/svg/SVGResourcesCycleSolver.h" |
21 | 21 |
22 // Set to a value > 0, to debug the resource cache. | 22 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
23 #define DEBUG_CYCLE_DETECTION 0 | |
24 | |
25 #include "core/layout/svg/LayoutSVGResourceClipper.h" | |
26 #include "core/layout/svg/LayoutSVGResourceFilter.h" | |
27 #include "core/layout/svg/LayoutSVGResourceMarker.h" | |
28 #include "core/layout/svg/LayoutSVGResourceMasker.h" | |
29 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | |
30 #include "core/layout/svg/SVGResources.h" | 23 #include "core/layout/svg/SVGResources.h" |
31 #include "core/layout/svg/SVGResourcesCache.h" | 24 #include "core/layout/svg/SVGResourcesCache.h" |
32 | 25 |
33 namespace blink { | 26 namespace blink { |
34 | 27 |
35 SVGResourcesCycleSolver::SVGResourcesCycleSolver(LayoutObject* layout_object, | 28 SVGResourcesCycleSolver::SVGResourcesCycleSolver(LayoutObject* layout_object, |
36 SVGResources* resources) | 29 SVGResources* resources) |
37 : layout_object_(layout_object), resources_(resources) { | 30 : layout_object_(layout_object), resources_(resources) { |
38 DCHECK(layout_object_); | 31 DCHECK(layout_object_); |
39 DCHECK(resources_); | 32 DCHECK(resources_); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 94 |
102 ResourceSet local_resources; | 95 ResourceSet local_resources; |
103 resources_->BuildSetOfResources(local_resources); | 96 resources_->BuildSetOfResources(local_resources); |
104 | 97 |
105 // This performs a depth-first search for a back-edge in all the | 98 // This performs a depth-first search for a back-edge in all the |
106 // (potentially disjoint) graphs formed by the resources referenced by | 99 // (potentially disjoint) graphs formed by the resources referenced by |
107 // |m_layoutObject|. | 100 // |m_layoutObject|. |
108 for (auto* local_resource : local_resources) { | 101 for (auto* local_resource : local_resources) { |
109 if (active_resources_.Contains(local_resource) || | 102 if (active_resources_.Contains(local_resource) || |
110 ResourceContainsCycles(local_resource)) | 103 ResourceContainsCycles(local_resource)) |
111 BreakCycle(local_resource); | 104 resources_->ClearReferencesTo(local_resource); |
112 } | 105 } |
113 | 106 |
114 active_resources_.Clear(); | 107 active_resources_.Clear(); |
115 } | 108 } |
116 | 109 |
117 void SVGResourcesCycleSolver::BreakCycle( | |
118 LayoutSVGResourceContainer* resource_leading_to_cycle) { | |
119 DCHECK(resource_leading_to_cycle); | |
120 if (resource_leading_to_cycle == resources_->LinkedResource()) { | |
121 resources_->ResetLinkedResource(); | |
122 return; | |
123 } | |
124 | |
125 switch (resource_leading_to_cycle->ResourceType()) { | |
126 case kMaskerResourceType: | |
127 DCHECK_EQ(resource_leading_to_cycle, resources_->Masker()); | |
128 resources_->ResetMasker(); | |
129 break; | |
130 case kMarkerResourceType: | |
131 DCHECK(resource_leading_to_cycle == resources_->MarkerStart() || | |
132 resource_leading_to_cycle == resources_->MarkerMid() || | |
133 resource_leading_to_cycle == resources_->MarkerEnd()); | |
134 if (resources_->MarkerStart() == resource_leading_to_cycle) | |
135 resources_->ResetMarkerStart(); | |
136 if (resources_->MarkerMid() == resource_leading_to_cycle) | |
137 resources_->ResetMarkerMid(); | |
138 if (resources_->MarkerEnd() == resource_leading_to_cycle) | |
139 resources_->ResetMarkerEnd(); | |
140 break; | |
141 case kPatternResourceType: | |
142 case kLinearGradientResourceType: | |
143 case kRadialGradientResourceType: | |
144 DCHECK(resource_leading_to_cycle == resources_->Fill() || | |
145 resource_leading_to_cycle == resources_->Stroke()); | |
146 if (resources_->Fill() == resource_leading_to_cycle) | |
147 resources_->ResetFill(); | |
148 if (resources_->Stroke() == resource_leading_to_cycle) | |
149 resources_->ResetStroke(); | |
150 break; | |
151 case kFilterResourceType: | |
152 DCHECK_EQ(resource_leading_to_cycle, resources_->Filter()); | |
153 resources_->ResetFilter(); | |
154 break; | |
155 case kClipperResourceType: | |
156 DCHECK_EQ(resource_leading_to_cycle, resources_->Clipper()); | |
157 resources_->ResetClipper(); | |
158 break; | |
159 default: | |
160 NOTREACHED(); | |
161 break; | |
162 } | |
163 } | |
164 | |
165 } // namespace blink | 110 } // namespace blink |
OLD | NEW |