Changeset 149694 in webkit
- Timestamp:
- May 7, 2013 3:04:01 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149693 r149694 1 2013-05-07 Anders Carlsson <andersca@apple.com> 2 3 Clean up KeyframeValueList and related classes 4 https://bugs.webkit.org/show_bug.cgi?id=115738 5 6 Reviewed by Simon Fraser. 7 8 Add static create() functions to the AnimationValue subclasses, and change a bunch of parameters 9 and return values that can never be null from pointer types to reference types to better indicate this. 10 11 * platform/graphics/GraphicsLayer.cpp: 12 (WebCore::filterOperationsAt): 13 (WebCore::GraphicsLayer::validateFilterOperations): 14 (WebCore::operationsAt): 15 (WebCore::GraphicsLayer::validateTransformOperations): 16 * platform/graphics/GraphicsLayer.h: 17 (AnimationValue): 18 (WebCore::AnimationValue::AnimationValue): 19 (WebCore::FloatAnimationValue::create): 20 (FloatAnimationValue): 21 (WebCore::FloatAnimationValue::FloatAnimationValue): 22 (WebCore::TransformAnimationValue::create): 23 (TransformAnimationValue): 24 (WebCore::TransformAnimationValue::value): 25 (WebCore::TransformAnimationValue::TransformAnimationValue): 26 (WebCore::FilterAnimationValue::create): 27 (WebCore::FilterAnimationValue::value): 28 (WebCore::FilterAnimationValue::FilterAnimationValue): 29 (FilterAnimationValue): 30 (WebCore::KeyframeValueList::~KeyframeValueList): 31 (KeyframeValueList): 32 (WebCore::KeyframeValueList::at): 33 * platform/graphics/ca/GraphicsLayerCA.cpp: 34 (WebCore::animationHasStepsTimingFunction): 35 (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): 36 (WebCore::GraphicsLayerCA::createFilterAnimationsFromKeyframes): 37 (WebCore::GraphicsLayerCA::timingFunctionForAnimationValue): 38 (WebCore::GraphicsLayerCA::setAnimationEndpoints): 39 (WebCore::GraphicsLayerCA::setAnimationKeyframes): 40 (WebCore::GraphicsLayerCA::setTransformAnimationEndpoints): 41 (WebCore::GraphicsLayerCA::setTransformAnimationKeyframes): 42 (WebCore::GraphicsLayerCA::setFilterAnimationEndpoints): 43 (WebCore::GraphicsLayerCA::setFilterAnimationKeyframes): 44 * platform/graphics/ca/GraphicsLayerCA.h: 45 (GraphicsLayerCA): 46 * rendering/RenderLayerBacking.cpp: 47 (WebCore::RenderLayerBacking::startAnimation): 48 (WebCore::RenderLayerBacking::startTransition): 49 1 50 2013-05-07 Anders Carlsson <andersca@apple.com> 2 51 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp
r149661 r149694 410 410 411 411 #if ENABLE(CSS_FILTERS) 412 static inline const FilterOperations *filterOperationsAt(const KeyframeValueList& valueList, size_t index)413 { 414 return static_cast<const FilterAnimationValue *>(valueList.at(index))->value();412 static inline const FilterOperations& filterOperationsAt(const KeyframeValueList& valueList, size_t index) 413 { 414 return static_cast<const FilterAnimationValue&>(valueList.at(index)).value(); 415 415 } 416 416 … … 425 425 size_t firstIndex = 0; 426 426 for ( ; firstIndex < valueList.size(); ++firstIndex) { 427 if ( filterOperationsAt(valueList, firstIndex)->operations().size() > 0)427 if (!filterOperationsAt(valueList, firstIndex).operations().isEmpty()) 428 428 break; 429 429 } … … 432 432 return -1; 433 433 434 const FilterOperations *firstVal = filterOperationsAt(valueList, firstIndex);434 const FilterOperations& firstVal = filterOperationsAt(valueList, firstIndex); 435 435 436 436 for (size_t i = firstIndex + 1; i < valueList.size(); ++i) { 437 const FilterOperations *val = filterOperationsAt(valueList, i);437 const FilterOperations& val = filterOperationsAt(valueList, i); 438 438 439 439 // An emtpy filter list matches anything. 440 if (val ->operations().isEmpty())440 if (val.operations().isEmpty()) 441 441 continue; 442 442 443 if (!firstVal ->operationsMatch(*val))443 if (!firstVal.operationsMatch(val)) 444 444 return -1; 445 445 } … … 453 453 // true if the rotation between any two keyframes is >= 180 degrees. 454 454 455 static inline const TransformOperations *operationsAt(const KeyframeValueList& valueList, size_t index)456 { 457 return static_cast<const TransformAnimationValue *>(valueList.at(index))->value();455 static inline const TransformOperations& operationsAt(const KeyframeValueList& valueList, size_t index) 456 { 457 return static_cast<const TransformAnimationValue&>(valueList.at(index)).value(); 458 458 } 459 459 … … 470 470 size_t firstIndex = 0; 471 471 for ( ; firstIndex < valueList.size(); ++firstIndex) { 472 if ( operationsAt(valueList, firstIndex)->operations().size() > 0)472 if (!operationsAt(valueList, firstIndex).operations().isEmpty()) 473 473 break; 474 474 } … … 477 477 return -1; 478 478 479 const TransformOperations *firstVal = operationsAt(valueList, firstIndex);479 const TransformOperations& firstVal = operationsAt(valueList, firstIndex); 480 480 481 481 // See if the keyframes are valid. 482 482 for (size_t i = firstIndex + 1; i < valueList.size(); ++i) { 483 const TransformOperations *val = operationsAt(valueList, i);484 485 // An em tpy transform list matches anything.486 if (val ->operations().isEmpty())483 const TransformOperations& val = operationsAt(valueList, i); 484 485 // An empty transform list matches anything. 486 if (val.operations().isEmpty()) 487 487 continue; 488 488 489 if (!firstVal ->operationsMatch(*val))489 if (!firstVal.operationsMatch(val)) 490 490 return -1; 491 491 } … … 495 495 double maxRotAngle = -1.0; 496 496 497 for (size_t j = 0; j < firstVal ->operations().size(); ++j) {498 TransformOperation::OperationType type = firstVal ->operations().at(j)->getOperationType();497 for (size_t j = 0; j < firstVal.operations().size(); ++j) { 498 TransformOperation::OperationType type = firstVal.operations().at(j)->getOperationType(); 499 499 500 500 // if this is a rotation entry, we need to see if any angle differences are >= 180 deg … … 503 503 type == TransformOperation::ROTATE_Z || 504 504 type == TransformOperation::ROTATE_3D) { 505 lastRotAngle = static_cast<RotateTransformOperation*>(firstVal ->operations().at(j).get())->angle();505 lastRotAngle = static_cast<RotateTransformOperation*>(firstVal.operations().at(j).get())->angle(); 506 506 507 507 if (maxRotAngle < 0) … … 509 509 510 510 for (size_t i = firstIndex + 1; i < valueList.size(); ++i) { 511 const TransformOperations *val = operationsAt(valueList, i);512 double rotAngle = val ->operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val->operations().at(j).get())->angle());511 const TransformOperations& val = operationsAt(valueList, i); 512 double rotAngle = val.operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val.operations().at(j).get())->angle()); 513 513 double diffAngle = fabs(rotAngle - lastRotAngle); 514 514 if (diffAngle > maxRotAngle) -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r149661 r149694 73 73 WTF_MAKE_FAST_ALLOCATED; 74 74 public: 75 explicit AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)76 : m_keyTime(keyTime)77 , m_timingFunction(timingFunction)78 {79 }80 81 75 virtual ~AnimationValue() { } 82 76 … … 84 78 const TimingFunction* timingFunction() const { return m_timingFunction.get(); } 85 79 virtual PassOwnPtr<AnimationValue> clone() const = 0; 80 81 protected: 82 AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0) 83 : m_keyTime(keyTime) 84 , m_timingFunction(timingFunction) 85 { 86 } 86 87 87 88 private: … … 94 95 class FloatAnimationValue : public AnimationValue { 95 96 public: 96 FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0) 97 static PassOwnPtr<FloatAnimationValue> create(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0) 98 { 99 return adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction)); 100 } 101 102 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE 103 { 104 return adoptPtr(new FloatAnimationValue(*this)); 105 } 106 107 float value() const { return m_value; } 108 109 private: 110 FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction) 97 111 : AnimationValue(keyTime, timingFunction) 98 112 , m_value(value) 99 113 { 100 114 } 101 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FloatAnimationValue(*this)); } 102 103 float value() const { return m_value; } 104 105 private: 115 106 116 float m_value; 107 117 }; … … 111 121 class TransformAnimationValue : public AnimationValue { 112 122 public: 113 explicit TransformAnimationValue(float keyTime, const TransformOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0) 123 static PassOwnPtr<TransformAnimationValue> create(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction = 0) 124 { 125 return adoptPtr(new TransformAnimationValue(keyTime, value, timingFunction)); 126 } 127 128 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE 129 { 130 return adoptPtr(new TransformAnimationValue(*this)); 131 } 132 133 const TransformOperations& value() const { return m_value; } 134 135 private: 136 TransformAnimationValue(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction) 114 137 : AnimationValue(keyTime, timingFunction) 115 { 116 if (value) 117 m_value = *value; 118 } 119 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new TransformAnimationValue(*this)); } 120 121 const TransformOperations* value() const { return &m_value; } 122 123 private: 138 , m_value(value) 139 { 140 } 141 124 142 TransformOperations m_value; 125 143 }; … … 130 148 class FilterAnimationValue : public AnimationValue { 131 149 public: 132 explicit FilterAnimationValue(float keyTime, const FilterOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0) 150 static PassOwnPtr<FilterAnimationValue> create(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction = 0) 151 { 152 return adoptPtr(new FilterAnimationValue(keyTime, value, timingFunction)); 153 } 154 155 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE 156 { 157 return adoptPtr(new FilterAnimationValue(*this)); 158 } 159 160 const FilterOperations& value() const { return m_value; } 161 162 private: 163 FilterAnimationValue(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction) 133 164 : AnimationValue(keyTime, timingFunction) 134 { 135 if (value) 136 m_value = *value; 137 } 138 virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE { return adoptPtr(new FilterAnimationValue(*this)); } 139 140 const FilterOperations* value() const { return &m_value; } 141 142 private: 165 , m_value(value) 166 { 167 } 168 143 169 FilterOperations m_value; 144 170 }; … … 162 188 } 163 189 190 ~KeyframeValueList() 191 { 192 } 193 164 194 KeyframeValueList& operator=(const KeyframeValueList& other) 165 195 { … … 178 208 179 209 size_t size() const { return m_values.size(); } 180 const AnimationValue * at(size_t i) const { return m_values.at(i).get(); }210 const AnimationValue& at(size_t i) const { return *m_values.at(i); } 181 211 182 212 // Insert, sorted by keyTime. -
trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp
r147746 r149694 40 40 41 41 42 static FilterOperations applyFilterAnimation(const FilterOperations * from, const FilterOperations*to, double progress, const IntSize& boxSize)42 static FilterOperations applyFilterAnimation(const FilterOperations& from, const FilterOperations& to, double progress, const IntSize& boxSize) 43 43 { 44 44 // First frame of an animation. 45 45 if (!progress) 46 return *from;46 return from; 47 47 48 48 // Last frame of an animation. 49 49 if (progress == 1) 50 return *to;51 52 if (!from ->isEmpty() && !to->isEmpty() && !from->operationsMatch(*to))53 return *to;50 return to; 51 52 if (!from.isEmpty() && !to.isEmpty() && !from.operationsMatch(to)) 53 return to; 54 54 55 55 FilterOperations result; 56 56 57 size_t fromSize = from ->operations().size();58 size_t toSize = to ->operations().size();57 size_t fromSize = from.operations().size(); 58 size_t toSize = to.operations().size(); 59 59 size_t size = std::max(fromSize, toSize); 60 60 for (size_t i = 0; i < size; i++) { 61 RefPtr<FilterOperation> fromOp = (i < fromSize) ? from ->operations()[i].get() : 0;62 RefPtr<FilterOperation> toOp = (i < toSize) ? to ->operations()[i].get() : 0;61 RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0; 62 RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0; 63 63 RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), progress, boxSize) : (fromOp ? blendFunc(0, fromOp.get(), progress, boxSize, true) : 0); 64 64 if (blendedOp) … … 156 156 } 157 157 158 static TransformationMatrix applyTransformAnimation(const TransformOperations * from, const TransformOperations*to, double progress, const IntSize& boxSize, bool listsMatch)158 static TransformationMatrix applyTransformAnimation(const TransformOperations& from, const TransformOperations& to, double progress, const IntSize& boxSize, bool listsMatch) 159 159 { 160 160 TransformationMatrix matrix; … … 162 162 // First frame of an animation. 163 163 if (!progress) { 164 from ->apply(boxSize, matrix);164 from.apply(boxSize, matrix); 165 165 return matrix; 166 166 } … … 168 168 // Last frame of an animation. 169 169 if (progress == 1) { 170 to ->apply(boxSize, matrix);170 to.apply(boxSize, matrix); 171 171 return matrix; 172 172 } … … 175 175 if (!listsMatch) { 176 176 TransformationMatrix fromMatrix; 177 to ->apply(boxSize, matrix);178 from ->apply(boxSize, fromMatrix);177 to.apply(boxSize, matrix); 178 from.apply(boxSize, fromMatrix); 179 179 matrix.blend(fromMatrix, progress); 180 180 return matrix; … … 182 182 183 183 // Animation to "-webkit-transform: none". 184 if (!to ->size()) {185 TransformOperations blended( *from);184 if (!to.size()) { 185 TransformOperations blended(from); 186 186 for (size_t i = 0; i < blended.operations().size(); ++i) 187 187 blended.operations()[i]->blend(0, progress, true)->apply(matrix, boxSize); … … 190 190 191 191 // Animation from "-webkit-transform: none". 192 if (!from ->size()) {193 TransformOperations blended( *to);192 if (!from.size()) { 193 TransformOperations blended(to); 194 194 for (size_t i = 0; i < blended.operations().size(); ++i) 195 195 blended.operations()[i]->blend(0, 1. - progress, true)->apply(matrix, boxSize); … … 198 198 199 199 // Normal animation with a matching operation list. 200 TransformOperations blended( *to);200 TransformOperations blended(to); 201 201 for (size_t i = 0; i < blended.operations().size(); ++i) 202 blended.operations()[i]->blend(from ->at(i), progress, !from->at(i))->apply(matrix, boxSize);202 blended.operations()[i]->blend(from.at(i), progress, !from.at(i))->apply(matrix, boxSize); 203 203 return matrix; 204 204 } 205 205 206 static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue *animValue, const Animation* anim)207 { 208 if (animValue ->timingFunction())209 return animValue ->timingFunction();206 static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation* anim) 207 { 208 if (animValue.timingFunction()) 209 return animValue.timingFunction(); 210 210 if (anim->timingFunction()) 211 211 return anim->timingFunction().get(); … … 228 228 } 229 229 230 void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue * from, const AnimationValue*to, float progress)230 void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue& from, const AnimationValue& to, float progress) 231 231 { 232 232 switch (m_keyframes.property()) { 233 233 case AnimatedPropertyOpacity: 234 client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue *>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress));234 client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress)); 235 235 return; 236 236 case AnimatedPropertyWebkitTransform: 237 client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue *>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch));237 client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch)); 238 238 return; 239 239 #if ENABLE(CSS_FILTERS) 240 240 case AnimatedPropertyWebkitFilter: 241 client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue *>(from)->value(), static_cast<const FilterAnimationValue*>(to)->value(), progress, m_boxSize));241 client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize)); 242 242 return; 243 243 #endif … … 305 305 306 306 for (size_t i = 0; i < m_keyframes.size() - 1; ++i) { 307 const AnimationValue *from = m_keyframes.at(i);308 const AnimationValue *to = m_keyframes.at(i + 1);309 if (from ->keyTime() > normalizedValue || to->keyTime() < normalizedValue)307 const AnimationValue& from = m_keyframes.at(i); 308 const AnimationValue& to = m_keyframes.at(i + 1); 309 if (from.keyTime() > normalizedValue || to.keyTime() < normalizedValue) 310 310 continue; 311 311 312 normalizedValue = (normalizedValue - from ->keyTime()) / (to->keyTime() - from->keyTime());312 normalizedValue = (normalizedValue - from.keyTime()) / (to.keyTime() - from.keyTime()); 313 313 const TimingFunction* timingFunction = timingFunctionForAnimationValue(from, m_animation.get()); 314 314 normalizedValue = applyTimingFunction(timingFunction, normalizedValue, m_animation->duration()); -
trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h
r136953 r149694 67 67 68 68 private: 69 void applyInternal(Client*, const AnimationValue * from, const AnimationValue*to, float progress);69 void applyInternal(Client*, const AnimationValue& from, const AnimationValue& to, float progress); 70 70 KeyframeValueList m_keyframes; 71 71 IntSize m_boxSize; -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r149665 r149694 243 243 244 244 for (unsigned i = 0; i < valueList.size(); ++i) { 245 const TimingFunction* timingFunction = valueList.at(i)->timingFunction(); 246 if (timingFunction && timingFunction->isStepsTimingFunction()) 247 return true; 245 if (const TimingFunction* timingFunction = valueList.at(i).timingFunction()) { 246 if (timingFunction->isStepsTimingFunction()) 247 return true; 248 } 248 249 } 249 250 … … 2092 2093 bool hasBigRotation; 2093 2094 int listIndex = validateTransformOperations(valueList, hasBigRotation); 2094 const TransformOperations* operations = (listIndex >= 0) ? static_cast<const TransformAnimationValue*>(valueList.at(listIndex))->value() : 0;2095 const TransformOperations* operations = (listIndex >= 0) ? &static_cast<const TransformAnimationValue&>(valueList.at(listIndex)).value() : 0; 2095 2096 2096 2097 // We need to fall back to software animation if we don't have setValueFunction:, and … … 2182 2183 return false; 2183 2184 2184 const FilterOperations * operations = static_cast<const FilterAnimationValue*>(valueList.at(listIndex))->value();2185 const FilterOperations& operations = static_cast<const FilterAnimationValue&>(valueList.at(listIndex)).value(); 2185 2186 // Make sure the platform layer didn't fallback to using software filter compositing instead. 2186 if (!PlatformCALayer::filtersCanBeComposited( *operations))2187 if (!PlatformCALayer::filtersCanBeComposited(operations)) 2187 2188 return false; 2188 2189 2189 int numAnimations = operations ->size();2190 int numAnimations = operations.size(); 2190 2191 2191 2192 // FIXME: We can't currently hardware animate shadows. 2192 2193 for (int i = 0; i < numAnimations; ++i) { 2193 if (operations ->at(i)->getOperationType() == FilterOperation::DROP_SHADOW)2194 if (operations.at(i)->getOperationType() == FilterOperation::DROP_SHADOW) 2194 2195 return false; 2195 2196 } 2196 2197 2197 2198 for (int animationIndex = 0; animationIndex < numAnimations; ++animationIndex) { 2198 if (!appendToUncommittedAnimations(valueList, operations ->operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset))2199 if (!appendToUncommittedAnimations(valueList, operations.operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset)) 2199 2200 return false; 2200 2201 } … … 2254 2255 } 2255 2256 2256 const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue * animValue, const Animation*anim)2257 { 2258 if (animValue ->timingFunction())2259 return animValue ->timingFunction();2260 if (anim ->isTimingFunctionSet())2261 return anim ->timingFunction().get();2257 const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation& anim) 2258 { 2259 if (animValue.timingFunction()) 2260 return animValue.timingFunction(); 2261 if (anim.isTimingFunctionSet()) 2262 return anim.timingFunction().get(); 2262 2263 2263 2264 return CubicBezierTimingFunction::defaultTimingFunction(); … … 2273 2274 switch (valueList.property()) { 2274 2275 case AnimatedPropertyOpacity: { 2275 basicAnim->setFromValue(static_cast<const FloatAnimationValue *>(valueList.at(fromIndex))->value());2276 basicAnim->setToValue(static_cast<const FloatAnimationValue *>(valueList.at(toIndex))->value());2276 basicAnim->setFromValue(static_cast<const FloatAnimationValue&>(valueList.at(fromIndex)).value()); 2277 basicAnim->setToValue(static_cast<const FloatAnimationValue&>(valueList.at(toIndex)).value()); 2277 2278 break; 2278 2279 } … … 2284 2285 // This codepath is used for 2-keyframe animations, so we still need to look in the start 2285 2286 // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function. 2286 const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);2287 const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation); 2287 2288 if (timingFunction) 2288 2289 basicAnim->setTimingFunction(timingFunction, !forwards); … … 2301 2302 for (unsigned i = 0; i < valueList.size(); ++i) { 2302 2303 unsigned index = forwards ? i : (valueList.size() - i - 1); 2303 const AnimationValue *curValue = valueList.at(index);2304 keyTimes.append(forwards ? curValue ->keyTime() : (1 - curValue->keyTime()));2304 const AnimationValue& curValue = valueList.at(index); 2305 keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime())); 2305 2306 2306 2307 switch (valueList.property()) { 2307 2308 case AnimatedPropertyOpacity: { 2308 const FloatAnimationValue * floatValue = static_cast<const FloatAnimationValue*>(curValue);2309 values.append(floatValue ->value());2309 const FloatAnimationValue& floatValue = static_cast<const FloatAnimationValue&>(curValue); 2310 values.append(floatValue.value()); 2310 2311 break; 2311 2312 } … … 2316 2317 2317 2318 if (i < (valueList.size() - 1)) 2318 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));2319 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation)); 2319 2320 } 2320 2321 … … 2335 2336 unsigned toIndex = forwards; 2336 2337 2337 const TransformAnimationValue * startValue = static_cast<const TransformAnimationValue*>(valueList.at(fromIndex));2338 const TransformAnimationValue * endValue = static_cast<const TransformAnimationValue*>(valueList.at(toIndex));2338 const TransformAnimationValue& startValue = static_cast<const TransformAnimationValue&>(valueList.at(fromIndex)); 2339 const TransformAnimationValue& endValue = static_cast<const TransformAnimationValue&>(valueList.at(toIndex)); 2339 2340 2340 2341 if (isMatrixAnimation) { 2341 2342 TransformationMatrix fromTransform, toTransform; 2342 startValue ->value()->apply(boxSize, fromTransform);2343 endValue ->value()->apply(boxSize, toTransform);2343 startValue.value().apply(boxSize, fromTransform); 2344 endValue.value().apply(boxSize, toTransform); 2344 2345 2345 2346 // If any matrix is singular, CA won't animate it correctly. So fall back to software animation … … 2352 2353 if (isTransformTypeNumber(transformOpType)) { 2353 2354 float fromValue; 2354 getTransformFunctionValue(startValue ->value()->at(functionIndex), transformOpType, boxSize, fromValue);2355 getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue); 2355 2356 basicAnim->setFromValue(fromValue); 2356 2357 2357 2358 float toValue; 2358 getTransformFunctionValue(endValue ->value()->at(functionIndex), transformOpType, boxSize, toValue);2359 getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue); 2359 2360 basicAnim->setToValue(toValue); 2360 2361 } else if (isTransformTypeFloatPoint3D(transformOpType)) { 2361 2362 FloatPoint3D fromValue; 2362 getTransformFunctionValue(startValue ->value()->at(functionIndex), transformOpType, boxSize, fromValue);2363 getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue); 2363 2364 basicAnim->setFromValue(fromValue); 2364 2365 2365 2366 FloatPoint3D toValue; 2366 getTransformFunctionValue(endValue ->value()->at(functionIndex), transformOpType, boxSize, toValue);2367 getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue); 2367 2368 basicAnim->setToValue(toValue); 2368 2369 } else { 2369 2370 TransformationMatrix fromValue; 2370 getTransformFunctionValue(startValue ->value()->at(functionIndex), transformOpType, boxSize, fromValue);2371 getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue); 2371 2372 basicAnim->setFromValue(fromValue); 2372 2373 2373 2374 TransformationMatrix toValue; 2374 getTransformFunctionValue(endValue ->value()->at(functionIndex), transformOpType, boxSize, toValue);2375 getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue); 2375 2376 basicAnim->setToValue(toValue); 2376 2377 } … … 2379 2380 // This codepath is used for 2-keyframe animations, so we still need to look in the start 2380 2381 // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function. 2381 const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);2382 const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation); 2382 2383 basicAnim->setTimingFunction(timingFunction, !forwards); 2383 2384 … … 2401 2402 for (unsigned i = 0; i < valueList.size(); ++i) { 2402 2403 unsigned index = forwards ? i : (valueList.size() - i - 1); 2403 const TransformAnimationValue * curValue = static_cast<const TransformAnimationValue*>(valueList.at(index));2404 keyTimes.append(forwards ? curValue ->keyTime() : (1 - curValue->keyTime()));2404 const TransformAnimationValue& curValue = static_cast<const TransformAnimationValue&>(valueList.at(index)); 2405 keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime())); 2405 2406 2406 2407 if (isMatrixAnimation) { 2407 2408 TransformationMatrix transform; 2408 curValue ->value()->apply(boxSize, transform);2409 curValue.value().apply(boxSize, transform); 2409 2410 2410 2411 // If any matrix is singular, CA won't animate it correctly. So fall back to software animation … … 2414 2415 transformationMatrixValues.append(transform); 2415 2416 } else { 2416 const TransformOperation* transformOp = curValue ->value()->at(functionIndex);2417 const TransformOperation* transformOp = curValue.value().at(functionIndex); 2417 2418 if (isTransformTypeNumber(transformOpType)) { 2418 2419 float value; … … 2431 2432 2432 2433 if (i < (valueList.size() - 1)) 2433 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));2434 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation)); 2434 2435 } 2435 2436 … … 2462 2463 unsigned toIndex = forwards; 2463 2464 2464 const FilterAnimationValue * fromValue = static_cast<const FilterAnimationValue*>(valueList.at(fromIndex));2465 const FilterAnimationValue * toValue = static_cast<const FilterAnimationValue*>(valueList.at(toIndex));2466 2467 const FilterOperation* fromOperation = fromValue ->value()->at(functionIndex);2468 const FilterOperation* toOperation = toValue ->value()->at(functionIndex);2465 const FilterAnimationValue& fromValue = static_cast<const FilterAnimationValue&>(valueList.at(fromIndex)); 2466 const FilterAnimationValue& toValue = static_cast<const FilterAnimationValue&>(valueList.at(toIndex)); 2467 2468 const FilterOperation* fromOperation = fromValue.value().at(functionIndex); 2469 const FilterOperation* toOperation = toValue.value().at(functionIndex); 2469 2470 2470 2471 RefPtr<DefaultFilterOperation> defaultFromOperation; … … 2488 2489 // This codepath is used for 2-keyframe animations, so we still need to look in the start 2489 2490 // for a timing function. Even in the reversing animation case, the first keyframe provides the timing function. 2490 basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), animation), !forwards);2491 basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), *animation), !forwards); 2491 2492 2492 2493 return true; … … 2504 2505 for (unsigned i = 0; i < valueList.size(); ++i) { 2505 2506 unsigned index = forwards ? i : (valueList.size() - i - 1); 2506 const FilterAnimationValue * curValue = static_cast<const FilterAnimationValue*>(valueList.at(index));2507 keyTimes.append(forwards ? curValue ->keyTime() : (1 - curValue->keyTime()));2508 2509 if (curValue ->value()->operations().size() > static_cast<size_t>(functionIndex))2510 values.append(curValue ->value()->operations()[functionIndex]);2507 const FilterAnimationValue& curValue = static_cast<const FilterAnimationValue&>(valueList.at(index)); 2508 keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime())); 2509 2510 if (curValue.value().operations().size() > static_cast<size_t>(functionIndex)) 2511 values.append(curValue.value().operations()[functionIndex]); 2511 2512 else { 2512 2513 if (!defaultOperation) … … 2516 2517 2517 2518 if (i < (valueList.size() - 1)) 2518 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));2519 timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation)); 2519 2520 } 2520 2521 -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r149388 r149694 206 206 void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive); 207 207 208 const TimingFunction* timingFunctionForAnimationValue(const AnimationValue *, const Animation*);208 const TimingFunction* timingFunctionForAnimationValue(const AnimationValue&, const Animation&); 209 209 210 210 bool setAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*); -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
r149276 r149694 713 713 continue; 714 714 for (size_t j = 0; j < keyframes.size(); ++j) { 715 const FilterAnimationValue * filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));716 injectCachedCustomFilterPrograms( *filterValue->value());715 const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(i)); 716 injectCachedCustomFilterPrograms(filterValue.value()); 717 717 } 718 718 } -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r149661 r149694 2108 2108 bool isFirstOrLastKeyframe = key == 0 || key == 1; 2109 2109 if ((hasTransform && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitTransform)) 2110 transformVector.insert( adoptPtr(new TransformAnimationValue(key, &(keyframeStyle->transform()), tf)));2111 2110 transformVector.insert(TransformAnimationValue::create(key, keyframeStyle->transform(), tf)); 2111 2112 2112 if ((hasOpacity && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyOpacity)) 2113 opacityVector.insert( adoptPtr(new FloatAnimationValue(key, keyframeStyle->opacity(), tf)));2113 opacityVector.insert(FloatAnimationValue::create(key, keyframeStyle->opacity(), tf)); 2114 2114 2115 2115 #if ENABLE(CSS_FILTERS) 2116 2116 if ((hasFilter && isFirstOrLastKeyframe) || currentKeyframe.containsProperty(CSSPropertyWebkitFilter)) 2117 filterVector.insert( adoptPtr(new FilterAnimationValue(key, &(keyframeStyle->filter()), tf)));2117 filterVector.insert(FilterAnimationValue::create(key, keyframeStyle->filter(), tf)); 2118 2118 #endif 2119 2119 } … … 2155 2155 if (opacityAnim && !opacityAnim->isEmptyOrZeroDuration()) { 2156 2156 KeyframeValueList opacityVector(AnimatedPropertyOpacity); 2157 opacityVector.insert( adoptPtr(new FloatAnimationValue(0, compositingOpacity(fromStyle->opacity()))));2158 opacityVector.insert( adoptPtr(new FloatAnimationValue(1, compositingOpacity(toStyle->opacity()))));2157 opacityVector.insert(FloatAnimationValue::create(0, compositingOpacity(fromStyle->opacity()))); 2158 opacityVector.insert(FloatAnimationValue::create(1, compositingOpacity(toStyle->opacity()))); 2159 2159 // The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here. 2160 2160 if (m_graphicsLayer->addAnimation(opacityVector, IntSize(), opacityAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyOpacity), timeOffset)) { … … 2170 2170 if (transformAnim && !transformAnim->isEmptyOrZeroDuration()) { 2171 2171 KeyframeValueList transformVector(AnimatedPropertyWebkitTransform); 2172 transformVector.insert( adoptPtr(new TransformAnimationValue(0, &fromStyle->transform())));2173 transformVector.insert( adoptPtr(new TransformAnimationValue(1, &toStyle->transform())));2172 transformVector.insert(TransformAnimationValue::create(0, fromStyle->transform())); 2173 transformVector.insert(TransformAnimationValue::create(1, toStyle->transform())); 2174 2174 if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) { 2175 2175 // To ensure that the correct transform is visible when the animation ends, also set the final transform. … … 2185 2185 if (filterAnim && !filterAnim->isEmptyOrZeroDuration()) { 2186 2186 KeyframeValueList filterVector(AnimatedPropertyWebkitFilter); 2187 filterVector.insert( adoptPtr(new FilterAnimationValue(0, &fromStyle->filter())));2188 filterVector.insert( adoptPtr(new FilterAnimationValue(1, &toStyle->filter())));2187 filterVector.insert(FilterAnimationValue::create(0, fromStyle->filter())); 2188 filterVector.insert(FilterAnimationValue::create(1, toStyle->filter())); 2189 2189 if (m_graphicsLayer->addAnimation(filterVector, IntSize(), filterAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitFilter), timeOffset)) { 2190 2190 // To ensure that the correct filter is visible when the animation ends, also set the final filter. -
trunk/Source/WebKit2/ChangeLog
r149693 r149694 1 2013-05-07 Anders Carlsson <andersca@apple.com> 2 3 Clean up KeyframeValueList and related classes 4 https://bugs.webkit.org/show_bug.cgi?id=115738 5 6 Reviewed by Simon Fraser. 7 8 Update for WebCore changes. 9 10 * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp: 11 (CoreIPC::::decode): 12 1 13 2013-05-07 Anders Carlsson <andersca@apple.com> 2 14 -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
r149661 r149694 646 646 encoder << static_cast<uint32_t>(keyframes.size()); 647 647 for (size_t i = 0; i < keyframes.size(); ++i) { 648 const AnimationValue *value = keyframes.at(i);649 encoder << value ->keyTime();650 encodeTimingFunction(encoder, value ->timingFunction());648 const AnimationValue& value = keyframes.at(i); 649 encoder << value.keyTime(); 650 encodeTimingFunction(encoder, value.timingFunction()); 651 651 switch (keyframes.property()) { 652 652 case AnimatedPropertyOpacity: 653 encoder << static_cast<const FloatAnimationValue *>(value)->value();653 encoder << static_cast<const FloatAnimationValue&>(value).value(); 654 654 break; 655 655 case AnimatedPropertyWebkitTransform: 656 encoder << *static_cast<const TransformAnimationValue*>(value)->value();656 encoder << static_cast<const TransformAnimationValue&>(value).value(); 657 657 break; 658 658 #if ENABLE(CSS_FILTERS) 659 659 case AnimatedPropertyWebkitFilter: 660 encoder << *static_cast<const FilterAnimationValue*>(value)->value();660 encoder << static_cast<const FilterAnimationValue&>(value).value(); 661 661 break; 662 662 #endif … … 734 734 if (!decoder.decode(value)) 735 735 return false; 736 keyframes.insert( adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction)));736 keyframes.insert(FloatAnimationValue::create(keyTime, value, timingFunction)); 737 737 break; 738 738 } … … 741 741 if (!decoder.decode(transform)) 742 742 return false; 743 keyframes.insert( adoptPtr(new TransformAnimationValue(keyTime, &transform, timingFunction)));743 keyframes.insert(TransformAnimationValue::create(keyTime, transform, timingFunction)); 744 744 break; 745 745 } … … 749 749 if (!decoder.decode(filter)) 750 750 return false; 751 keyframes.insert( adoptPtr(new FilterAnimationValue(keyTime, &filter, timingFunction)));751 keyframes.insert(FilterAnimationValue::create(keyTime, filter, timingFunction)); 752 752 break; 753 753 } -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
r149292 r149694 343 343 continue; 344 344 for (size_t j = 0; j < keyframes.size(); ++j) { 345 const FilterAnimationValue * filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));346 checkCustomFilterProgramProxies( *filterValue->value());345 const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(i)); 346 checkCustomFilterProgramProxies(filterValue.value()); 347 347 } 348 348 }
Note: See TracChangeset
for help on using the changeset viewer.