OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 25 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
26 | 26 |
27 #include "core/dom/ElementTraversal.h" | |
28 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" | 27 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" |
29 #include "platform/graphics/GraphicsContext.h" | |
30 #include "platform/graphics/filters/SourceGraphic.h" | |
31 #include "third_party/skia/include/core/SkPicture.h" | |
32 | 28 |
33 namespace blink { | 29 namespace blink { |
34 | 30 |
35 DEFINE_TRACE(FilterData) | 31 DEFINE_TRACE(FilterData) |
36 { | 32 { |
37 #if ENABLE(OILPAN) | 33 #if ENABLE(OILPAN) |
38 visitor->trace(filter); | 34 visitor->trace(filter); |
39 visitor->trace(builder); | 35 visitor->trace(nodeMap); |
40 #endif | 36 #endif |
41 } | 37 } |
42 | 38 |
43 void FilterData::dispose() | 39 void FilterData::dispose() |
44 { | 40 { |
45 builder = nullptr; | 41 nodeMap = nullptr; |
46 filter = nullptr; | 42 filter = nullptr; |
47 } | 43 } |
48 | 44 |
49 LayoutSVGResourceFilter::LayoutSVGResourceFilter(SVGFilterElement* node) | 45 LayoutSVGResourceFilter::LayoutSVGResourceFilter(SVGFilterElement* node) |
50 : LayoutSVGResourceContainer(node) | 46 : LayoutSVGResourceContainer(node) |
51 { | 47 { |
52 } | 48 } |
53 | 49 |
54 LayoutSVGResourceFilter::~LayoutSVGResourceFilter() | 50 LayoutSVGResourceFilter::~LayoutSVGResourceFilter() |
55 { | 51 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (filterCached) | 88 if (filterCached) |
93 m_filter.remove(client); | 89 m_filter.remove(client); |
94 | 90 |
95 // If the filter has a cached subtree, invalidate the associated display ite
m. | 91 // If the filter has a cached subtree, invalidate the associated display ite
m. |
96 if (markForInvalidation && filterCached) | 92 if (markForInvalidation && filterCached) |
97 markClientForInvalidation(client, PaintInvalidation); | 93 markClientForInvalidation(client, PaintInvalidation); |
98 | 94 |
99 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); | 95 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); |
100 } | 96 } |
101 | 97 |
102 PassRefPtrWillBeRawPtr<SVGFilterBuilder> LayoutSVGResourceFilter::buildPrimitive
s(Filter* filter) | |
103 { | |
104 SVGFilterElement* filterElement = toSVGFilterElement(element()); | |
105 FloatRect referenceBox = filter->referenceBox(); | |
106 | |
107 // Add effects to the builder | |
108 RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(filt
er->sourceGraphic()); | |
109 for (SVGElement* element = Traversal<SVGElement>::firstChild(*filterElement)
; element; element = Traversal<SVGElement>::nextSibling(*element)) { | |
110 if (!element->isFilterEffect() || !element->layoutObject()) | |
111 continue; | |
112 | |
113 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil
terPrimitiveStandardAttributes*>(element); | |
114 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.g
et(), filter); | |
115 if (!effect) { | |
116 builder->clearEffects(); | |
117 return nullptr; | |
118 } | |
119 builder->appendEffectToEffectReferences(effect, effectElement->layoutObj
ect()); | |
120 effectElement->setStandardAttributes(effect.get()); | |
121 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter
PrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnits()->cur
rentValue()->enumValue(), referenceBox)); | |
122 effect->setOperatingColorSpace( | |
123 effectElement->layoutObject()->style()->svgStyle().colorInterpolatio
nFilters() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB); | |
124 builder->add(AtomicString(effectElement->result()->currentValue()->value
()), effect); | |
125 } | |
126 filter->setLastEffect(builder->lastEffect()); | |
127 return builder.release(); | |
128 } | |
129 | |
130 FloatRect LayoutSVGResourceFilter::resourceBoundingBox(const LayoutObject* objec
t) | 98 FloatRect LayoutSVGResourceFilter::resourceBoundingBox(const LayoutObject* objec
t) |
131 { | 99 { |
132 if (SVGFilterElement* element = toSVGFilterElement(this->element())) | 100 if (SVGFilterElement* element = toSVGFilterElement(this->element())) |
133 return SVGLengthContext::resolveRectangle<SVGFilterElement>(element, ele
ment->filterUnits()->currentValue()->enumValue(), object->objectBoundingBox()); | 101 return SVGLengthContext::resolveRectangle<SVGFilterElement>(element, ele
ment->filterUnits()->currentValue()->enumValue(), object->objectBoundingBox()); |
134 | 102 |
135 return FloatRect(); | 103 return FloatRect(); |
136 } | 104 } |
137 | 105 |
138 void LayoutSVGResourceFilter::primitiveAttributeChanged(LayoutObject* object, co
nst QualifiedName& attribute) | 106 void LayoutSVGResourceFilter::primitiveAttributeChanged(LayoutObject* object, co
nst QualifiedName& attribute) |
139 { | 107 { |
140 FilterMap::iterator it = m_filter.begin(); | |
141 FilterMap::iterator end = m_filter.end(); | |
142 SVGFilterPrimitiveStandardAttributes* primitive = static_cast<SVGFilterPrimi
tiveStandardAttributes*>(object->node()); | 108 SVGFilterPrimitiveStandardAttributes* primitive = static_cast<SVGFilterPrimi
tiveStandardAttributes*>(object->node()); |
143 | 109 |
144 for (; it != end; ++it) { | 110 for (auto& filter : m_filter) { |
145 FilterData* filterData = it->value.get(); | 111 FilterData* filterData = filter.value.get(); |
146 if (filterData->m_state != FilterData::ReadyToPaint) | 112 if (filterData->m_state != FilterData::ReadyToPaint) |
147 continue; | 113 continue; |
148 | 114 |
149 SVGFilterBuilder* builder = filterData->builder.get(); | 115 SVGFilterGraphNodeMap* nodeMap = filterData->nodeMap.get(); |
150 FilterEffect* effect = builder->effectByRenderer(object); | 116 FilterEffect* effect = nodeMap->effectByRenderer(object); |
151 if (!effect) | 117 if (!effect) |
152 continue; | 118 continue; |
153 // Since all effects shares the same attribute value, all | 119 // Since all effects shares the same attribute value, all |
154 // or none of them will be changed. | 120 // or none of them will be changed. |
155 if (!primitive->setFilterEffectAttribute(effect, attribute)) | 121 if (!primitive->setFilterEffectAttribute(effect, attribute)) |
156 return; | 122 return; |
157 builder->clearResultsRecursive(effect); | 123 nodeMap->invalidateDependentEffects(effect); |
158 | 124 |
159 // Issue paint invalidations for the image on the screen. | 125 // Issue paint invalidations for the image on the screen. |
160 markClientForInvalidation(it->key, PaintInvalidation); | 126 markClientForInvalidation(filter.key, PaintInvalidation); |
161 } | 127 } |
162 markAllClientLayersForInvalidation(); | 128 markAllClientLayersForInvalidation(); |
163 } | 129 } |
164 | 130 |
165 } // namespace blink | 131 } // namespace blink |
OLD | NEW |