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

Side by Side Diff: Source/core/svg/SVGFEDisplacementMapElement.cpp

Issue 148173018: [SVG] SVGAnimatedString{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove debug print Created 6 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
« no previous file with comments | « Source/core/svg/SVGFEDisplacementMapElement.h ('k') | Source/core/svg/SVGFEDropShadowElement.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) 2006 Oliver Hunt <oliver@nerget.com> 2 * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
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
(...skipping 11 matching lines...) Expand all
22 #include "core/svg/SVGFEDisplacementMapElement.h" 22 #include "core/svg/SVGFEDisplacementMapElement.h"
23 23
24 #include "SVGNames.h" 24 #include "SVGNames.h"
25 #include "platform/graphics/filters/FilterEffect.h" 25 #include "platform/graphics/filters/FilterEffect.h"
26 #include "core/svg/SVGElementInstance.h" 26 #include "core/svg/SVGElementInstance.h"
27 #include "core/svg/graphics/filters/SVGFilterBuilder.h" 27 #include "core/svg/graphics/filters/SVGFilterBuilder.h"
28 28
29 namespace WebCore { 29 namespace WebCore {
30 30
31 // Animated property definitions 31 // Animated property definitions
32 DEFINE_ANIMATED_STRING(SVGFEDisplacementMapElement, SVGNames::inAttr, In1, in1)
33 DEFINE_ANIMATED_STRING(SVGFEDisplacementMapElement, SVGNames::in2Attr, In2, in2)
34 DEFINE_ANIMATED_ENUMERATION(SVGFEDisplacementMapElement, SVGNames::xChannelSelec torAttr, XChannelSelector, xChannelSelector, ChannelSelectorType) 32 DEFINE_ANIMATED_ENUMERATION(SVGFEDisplacementMapElement, SVGNames::xChannelSelec torAttr, XChannelSelector, xChannelSelector, ChannelSelectorType)
35 DEFINE_ANIMATED_ENUMERATION(SVGFEDisplacementMapElement, SVGNames::yChannelSelec torAttr, YChannelSelector, yChannelSelector, ChannelSelectorType) 33 DEFINE_ANIMATED_ENUMERATION(SVGFEDisplacementMapElement, SVGNames::yChannelSelec torAttr, YChannelSelector, yChannelSelector, ChannelSelectorType)
36 34
37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement) 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement)
38 REGISTER_LOCAL_ANIMATED_PROPERTY(in1)
39 REGISTER_LOCAL_ANIMATED_PROPERTY(in2)
40 REGISTER_LOCAL_ANIMATED_PROPERTY(xChannelSelector) 36 REGISTER_LOCAL_ANIMATED_PROPERTY(xChannelSelector)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(yChannelSelector) 37 REGISTER_LOCAL_ANIMATED_PROPERTY(yChannelSelector)
42 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) 38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes)
43 END_REGISTER_ANIMATED_PROPERTIES 39 END_REGISTER_ANIMATED_PROPERTIES
44 40
45 inline SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(Document& docume nt) 41 inline SVGFEDisplacementMapElement::SVGFEDisplacementMapElement(Document& docume nt)
46 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDisplacementMapTag, docum ent) 42 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDisplacementMapTag, docum ent)
47 , m_scale(SVGAnimatedNumber::create(this, SVGNames::scaleAttr, SVGNumber::cr eate(0))) 43 , m_scale(SVGAnimatedNumber::create(this, SVGNames::scaleAttr, SVGNumber::cr eate(0)))
44 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create( )))
45 , m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create ()))
48 , m_xChannelSelector(CHANNEL_A) 46 , m_xChannelSelector(CHANNEL_A)
49 , m_yChannelSelector(CHANNEL_A) 47 , m_yChannelSelector(CHANNEL_A)
50 { 48 {
51 ScriptWrappable::init(this); 49 ScriptWrappable::init(this);
52 50
53 addToPropertyMap(m_scale); 51 addToPropertyMap(m_scale);
52 addToPropertyMap(m_in1);
53 addToPropertyMap(m_in2);
54 registerAnimatedPropertiesForSVGFEDisplacementMapElement(); 54 registerAnimatedPropertiesForSVGFEDisplacementMapElement();
55 } 55 }
56 56
57 PassRefPtr<SVGFEDisplacementMapElement> SVGFEDisplacementMapElement::create(Docu ment& document) 57 PassRefPtr<SVGFEDisplacementMapElement> SVGFEDisplacementMapElement::create(Docu ment& document)
58 { 58 {
59 return adoptRef(new SVGFEDisplacementMapElement(document)); 59 return adoptRef(new SVGFEDisplacementMapElement(document));
60 } 60 }
61 61
62 bool SVGFEDisplacementMapElement::isSupportedAttribute(const QualifiedName& attr Name) 62 bool SVGFEDisplacementMapElement::isSupportedAttribute(const QualifiedName& attr Name)
63 { 63 {
(...skipping 22 matching lines...) Expand all
86 return; 86 return;
87 } 87 }
88 88
89 if (name == SVGNames::yChannelSelectorAttr) { 89 if (name == SVGNames::yChannelSelectorAttr) {
90 ChannelSelectorType propertyValue = SVGPropertyTraits<ChannelSelectorTyp e>::fromString(value); 90 ChannelSelectorType propertyValue = SVGPropertyTraits<ChannelSelectorTyp e>::fromString(value);
91 if (propertyValue > 0) 91 if (propertyValue > 0)
92 setYChannelSelectorBaseValue(propertyValue); 92 setYChannelSelectorBaseValue(propertyValue);
93 return; 93 return;
94 } 94 }
95 95
96 if (name == SVGNames::inAttr) {
97 setIn1BaseValue(value);
98 return;
99 }
100
101 if (name == SVGNames::in2Attr) {
102 setIn2BaseValue(value);
103 return;
104 }
105
106 SVGParsingError parseError = NoError; 96 SVGParsingError parseError = NoError;
107 97
108 if (name == SVGNames::scaleAttr) 98 if (name == SVGNames::inAttr)
99 m_in1->setBaseValueAsString(value, parseError);
100 else if (name == SVGNames::in2Attr)
101 m_in2->setBaseValueAsString(value, parseError);
102 else if (name == SVGNames::scaleAttr)
109 m_scale->setBaseValueAsString(value, parseError); 103 m_scale->setBaseValueAsString(value, parseError);
110 else 104 else
111 ASSERT_NOT_REACHED(); 105 ASSERT_NOT_REACHED();
112 106
113 reportAttributeParsingError(parseError, name, value); 107 reportAttributeParsingError(parseError, name, value);
114 } 108 }
115 109
116 bool SVGFEDisplacementMapElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) 110 bool SVGFEDisplacementMapElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
117 { 111 {
118 FEDisplacementMap* displacementMap = static_cast<FEDisplacementMap*>(effect) ; 112 FEDisplacementMap* displacementMap = static_cast<FEDisplacementMap*>(effect) ;
(...skipping 25 matching lines...) Expand all
144 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) { 138 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) {
145 invalidate(); 139 invalidate();
146 return; 140 return;
147 } 141 }
148 142
149 ASSERT_NOT_REACHED(); 143 ASSERT_NOT_REACHED();
150 } 144 }
151 145
152 PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* fi lterBuilder, Filter* filter) 146 PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* fi lterBuilder, Filter* filter)
153 { 147 {
154 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV alue())); 148 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value()));
155 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(in2CurrentV alue())); 149 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr entValue()->value()));
156 150
157 if (!input1 || !input2) 151 if (!input1 || !input2)
158 return 0; 152 return 0;
159 153
160 RefPtr<FilterEffect> effect = FEDisplacementMap::create(filter, xChannelSele ctorCurrentValue(), yChannelSelectorCurrentValue(), m_scale->currentValue()->val ue()); 154 RefPtr<FilterEffect> effect = FEDisplacementMap::create(filter, xChannelSele ctorCurrentValue(), yChannelSelectorCurrentValue(), m_scale->currentValue()->val ue());
161 FilterEffectVector& inputEffects = effect->inputEffects(); 155 FilterEffectVector& inputEffects = effect->inputEffects();
162 inputEffects.reserveCapacity(2); 156 inputEffects.reserveCapacity(2);
163 inputEffects.append(input1); 157 inputEffects.append(input1);
164 inputEffects.append(input2); 158 inputEffects.append(input2);
165 return effect.release(); 159 return effect.release();
166 } 160 }
167 161
168 } 162 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGFEDisplacementMapElement.h ('k') | Source/core/svg/SVGFEDropShadowElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698