Changeset 128131 in webkit
- Timestamp:
- Sep 10, 2012 5:07:26 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r128129 r128131 1 2012-09-10 Philip Rogers <pdr@google.com> 2 3 Remove unnecessary work in SMILTimeContainer::updateAnimations 4 https://bugs.webkit.org/show_bug.cgi?id=96224 5 6 Reviewed by Nikolas Zimmermann. 7 8 This change should have no functional differences but a test 9 is being added to show that. SMILTimeContainer::updateAnimations 10 contained a comment explaining why a animateTransform needed to be 11 processed last but that is no longer the case (as the test shows). 12 13 * svg/animations/script-tests/use-animate-transform-and-position.js: Added. 14 (sample1): 15 (sample2): 16 (sample3): 17 (sample4): 18 (sample5): 19 (executeTest): 20 * svg/animations/use-animate-transform-and-position-expected.txt: Added. 21 * svg/animations/use-animate-transform-and-position.html: Added. 22 1 23 2012-09-10 Jer Noble <jer.noble@apple.com> 2 24 -
trunk/Source/WebCore/ChangeLog
r128130 r128131 1 2012-09-10 Philip Rogers <pdr@google.com> 2 3 Remove unnecessary codepaths in SMILTimeContainer::updateAnimations 4 https://bugs.webkit.org/show_bug.cgi?id=96224 5 6 Reviewed by Nikolas Zimmermann. 7 8 This change removes two sources of unnecessary code in 9 SMILTimeContainer::updateAnimations: 10 1) After r117711 we now accumulate the result of multiple 11 animations into the first _contributing_ animation 12 element. As a result it is no longer necessary to 13 track both which elements are contributing AND which elements 14 we are storing results into. Both cases are now handled 15 together with resultsElements. 16 17 2) r32044 added a second sort of the animation elements 18 in order to process animateTransform last. This change 19 was added 4 years ago, before we correctly handled <use> 20 and the instance tree, and I think the extra sort is no 21 longer necessary. A test has been added to ensure this 22 is the case. 23 24 This change also does a minor cleanup of resultsElements. Previously, 25 we added animation elements to resultsElements and then removed them 26 if the animation element did not contribute. After this change, we 27 only add to resultsElements (no more add-then-remove). 28 29 Test: svg/animations/use-animate-transform-and-position.html 30 31 * svg/animation/SMILTimeContainer.cpp: 32 (WebCore::SMILTimeContainer::sortByPriority): 33 (WebCore::SMILTimeContainer::updateAnimations): 34 1 35 2012-09-10 Ojan Vafai <ojan@chromium.org> 2 36 -
trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp
r127474 r128131 205 205 std::sort(smilElements.begin(), smilElements.end(), PriorityCompare(elapsed)); 206 206 } 207 208 static bool applyOrderSortFunction(SVGSMILElement* a, SVGSMILElement* b)209 {210 if (!a->hasTagName(SVGNames::animateTransformTag) && b->hasTagName(SVGNames::animateTransformTag))211 return true;212 return false;213 }214 215 static void sortByApplyOrder(Vector<SVGSMILElement*>& smilElements)216 {217 std::sort(smilElements.begin(), smilElements.end(), applyOrderSortFunction);218 }219 207 220 208 void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) … … 230 218 // have higher priority. 231 219 sortByPriority(toAnimate, elapsed); 232 220 233 221 // Calculate animation contributions. 234 222 typedef pair<SVGElement*, QualifiedName> ElementAttributePair; 235 typedef HashMap<ElementAttributePair, RefPtr<SVGSMILElement>> ResultElementMap;223 typedef HashMap<ElementAttributePair, SVGSMILElement*> ResultElementMap; 236 224 ResultElementMap resultsElements; 237 HashSet<SVGSMILElement*> contributingElements;238 225 for (unsigned n = 0; n < toAnimate.size(); ++n) { 239 226 SVGSMILElement* animation = toAnimate[n]; … … 243 230 if (!targetElement) 244 231 continue; 245 232 246 233 QualifiedName attributeName = animation->attributeName(); 247 234 if (attributeName == anyQName()) { … … 251 238 continue; 252 239 } 253 240 254 241 // Results are accumulated to the first animation that animates and contributes to a particular element/attribute pair. 255 242 ElementAttributePair key(targetElement, attributeName); 256 SVGSMILElement* resultElement = resultsElements.get(key).get(); 257 bool accumulatedResultElement = false; 243 SVGSMILElement* resultElement = resultsElements.get(key); 258 244 if (!resultElement) { 259 245 if (!animation->hasValidAttributeType()) 260 246 continue; 261 247 resultElement = animation; 248 } else 249 ASSERT(resultElement != animation); 250 251 // This will calculate the contribution from the animation and add it to the resultsElement. 252 if (animation->progress(elapsed, resultElement, seekToTime) && resultElement == animation) 262 253 resultsElements.add(key, resultElement); 263 accumulatedResultElement = true;264 }265 266 // This will calculate the contribution from the animation and add it to the resultsElement.267 if (animation->progress(elapsed, resultElement, seekToTime))268 contributingElements.add(resultElement);269 else if (accumulatedResultElement)270 resultsElements.remove(key);271 254 272 255 SMILTime nextFireTime = animation->nextProgressTime(); … … 274 257 earliersFireTime = min(nextFireTime, earliersFireTime); 275 258 } 276 277 Vector<SVGSMILElement*> animationsToApply; 259 260 unsigned resultsToApplySize = resultsElements.size(); 261 if (!resultsToApplySize) { 262 startTimer(earliersFireTime, animationFrameDelay); 263 return; 264 } 265 266 // Apply results to target elements. 278 267 ResultElementMap::iterator end = resultsElements.end(); 279 for (ResultElementMap::iterator it = resultsElements.begin(); it != end; ++it) { 280 SVGSMILElement* animation = it->second.get(); 281 if (contributingElements.contains(animation)) 282 animationsToApply.append(animation); 283 } 284 285 unsigned animationsToApplySize = animationsToApply.size(); 286 if (!animationsToApplySize) { 287 startTimer(earliersFireTime, animationFrameDelay); 288 return; 289 } 290 291 // Sort <animateTranform> to be the last one to be applied. <animate> may change transform attribute as 292 // well (directly or indirectly by modifying <use> x/y) and this way transforms combine properly. 293 sortByApplyOrder(animationsToApply); 294 295 // Apply results to target elements. 296 for (unsigned i = 0; i < animationsToApplySize; ++i) 297 animationsToApply[i]->applyResultsToTarget(); 268 for (ResultElementMap::iterator it = resultsElements.begin(); it != end; ++it) 269 it->second->applyResultsToTarget(); 298 270 299 271 startTimer(earliersFireTime, animationFrameDelay);
Note: See TracChangeset
for help on using the changeset viewer.