Changeset 123419 in webkit
- Timestamp:
- Jul 23, 2012 7:44:29 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r123418 r123419 1 2012-07-23 Mike Lawther <mikelawther@chromium.org> 2 3 CSS3 calc: optimise blending expression 4 https://bugs.webkit.org/show_bug.cgi?id=90037 5 6 Reviewed by Tony Chang. 7 8 Introduce a new calc expression node - a BlendLength node. Given two Lengths and a progress 9 this blends them together when evaluated. 10 11 An alternative and more general approach of being able to blend two CalcExpressionNodes was 12 tested, but involves more memory allocations, was measurably slower, and nothing currently 13 would make use of the generality. 14 15 No functional change. Covered by existing tests. 16 17 * platform/CalculationValue.h: 18 (CalcExpressionBlendLength): 19 (WebCore::CalcExpressionBlendLength::CalcExpressionBlendLength): 20 (WebCore::CalcExpressionBlendLength::operator==): 21 (WebCore::CalcExpressionBlendLength::evaluate): 22 (WebCore): 23 * platform/Length.cpp: 24 (WebCore::Length::blendCalculation): 25 1 26 2012-07-23 Nico Weber <thakis@chromium.org> 2 27 -
trunk/Source/WebCore/platform/CalculationValue.h
r121132 r123419 57 57 CalcExpressionNodeNumber, 58 58 CalcExpressionNodeLength, 59 CalcExpressionNodeBinaryOperation 59 CalcExpressionNodeBinaryOperation, 60 CalcExpressionNodeBlendLength, 60 61 }; 61 62 … … 184 185 }; 185 186 187 class CalcExpressionBlendLength : public CalcExpressionNode { 188 public: 189 CalcExpressionBlendLength(Length from, Length to, float progress) 190 : m_from(from) 191 , m_to(to) 192 , m_progress(progress) 193 { 194 m_type = CalcExpressionNodeBlendLength; 195 } 196 197 bool operator==(const CalcExpressionBlendLength& o) const 198 { 199 return m_progress == o.m_progress && m_from == o.m_from && m_to == o.m_to; 200 } 201 202 virtual bool operator==(const CalcExpressionNode& o) const 203 { 204 return type() == o.type() && *this == static_cast<const CalcExpressionBlendLength&>(o); 205 } 206 207 virtual float evaluate(float maxValue) const 208 { 209 return (1.0f - m_progress) * floatValueForLength(m_from, maxValue) + m_progress * floatValueForLength(m_to, maxValue); 210 } 211 212 private: 213 Length m_from; 214 Length m_to; 215 float m_progress; 216 }; 217 186 218 } // namespace WebCore 187 219 -
trunk/Source/WebCore/platform/Length.cpp
r121351 r123419 211 211 return *this; 212 212 213 // FIXME: https://webkit.org/b/90037 - some of these allocations can be eliminated 214 OwnPtr<CalcExpressionNode> startScale = adoptPtr(new CalcExpressionNumber(1.0 - progress)); 215 OwnPtr<CalcExpressionNode> startLength = adoptPtr(new CalcExpressionLength(from)); 216 OwnPtr<CalcExpressionNode> startNode = adoptPtr(new CalcExpressionBinaryOperation(startScale.release(), startLength.release(), CalcMultiply)); 217 218 OwnPtr<CalcExpressionNode> endScale = adoptPtr(new CalcExpressionNumber(progress)); 219 OwnPtr<CalcExpressionNode> endLength = adoptPtr(new CalcExpressionLength(*this)); 220 OwnPtr<CalcExpressionNode> endNode = adoptPtr(new CalcExpressionBinaryOperation(endScale.release(), endLength.release(), CalcMultiply)); 221 222 OwnPtr<CalcExpressionNode> blend = adoptPtr(new CalcExpressionBinaryOperation(startNode.release(), endNode.release(), CalcAdd)); 223 213 OwnPtr<CalcExpressionNode> blend = adoptPtr(new CalcExpressionBlendLength(from, *this, progress)); 224 214 return Length(CalculationValue::create(blend.release(), CalculationRangeAll)); 225 215 }
Note: See TracChangeset
for help on using the changeset viewer.