OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Inc. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * Copyright (C) 2011 Apple Inc. All rights reserved. | 4 * Copyright (C) 2011 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (!isSVGFilterElement(*filter)) | 117 if (!isSVGFilterElement(*filter)) |
118 return nullptr; | 118 return nullptr; |
119 | 119 |
120 SVGFilterElement& filterElement = toSVGFilterElement(*filter); | 120 SVGFilterElement& filterElement = toSVGFilterElement(*filter); |
121 | 121 |
122 FloatRect referenceBox; | 122 FloatRect referenceBox; |
123 if (element->inDocument() && element->layoutObject() && element->layoutObjec
t()->isBoxModelObject()) | 123 if (element->inDocument() && element->layoutObject() && element->layoutObjec
t()->isBoxModelObject()) |
124 referenceBox = toLayoutBoxModelObject(element->layoutObject())->borderBo
undingBox(); | 124 referenceBox = toLayoutBoxModelObject(element->layoutObject())->borderBo
undingBox(); |
125 referenceBox.scale(1.0f / zoom); | 125 referenceBox.scale(1.0f / zoom); |
126 FloatRect filterRegion = SVGLengthContext::resolveRectangle<SVGFilterElement
>(&filterElement, filterElement.filterUnits()->currentValue()->enumValue(), refe
renceBox); | 126 FloatRect filterRegion = SVGLengthContext::resolveRectangle<SVGFilterElement
>(&filterElement, filterElement.filterUnits()->currentValue()->enumValue(), refe
renceBox); |
127 RefPtrWillBeRawPtr<Filter> result(Filter::create(referenceBox, filterRegion,
zoom)); | 127 bool primitiveBoundingBoxMode = filterElement.primitiveUnits()->currentValue
()->enumValue() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; |
| 128 Filter::UnitScaling unitScaling = primitiveBoundingBoxMode ? Filter::Boundin
gBox : Filter::UserSpace; |
| 129 RefPtrWillBeRawPtr<Filter> result(Filter::create(referenceBox, filterRegion,
zoom, unitScaling)); |
128 if (!previousEffect) | 130 if (!previousEffect) |
129 previousEffect = result->sourceGraphic(); | 131 previousEffect = result->sourceGraphic(); |
130 RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(prev
iousEffect); | 132 RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(prev
iousEffect); |
131 | 133 |
132 EColorInterpolation filterColorInterpolation = colorInterpolationForElement(
filterElement, CI_AUTO); | 134 EColorInterpolation filterColorInterpolation = colorInterpolationForElement(
filterElement, CI_AUTO); |
133 | 135 |
134 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement);
element; element = Traversal<SVGElement>::nextSibling(*element)) { | 136 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement);
element; element = Traversal<SVGElement>::nextSibling(*element)) { |
135 if (!element->isFilterEffect()) | 137 if (!element->isFilterEffect()) |
136 continue; | 138 continue; |
137 | 139 |
138 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil
terPrimitiveStandardAttributes*>(element); | 140 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil
terPrimitiveStandardAttributes*>(element); |
139 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.g
et(), result.get()); | 141 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.g
et(), result.get()); |
140 if (!effect) | 142 if (!effect) |
141 continue; | 143 continue; |
142 | 144 |
143 effectElement->setStandardAttributes(effect.get()); | 145 effectElement->setStandardAttributes(effect.get()); |
144 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter
PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr
entValue()->enumValue(), referenceBox)); | 146 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter
PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr
entValue()->enumValue(), referenceBox)); |
145 EColorInterpolation colorInterpolation = colorInterpolationForElement(*e
ffectElement, filterColorInterpolation); | 147 EColorInterpolation colorInterpolation = colorInterpolationForElement(*e
ffectElement, filterColorInterpolation); |
146 effect->setOperatingColorSpace(colorInterpolation == CI_LINEARRGB ? Colo
rSpaceLinearRGB : ColorSpaceDeviceRGB); | 148 effect->setOperatingColorSpace(colorInterpolation == CI_LINEARRGB ? Colo
rSpaceLinearRGB : ColorSpaceDeviceRGB); |
147 builder->add(AtomicString(effectElement->result()->currentValue()->value
()), effect); | 149 builder->add(AtomicString(effectElement->result()->currentValue()->value
()), effect); |
148 } | 150 } |
149 result->setLastEffect(builder->lastEffect()); | 151 result->setLastEffect(builder->lastEffect()); |
150 return result.release(); | 152 return result.release(); |
151 } | 153 } |
152 | 154 |
153 } // namespace blink | 155 } // namespace blink |
OLD | NEW |