Title: [123419] trunk/Source/WebCore
- Revision
- 123419
- Author
- [email protected]
- Date
- 2012-07-23 19:44:29 -0700 (Mon, 23 Jul 2012)
Log Message
CSS3 calc: optimise blending _expression_
https://bugs.webkit.org/show_bug.cgi?id=90037
Reviewed by Tony Chang.
Introduce a new calc _expression_ node - a BlendLength node. Given two Lengths and a progress
this blends them together when evaluated.
An alternative and more general approach of being able to blend two CalcExpressionNodes was
tested, but involves more memory allocations, was measurably slower, and nothing currently
would make use of the generality.
No functional change. Covered by existing tests.
* platform/CalculationValue.h:
(CalcExpressionBlendLength):
(WebCore::CalcExpressionBlendLength::CalcExpressionBlendLength):
(WebCore::CalcExpressionBlendLength::operator==):
(WebCore::CalcExpressionBlendLength::evaluate):
(WebCore):
* platform/Length.cpp:
(WebCore::Length::blendCalculation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (123418 => 123419)
--- trunk/Source/WebCore/ChangeLog 2012-07-24 02:19:13 UTC (rev 123418)
+++ trunk/Source/WebCore/ChangeLog 2012-07-24 02:44:29 UTC (rev 123419)
@@ -1,3 +1,28 @@
+2012-07-23 Mike Lawther <[email protected]>
+
+ CSS3 calc: optimise blending _expression_
+ https://bugs.webkit.org/show_bug.cgi?id=90037
+
+ Reviewed by Tony Chang.
+
+ Introduce a new calc _expression_ node - a BlendLength node. Given two Lengths and a progress
+ this blends them together when evaluated.
+
+ An alternative and more general approach of being able to blend two CalcExpressionNodes was
+ tested, but involves more memory allocations, was measurably slower, and nothing currently
+ would make use of the generality.
+
+ No functional change. Covered by existing tests.
+
+ * platform/CalculationValue.h:
+ (CalcExpressionBlendLength):
+ (WebCore::CalcExpressionBlendLength::CalcExpressionBlendLength):
+ (WebCore::CalcExpressionBlendLength::operator==):
+ (WebCore::CalcExpressionBlendLength::evaluate):
+ (WebCore):
+ * platform/Length.cpp:
+ (WebCore::Length::blendCalculation):
+
2012-07-23 Nico Weber <[email protected]>
[chromium] Show search tickmarks on css-styled scrollbars
Modified: trunk/Source/WebCore/platform/CalculationValue.h (123418 => 123419)
--- trunk/Source/WebCore/platform/CalculationValue.h 2012-07-24 02:19:13 UTC (rev 123418)
+++ trunk/Source/WebCore/platform/CalculationValue.h 2012-07-24 02:44:29 UTC (rev 123419)
@@ -56,7 +56,8 @@
CalcExpressionNodeUndefined,
CalcExpressionNodeNumber,
CalcExpressionNodeLength,
- CalcExpressionNodeBinaryOperation
+ CalcExpressionNodeBinaryOperation,
+ CalcExpressionNodeBlendLength,
};
class CalcExpressionNode {
@@ -183,6 +184,37 @@
CalcOperator m_operator;
};
+class CalcExpressionBlendLength : public CalcExpressionNode {
+public:
+ CalcExpressionBlendLength(Length from, Length to, float progress)
+ : m_from(from)
+ , m_to(to)
+ , m_progress(progress)
+ {
+ m_type = CalcExpressionNodeBlendLength;
+ }
+
+ bool operator==(const CalcExpressionBlendLength& o) const
+ {
+ return m_progress == o.m_progress && m_from == o.m_from && m_to == o.m_to;
+ }
+
+ virtual bool operator==(const CalcExpressionNode& o) const
+ {
+ return type() == o.type() && *this == static_cast<const CalcExpressionBlendLength&>(o);
+ }
+
+ virtual float evaluate(float maxValue) const
+ {
+ return (1.0f - m_progress) * floatValueForLength(m_from, maxValue) + m_progress * floatValueForLength(m_to, maxValue);
+ }
+
+private:
+ Length m_from;
+ Length m_to;
+ float m_progress;
+};
+
} // namespace WebCore
#endif // CalculationValue_h
Modified: trunk/Source/WebCore/platform/Length.cpp (123418 => 123419)
--- trunk/Source/WebCore/platform/Length.cpp 2012-07-24 02:19:13 UTC (rev 123418)
+++ trunk/Source/WebCore/platform/Length.cpp 2012-07-24 02:44:29 UTC (rev 123419)
@@ -210,17 +210,7 @@
if (progress >= 1.0)
return *this;
- // FIXME: https://webkit.org/b/90037 - some of these allocations can be eliminated
- OwnPtr<CalcExpressionNode> startScale = adoptPtr(new CalcExpressionNumber(1.0 - progress));
- OwnPtr<CalcExpressionNode> startLength = adoptPtr(new CalcExpressionLength(from));
- OwnPtr<CalcExpressionNode> startNode = adoptPtr(new CalcExpressionBinaryOperation(startScale.release(), startLength.release(), CalcMultiply));
-
- OwnPtr<CalcExpressionNode> endScale = adoptPtr(new CalcExpressionNumber(progress));
- OwnPtr<CalcExpressionNode> endLength = adoptPtr(new CalcExpressionLength(*this));
- OwnPtr<CalcExpressionNode> endNode = adoptPtr(new CalcExpressionBinaryOperation(endScale.release(), endLength.release(), CalcMultiply));
-
- OwnPtr<CalcExpressionNode> blend = adoptPtr(new CalcExpressionBinaryOperation(startNode.release(), endNode.release(), CalcAdd));
-
+ OwnPtr<CalcExpressionNode> blend = adoptPtr(new CalcExpressionBlendLength(from, *this, progress));
return Length(CalculationValue::create(blend.release(), CalculationRangeAll));
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes