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

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

Issue 21042009: [SVG2] Merge SVGStyledElement into SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/svg/RenderSVGContainer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 #include "core/loader/cache/CachedSVGDocumentReference.h" 37 #include "core/loader/cache/CachedSVGDocumentReference.h"
38 #include "core/platform/graphics/filters/FilterEffect.h" 38 #include "core/platform/graphics/filters/FilterEffect.h"
39 #include "core/platform/graphics/filters/SourceAlpha.h" 39 #include "core/platform/graphics/filters/SourceAlpha.h"
40 #include "core/rendering/svg/RenderSVGResourceFilter.h" 40 #include "core/rendering/svg/RenderSVGResourceFilter.h"
41 #include "core/svg/SVGDocumentExtensions.h" 41 #include "core/svg/SVGDocumentExtensions.h"
42 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" 42 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
43 #include "core/svg/graphics/filters/SVGFilterBuilder.h" 43 #include "core/svg/graphics/filters/SVGFilterBuilder.h"
44 44
45 namespace WebCore { 45 namespace WebCore {
46 46
47 // Returns whether or not the SVGStyledElement object contains a valid color-int erpolation-filters attribute 47 // Returns whether or not the SVGElement object contains a valid color-interpola tion-filters attribute
48 static bool getSVGStyledElementColorSpace(SVGStyledElement* svgStyledElement, Co lorSpace& cs) 48 static bool getSVGElementColorSpace(SVGElement* svgElement, ColorSpace& cs)
49 { 49 {
50 if (!svgStyledElement) 50 if (!svgElement)
51 return false; 51 return false;
52 52
53 const RenderObject* renderer = svgStyledElement->renderer(); 53 const RenderObject* renderer = svgElement->renderer();
54 const RenderStyle* style = renderer ? renderer->style() : 0; 54 const RenderStyle* style = renderer ? renderer->style() : 0;
55 const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0; 55 const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
56 EColorInterpolation eColorInterpolation = CI_AUTO; 56 EColorInterpolation eColorInterpolation = CI_AUTO;
57 if (svgStyle) { 57 if (svgStyle) {
58 // If a layout has been performed, then we can use the fast path to get this attribute 58 // If a layout has been performed, then we can use the fast path to get this attribute
59 eColorInterpolation = svgStyle->colorInterpolationFilters(); 59 eColorInterpolation = svgStyle->colorInterpolationFilters();
60 } else { 60 } else {
61 // Otherwise, use the slow path by using string comparison (used by exte rnal svg files) 61 // Otherwise, use the slow path by using string comparison (used by exte rnal svg files)
62 RefPtr<CSSValue> cssValue = svgStyledElement->getPresentationAttribute( 62 RefPtr<CSSValue> cssValue = svgElement->getPresentationAttribute(
63 SVGNames::color_interpolation_filtersAttr.toString()); 63 SVGNames::color_interpolation_filtersAttr.toString());
64 if (cssValue.get() && cssValue->isPrimitiveValue()) { 64 if (cssValue.get() && cssValue->isPrimitiveValue()) {
65 const CSSPrimitiveValue& primitiveValue = *((CSSPrimitiveValue*)cssV alue.get()); 65 const CSSPrimitiveValue& primitiveValue = *((CSSPrimitiveValue*)cssV alue.get());
66 eColorInterpolation = (EColorInterpolation)primitiveValue; 66 eColorInterpolation = (EColorInterpolation)primitiveValue;
67 } else { 67 } else {
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 71
72 switch (eColorInterpolation) { 72 switch (eColorInterpolation) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 SVGFilterElement* filterElement = toSVGFilterElement(toSVGElement(filter)); 118 SVGFilterElement* filterElement = toSVGFilterElement(toSVGElement(filter));
119 119
120 // FIXME: Figure out what to do with SourceAlpha. Right now, we're 120 // FIXME: Figure out what to do with SourceAlpha. Right now, we're
121 // using the alpha of the original input layer, which is obviously 121 // using the alpha of the original input layer, which is obviously
122 // wrong. We should probably be extracting the alpha from the 122 // wrong. We should probably be extracting the alpha from the
123 // previousEffect, but this requires some more processing. 123 // previousEffect, but this requires some more processing.
124 // This may need a spec clarification. 124 // This may need a spec clarification.
125 RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(parentFilter)); 125 RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(parentFilter));
126 126
127 ColorSpace filterColorSpace = ColorSpaceDeviceRGB; 127 ColorSpace filterColorSpace = ColorSpaceDeviceRGB;
128 bool useFilterColorSpace = getSVGStyledElementColorSpace(filterElement, filt erColorSpace); 128 bool useFilterColorSpace = getSVGElementColorSpace(filterElement, filterColo rSpace);
129 129
130 for (Node* node = filterElement->firstChild(); node; node = node->nextSiblin g()) { 130 for (Node* node = filterElement->firstChild(); node; node = node->nextSiblin g()) {
131 if (!node->isSVGElement()) 131 if (!node->isSVGElement())
132 continue; 132 continue;
133 133
134 SVGElement* element = toSVGElement(node); 134 SVGElement* element = toSVGElement(node);
135 if (!element->isFilterEffect()) 135 if (!element->isFilterEffect())
136 continue; 136 continue;
137 137
138 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil terPrimitiveStandardAttributes*>(element); 138 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil terPrimitiveStandardAttributes*>(element);
139 139
140 RefPtr<FilterEffect> effect = effectElement->build(builder.get(), parent Filter); 140 RefPtr<FilterEffect> effect = effectElement->build(builder.get(), parent Filter);
141 if (!effect) 141 if (!effect)
142 continue; 142 continue;
143 143
144 effectElement->setStandardAttributes(effect.get()); 144 effectElement->setStandardAttributes(effect.get());
145 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter PrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnitsCurrent Value(), parentFilter->sourceImageRect())); 145 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter PrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnitsCurrent Value(), parentFilter->sourceImageRect()));
146 ColorSpace colorSpace = filterColorSpace; 146 ColorSpace colorSpace = filterColorSpace;
147 if (useFilterColorSpace || getSVGStyledElementColorSpace(effectElement, colorSpace)) 147 if (useFilterColorSpace || getSVGElementColorSpace(effectElement, colorS pace))
148 effect->setOperatingColorSpace(colorSpace); 148 effect->setOperatingColorSpace(colorSpace);
149 builder->add(effectElement->resultCurrentValue(), effect); 149 builder->add(effectElement->resultCurrentValue(), effect);
150 } 150 }
151 return builder->lastEffect(); 151 return builder->lastEffect();
152 } 152 }
153 153
154 } // namespace WebCore 154 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/svg/RenderSVGContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698