Changeset 132275 in webkit
- Timestamp:
- Oct 23, 2012 3:19:37 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r132274 r132275 1 2012-10-23 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 Coordinated Graphics: Enable threaded/IPC animations 4 https://bugs.webkit.org/show_bug.cgi?id=93146 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Add enablers to TextureMapper and GraphicsLayerAnimation so that they could be used 9 across processes with IPC. Added some public accessors to GraphicsLayerAnimation, 10 and allowed a GraphicsLayerTextureMapper to receive a full list of animations. 11 12 Covered by existing animation and compositing tests. 13 14 * platform/graphics/GraphicsLayerAnimation.cpp: 15 (WebCore::GraphicsLayerAnimation::GraphicsLayerAnimation): 16 Initialize the animation with the startTime instead of the offset. 17 18 (WebCore::GraphicsLayerAnimations::getActiveAnimations): 19 * platform/graphics/GraphicsLayerAnimation.h: 20 (WebCore::GraphicsLayerAnimation::setState): 21 Allow setting the pause time as well. 22 23 (WebCore::GraphicsLayerAnimation::boxSize): 24 (WebCore::GraphicsLayerAnimation::startTime): 25 (WebCore::GraphicsLayerAnimation::pauseTime): 26 (WebCore::GraphicsLayerAnimation::animation): 27 (WebCore::GraphicsLayerAnimation::keyframes): 28 (WebCore::GraphicsLayerAnimation::listsMatch): 29 (WebCore::GraphicsLayerAnimations::size): 30 (WebCore::GraphicsLayerAnimations::animations): 31 Add public accessors to GraphicsLayerAnimation properties. 32 33 (GraphicsLayerAnimation): 34 (GraphicsLayerAnimations): 35 * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp: 36 (WebCore::GraphicsLayerTextureMapper::addAnimation): 37 (WebCore::GraphicsLayerTextureMapper::setAnimations): 38 Allow replacing the entire list of animations. 39 40 (WebCore): 41 * platform/graphics/texmap/GraphicsLayerTextureMapper.h: 42 (GraphicsLayerTextureMapper): 43 * platform/graphics/texmap/TextureMapperLayer.cpp: 44 (WebCore::TextureMapperLayer::applyAnimationsRecursively): 45 (WebCore): 46 * platform/graphics/texmap/TextureMapperLayer.h: 47 (TextureMapperLayer): 48 1 49 2012-10-23 Chris Rogers <crogers@google.com> 2 50 -
trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp
r127072 r132275 157 157 158 158 159 GraphicsLayerAnimation::GraphicsLayerAnimation(const String& name, const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double timeOffset, bool listsMatch)159 GraphicsLayerAnimation::GraphicsLayerAnimation(const String& name, const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double startTime, bool listsMatch) 160 160 : m_keyframes(keyframes) 161 161 , m_boxSize(boxSize) … … 163 163 , m_name(name) 164 164 , m_listsMatch(listsMatch) 165 , m_startTime( WTF::currentTime() - timeOffset)165 , m_startTime(startTime) 166 166 , m_pauseTime(0) 167 167 , m_state(PlayingState) … … 286 286 } 287 287 288 GraphicsLayerAnimations GraphicsLayerAnimations::getActiveAnimations() const 289 { 290 GraphicsLayerAnimations active; 291 for (size_t i = 0; i < m_animations.size(); ++i) { 292 if (m_animations[i].isActive()) 293 active.add(m_animations[i]); 294 } 295 return active; 296 } 288 297 } 289 298 #endif -
trunk/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h
r124908 r132275 46 46 void pause(double); 47 47 AnimationState state() const { return m_state; } 48 void setState(AnimationState s) { m_state = s; } 48 void setState(AnimationState s, double pauseTime = 0) 49 { 50 m_state = s; 51 m_pauseTime = pauseTime; 52 } 49 53 AnimatedPropertyID property() const { return m_keyframes.property(); } 50 54 bool isActive() const; 51 55 String name() const { return m_name; } 56 IntSize boxSize() const { return m_boxSize; } 57 double startTime() const { return m_startTime; } 58 double pauseTime() const { return m_pauseTime; } 59 PassRefPtr<Animation> animation() const { return m_animation.get(); } 60 const KeyframeValueList& keyframes() const { return m_keyframes; } 61 bool listsMatch() const { return m_listsMatch; } 52 62 53 63 private: … … 58 68 String m_name; 59 69 bool m_listsMatch; 60 bool m_hasBigRotation;61 70 double m_startTime; 62 71 double m_pauseTime; … … 73 82 void apply(GraphicsLayerAnimation::Client*); 74 83 bool isEmpty() const { return m_animations.isEmpty(); } 84 size_t size() const { return m_animations.size(); } 85 const Vector<GraphicsLayerAnimation>& animations() const { return m_animations; } 86 Vector<GraphicsLayerAnimation>& animations() { return m_animations; } 75 87 76 88 bool hasRunningAnimations() const; 77 89 bool hasActiveAnimationsOfType(AnimatedPropertyID type) const; 90 91 GraphicsLayerAnimations getActiveAnimations() const; 78 92 79 93 private: -
trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
r130439 r132275 21 21 #include "GraphicsLayerTextureMapper.h" 22 22 23 #include "GraphicsLayerAnimation.h" 23 24 #include "GraphicsLayerFactory.h" 24 25 #include "TextureMapperLayer.h" … … 393 394 listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0; 394 395 395 m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, timeOffset, listsMatch));396 m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, WTF::currentTime() - timeOffset, listsMatch)); 396 397 notifyChange(TextureMapperLayer::AnimationChange); 397 398 m_animationStartedTimer.startOneShot(0); … … 399 400 } 400 401 402 void GraphicsLayerTextureMapper::setAnimations(const GraphicsLayerAnimations& animations) 403 { 404 m_animations = animations; 405 notifyChange(TextureMapperLayer::AnimationChange); 406 } 407 408 401 409 void GraphicsLayerTextureMapper::pauseAnimation(const String& animationName, double timeOffset) 402 410 { -
trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
r130439 r132275 82 82 virtual void pauseAnimation(const String&, double); 83 83 virtual void removeAnimation(const String&); 84 void setAnimations(const GraphicsLayerAnimations&); 84 85 85 86 TextureMapperLayer* layer() const { return m_layer.get(); } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r132019 r132275 511 511 } 512 512 513 void TextureMapperLayer::applyAnimationsRecursively() 514 { 515 syncAnimations(); 516 for (size_t i = 0; i < m_children.size(); ++i) 517 m_children[i]->applyAnimationsRecursively(); 518 } 519 513 520 void TextureMapperLayer::syncAnimations() 514 521 { -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
r130439 r132275 133 133 134 134 void setDebugBorder(const Color&, float width); 135 void applyAnimationsRecursively(); 135 136 136 137 private: -
trunk/Source/WebKit2/ChangeLog
r132235 r132275 1 2012-10-23 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 Coordinated Graphics: Enable threaded/IPC animations 4 https://bugs.webkit.org/show_bug.cgi?id=93146 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Re-enable UI-process animations for Coordinated-Graphics/TextureMapper. 9 - Added an argument coder for GraphicsLayerAnimations. 10 - Allow LayerTreeCoordinator to manage the animations per layer with the proxy, 11 as opposed to applying the animation values in the web process as before. 12 - LayerTreeRenderer now calls updateViewport() after painting when an animation is active. 13 14 To overcome the problem we've had in the past with synchronizing UI-side and web-side 15 animations, we now lock the animations in the UI process when a frame starts rendering, 16 and unlock it when the frame finishes rendering, or if after the layout there is no visible 17 changes pending on the screen. 18 19 * Scripts/webkit2/messages.py: 20 (headers_for_type): 21 * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp: 22 (CoreIPC): 23 (CoreIPC::encodeTimingFunction): 24 (CoreIPC::decodeTimingFunction): 25 (CoreIPC::::encode): 26 (CoreIPC::::decode): 27 * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h: 28 (WebCore): 29 Added argument coders for GraphicsLayerAnimations. 30 31 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp: 32 (WebKit::LayerTreeCoordinatorProxy::setLayerAnimations): 33 (WebKit::LayerTreeCoordinatorProxy::setAnimationsLocked): 34 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h: 35 (LayerTreeCoordinatorProxy): 36 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in: 37 Added an option to sync the layer's animations, and also to lock/unlock animations. 38 39 * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp: 40 (WebKit::LayerTreeRenderer::LayerTreeRenderer): 41 (WebKit::LayerTreeRenderer::paintToCurrentGLContext): 42 Sync animations if they're not locked, and call updateViewport() if we have animations. 43 44 (WebKit::LayerTreeRenderer::flushLayerChanges): 45 (WebKit::LayerTreeRenderer::setLayerAnimations): 46 (WebKit::LayerTreeRenderer::setAnimationsLocked): 47 48 * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h: 49 (LayerTreeRenderer): 50 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp: 51 (WebCore::CoordinatedGraphicsLayer::didChangeAnimations): 52 (WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect): 53 (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer): 54 (WebCore::CoordinatedGraphicsLayer::syncLayerState): 55 (WebCore::CoordinatedGraphicsLayer::syncAnimations): 56 (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly): 57 (WebCore::CoordinatedGraphicsLayer::addAnimation): 58 (WebCore::CoordinatedGraphicsLayer::pauseAnimation): 59 (WebCore::CoordinatedGraphicsLayer::removeAnimation): 60 (WebCore::CoordinatedGraphicsLayer::animationStartedTimerFired): 61 (WebCore): 62 Pass the animation info to the UI process instead of applying it in the web process. 63 64 (WebCore::CoordinatedGraphicsLayer::hasPendingVisibleChanges): 65 Compute whether a layer tree might have sync issues or flickers if rendered while 66 background animations are ongoing. 67 68 (WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect): 69 (WebCore::CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms): 70 Don't allow progressive tiling for layers with animations. 71 72 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h: 73 (WebCore): 74 (CoordinatedGraphicsLayerClient): 75 (CoordinatedGraphicsLayer): 76 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp: 77 (WebKit::LayerTreeCoordinator::LayerTreeCoordinator): 78 (WebKit::LayerTreeCoordinator::lockAnimations): 79 (WebKit): 80 (WebKit::LayerTreeCoordinator::unlockAnimations): 81 (WebKit::LayerTreeCoordinator::performScheduledLayerFlush): 82 (WebKit::LayerTreeCoordinator::setLayerAnimations): 83 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h: 84 (LayerTreeCoordinator): 85 1 86 2012-10-23 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 87 -
trunk/Source/WebKit2/Scripts/webkit2/messages.py
r132085 r132275 388 388 'WebCore::CompositionUnderline': ['<WebCore/Editor.h>'], 389 389 'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'], 390 'WebCore::GraphicsLayerAnimations': ['<WebCore/GraphicsLayerAnimation.h>'], 390 391 'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'], 391 392 'WebCore::KeypressCommand': ['<WebCore/KeyboardEvent.h>'], -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
r131990 r132275 34 34 #include <WebCore/Color.h> 35 35 #include <WebCore/FloatPoint3D.h> 36 #include <WebCore/GraphicsLayerAnimation.h> 37 #include <WebCore/IdentityTransformOperation.h> 36 38 #include <WebCore/IntPoint.h> 37 39 #include <WebCore/Length.h> 40 #include <WebCore/Matrix3DTransformOperation.h> 41 #include <WebCore/MatrixTransformOperation.h> 42 #include <WebCore/PerspectiveTransformOperation.h> 43 #include <WebCore/RotateTransformOperation.h> 44 #include <WebCore/ScaleTransformOperation.h> 45 #include <WebCore/SkewTransformOperation.h> 46 #include <WebCore/TimingFunction.h> 38 47 #include <WebCore/TransformationMatrix.h> 48 #include <WebCore/TranslateTransformOperation.h> 39 49 40 50 #if ENABLE(CSS_FILTERS) … … 49 59 #include <WebCore/CustomFilterProgram.h> 50 60 #include <WebCore/CustomFilterTransformParameter.h> 51 #include <WebCore/IdentityTransformOperation.h> 52 #include <WebCore/Matrix3DTransformOperation.h> 53 #include <WebCore/MatrixTransformOperation.h> 54 #include <WebCore/PerspectiveTransformOperation.h> 55 #include <WebCore/RotateTransformOperation.h> 56 #include <WebCore/ScaleTransformOperation.h> 57 #include <WebCore/SkewTransformOperation.h> 58 #include <WebCore/TranslateTransformOperation.h> 59 #endif 61 #endif 62 60 63 61 64 #if USE(GRAPHICS_SURFACE) … … 345 348 #endif 346 349 347 #if ENABLE(CSS_SHADERS)348 350 void ArgumentCoder<TransformOperations>::encode(ArgumentEncoder* encoder, const TransformOperations& transformOperations) 349 351 { … … 505 507 return true; 506 508 } 507 #endif 509 510 static void encodeTimingFunction(ArgumentEncoder* encoder, const TimingFunction* timingFunction) 511 { 512 if (!timingFunction) { 513 encoder->encodeEnum(TimingFunction::TimingFunctionType(-1)); 514 return; 515 } 516 517 TimingFunction::TimingFunctionType type = timingFunction ? timingFunction->type() : TimingFunction::LinearFunction; 518 encoder->encodeEnum(type); 519 switch (type) { 520 case TimingFunction::LinearFunction: 521 break; 522 case TimingFunction::CubicBezierFunction: { 523 const CubicBezierTimingFunction* cubic = static_cast<const CubicBezierTimingFunction*>(timingFunction); 524 encoder->encodeDouble(cubic->x1()); 525 encoder->encodeDouble(cubic->y1()); 526 encoder->encodeDouble(cubic->x2()); 527 encoder->encodeDouble(cubic->y2()); 528 break; 529 } 530 case TimingFunction::StepsFunction: { 531 const StepsTimingFunction* steps = static_cast<const StepsTimingFunction*>(timingFunction); 532 encoder->encodeInt32(steps->numberOfSteps()); 533 encoder->encodeBool(steps->stepAtStart()); 534 break; 535 } 536 } 537 } 538 539 bool decodeTimingFunction(ArgumentDecoder* decoder, RefPtr<TimingFunction>& timingFunction) 540 { 541 TimingFunction::TimingFunctionType type; 542 if (!decoder->decodeEnum(type)) 543 return false; 544 545 if (type == TimingFunction::TimingFunctionType(-1)) 546 return true; 547 548 switch (type) { 549 case TimingFunction::LinearFunction: 550 timingFunction = LinearTimingFunction::create(); 551 return true; 552 case TimingFunction::CubicBezierFunction: { 553 double x1, y1, x2, y2; 554 if (!decoder->decodeDouble(x1)) 555 return false; 556 if (!decoder->decodeDouble(y1)) 557 return false; 558 if (!decoder->decodeDouble(x2)) 559 return false; 560 if (!decoder->decodeDouble(y2)) 561 return false; 562 563 timingFunction = CubicBezierTimingFunction::create(x1, y1, x2, y2); 564 return true; 565 } 566 case TimingFunction::StepsFunction: { 567 int numberOfSteps; 568 bool stepAtStart; 569 if (!decoder->decodeInt32(numberOfSteps)) 570 return false; 571 if (!decoder->decodeBool(stepAtStart)) 572 return false; 573 574 timingFunction = StepsTimingFunction::create(numberOfSteps, stepAtStart); 575 return true; 576 } 577 } 578 579 return false; 580 } 581 582 void ArgumentCoder<GraphicsLayerAnimation>::encode(ArgumentEncoder* encoder, const GraphicsLayerAnimation& animation) 583 { 584 encoder->encode(animation.name()); 585 encoder->encode(animation.boxSize()); 586 encoder->encodeEnum(animation.state()); 587 encoder->encodeDouble(animation.startTime()); 588 encoder->encodeDouble(animation.pauseTime()); 589 encoder->encodeBool(animation.listsMatch()); 590 591 RefPtr<Animation> animationObject = animation.animation(); 592 encoder->encodeEnum(animationObject->direction()); 593 encoder->encodeUInt32(animationObject->fillMode()); 594 encoder->encodeDouble(animationObject->duration()); 595 encoder->encodeDouble(animationObject->iterationCount()); 596 encodeTimingFunction(encoder, animationObject->timingFunction().get()); 597 598 const KeyframeValueList& keyframes = animation.keyframes(); 599 encoder->encodeEnum(keyframes.property()); 600 encoder->encodeUInt32(keyframes.size()); 601 for (size_t i = 0; i < keyframes.size(); ++i) { 602 const AnimationValue* value = keyframes.at(i); 603 encoder->encodeFloat(value->keyTime()); 604 encodeTimingFunction(encoder, value->timingFunction()); 605 switch (keyframes.property()) { 606 case AnimatedPropertyOpacity: 607 encoder->encodeFloat(static_cast<const FloatAnimationValue*>(value)->value()); 608 break; 609 case AnimatedPropertyWebkitTransform: 610 encoder->encode(*static_cast<const TransformAnimationValue*>(value)->value()); 611 break; 612 default: 613 break; 614 } 615 } 616 } 617 618 bool ArgumentCoder<GraphicsLayerAnimation>::decode(ArgumentDecoder* decoder, GraphicsLayerAnimation& animation) 619 { 620 String name; 621 IntSize boxSize; 622 GraphicsLayerAnimation::AnimationState state; 623 double startTime; 624 double pauseTime; 625 bool listsMatch; 626 627 Animation::AnimationDirection direction; 628 unsigned fillMode; 629 double duration; 630 double iterationCount; 631 RefPtr<TimingFunction> timingFunction; 632 RefPtr<Animation> animationObject; 633 634 if (!decoder->decode(name)) 635 return false; 636 if (!decoder->decode(boxSize)) 637 return false; 638 if (!decoder->decodeEnum(state)) 639 return false; 640 if (!decoder->decodeDouble(startTime)) 641 return false; 642 if (!decoder->decodeDouble(pauseTime)) 643 return false; 644 if (!decoder->decodeBool(listsMatch)) 645 return false; 646 if (!decoder->decodeEnum(direction)) 647 return false; 648 if (!decoder->decodeUInt32(fillMode)) 649 return false; 650 if (!decoder->decodeDouble(duration)) 651 return false; 652 if (!decoder->decodeDouble(iterationCount)) 653 return false; 654 if (!decodeTimingFunction(decoder, timingFunction)) 655 return false; 656 657 animationObject = Animation::create(); 658 animationObject->setDirection(direction); 659 animationObject->setFillMode(fillMode); 660 animationObject->setDuration(duration); 661 animationObject->setIterationCount(iterationCount); 662 if (timingFunction) 663 animationObject->setTimingFunction(timingFunction); 664 665 AnimatedPropertyID property; 666 if (!decoder->decodeEnum(property)) 667 return false; 668 KeyframeValueList keyframes(property); 669 unsigned keyframesSize; 670 if (!decoder->decodeUInt32(keyframesSize)) 671 return false; 672 for (unsigned i = 0; i < keyframesSize; ++i) { 673 float keyTime; 674 RefPtr<TimingFunction> timingFunction; 675 if (!decoder->decode(keyTime)) 676 return false; 677 if (!decodeTimingFunction(decoder, timingFunction)) 678 return false; 679 680 switch (property) { 681 case AnimatedPropertyOpacity: { 682 float value; 683 if (!decoder->decodeFloat(value)) 684 return false; 685 keyframes.insert(new FloatAnimationValue(keyTime, value, timingFunction)); 686 break; 687 } 688 case AnimatedPropertyWebkitTransform: { 689 TransformOperations transform; 690 if (!decoder->decode(transform)) 691 return false; 692 keyframes.insert(new TransformAnimationValue(keyTime, &transform, timingFunction)); 693 break; 694 } 695 default: 696 break; 697 } 698 } 699 700 animation = GraphicsLayerAnimation(name, keyframes, boxSize, animationObject.get(), startTime, listsMatch); 701 animation.setState(state, pauseTime); 702 703 return true; 704 } 705 706 void ArgumentCoder<GraphicsLayerAnimations>::encode(ArgumentEncoder* encoder, const GraphicsLayerAnimations& animations) 707 { 708 encoder->encode(animations.animations()); 709 } 710 711 bool ArgumentCoder<GraphicsLayerAnimations>::decode(ArgumentDecoder* decoder, GraphicsLayerAnimations& animations) 712 { 713 return decoder->decode(animations.animations()); 714 } 508 715 509 716 #if USE(GRAPHICS_SURFACE) -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h
r131741 r132275 34 34 namespace WebCore { 35 35 class FloatPoint3D; 36 class GraphicsLayerAnimation; 37 class GraphicsLayerAnimations; 36 38 class TransformationMatrix; 37 39 struct Length; … … 74 76 #endif 75 77 76 #if ENABLE(CSS_SHADERS)77 78 template<> struct ArgumentCoder<WebCore::TransformOperations> { 78 79 static void encode(ArgumentEncoder*, const WebCore::TransformOperations&); 79 80 static bool decode(ArgumentDecoder*, WebCore::TransformOperations&); 80 81 }; 81 #endif 82 83 template<> struct ArgumentCoder<WebCore::GraphicsLayerAnimations> { 84 static void encode(ArgumentEncoder*, const WebCore::GraphicsLayerAnimations&); 85 static bool decode(ArgumentDecoder*, WebCore::GraphicsLayerAnimations&); 86 }; 87 88 template<> struct ArgumentCoder<WebCore::GraphicsLayerAnimation> { 89 static void encode(ArgumentEncoder*, const WebCore::GraphicsLayerAnimation&); 90 static bool decode(ArgumentDecoder*, WebCore::GraphicsLayerAnimation&); 91 }; 82 92 83 93 #if USE(GRAPHICS_SURFACE) -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
r132228 r132275 145 145 } 146 146 147 void LayerTreeCoordinatorProxy::setLayerAnimat edOpacity(uint32_t id, float opacity)147 void LayerTreeCoordinatorProxy::setLayerAnimations(WebLayerID id, const GraphicsLayerAnimations& animations) 148 148 { 149 dispatchUpdate(bind(&LayerTreeRenderer::set AnimatedOpacity, m_renderer.get(), id, opacity));149 dispatchUpdate(bind(&LayerTreeRenderer::setLayerAnimations, m_renderer.get(), id, animations)); 150 150 } 151 151 152 void LayerTreeCoordinatorProxy::set LayerAnimatedTransform(uint32_t id, const WebCore::TransformationMatrix& transform)152 void LayerTreeCoordinatorProxy::setAnimationsLocked(bool locked) 153 153 { 154 dispatchUpdate(bind(&LayerTreeRenderer::setAnimat edTransform, m_renderer.get(), id, transform));154 dispatchUpdate(bind(&LayerTreeRenderer::setAnimationsLocked, m_renderer.get(), locked)); 155 155 } 156 156 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
r131807 r132275 31 31 #include <WebCore/GraphicsContext.h> 32 32 #include <WebCore/GraphicsLayer.h> 33 #include <WebCore/GraphicsLayerAnimation.h> 33 34 #include <WebCore/GraphicsSurfaceToken.h> 34 35 #include <WebCore/IntRect.h> … … 81 82 void purgeBackingStores(); 82 83 LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); } 83 void setLayerAnimat edOpacity(uint32_t, float);84 void set LayerAnimatedTransform(uint32_t, const WebCore::TransformationMatrix&);84 void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&); 85 void setAnimationsLocked(bool); 85 86 86 87 protected: -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
r131036 r132275 34 34 DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect) 35 35 DidChangeScrollPosition(WebCore::IntPoint position) 36 SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations) 37 SetAnimationsLocked(bool locked) 38 36 39 #if USE(GRAPHICS_SURFACE) 37 40 SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token, uint32_t frontBuffer) 38 41 #endif 39 SetLayerAnimatedOpacity(uint32_t id, float opacity)40 SetLayerAnimatedTransform(uint32_t id, WebCore::TransformationMatrix transform)41 42 } 42 43 #endif -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
r132019 r132275 89 89 , m_rootLayerID(InvalidWebLayerID) 90 90 , m_isActive(false) 91 , m_animationsLocked(false) 91 92 { 92 93 } … … 121 122 122 123 layer->setTextureMapper(m_textureMapper.get()); 124 if (!m_animationsLocked) 125 layer->applyAnimationsRecursively(); 123 126 m_textureMapper->beginPainting(PaintFlags); 124 127 m_textureMapper->beginClip(TransformationMatrix(), clipRect); … … 133 136 m_textureMapper->endClip(); 134 137 m_textureMapper->endPainting(); 138 139 if (layer->descendantsOrSelfHaveRunningAnimations()) 140 dispatchOnMainThread(bind(&LayerTreeRenderer::updateViewport, this)); 135 141 } 136 142 … … 394 400 m_renderedContentsScrollPosition = m_pendingRenderedContentsScrollPosition; 395 401 402 // Since the frame has now been rendered, we can safely unlock the animations until the next layout. 403 setAnimationsLocked(false); 404 396 405 m_rootLayer->flushCompositingState(FloatRect()); 397 406 commitTileOperations(); … … 462 471 } 463 472 464 void LayerTreeRenderer::setAnimatedOpacity(uint32_t id, float opacity) 465 { 466 GraphicsLayer* layer = layerByID(id); 467 ASSERT(layer); 468 469 layer->setOpacity(opacity); 470 } 471 472 void LayerTreeRenderer::setAnimatedTransform(uint32_t id, const WebCore::TransformationMatrix& transform) 473 { 474 GraphicsLayer* layer = layerByID(id); 475 ASSERT(layer); 476 477 layer->setTransform(transform); 473 void LayerTreeRenderer::setLayerAnimations(WebLayerID id, const GraphicsLayerAnimations& animations) 474 { 475 GraphicsLayerTextureMapper* layer = toGraphicsLayerTextureMapper(layerByID(id)); 476 if (!layer) 477 return; 478 layer->setAnimations(animations); 479 } 480 481 void LayerTreeRenderer::setAnimationsLocked(bool locked) 482 { 483 m_animationsLocked = locked; 478 484 } 479 485 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h
r131036 r132275 29 29 #include <WebCore/GraphicsContext.h> 30 30 #include <WebCore/GraphicsLayer.h> 31 #include <WebCore/GraphicsLayerAnimation.h> 31 32 #include <WebCore/GraphicsSurface.h> 32 33 #include <WebCore/IntRect.h> … … 92 93 void createImage(int64_t, PassRefPtr<ShareableBitmap>); 93 94 void destroyImage(int64_t); 94 void set AnimatedOpacity(uint32_t, float);95 void setAnimat edTransform(uint32_t, const WebCore::TransformationMatrix&);95 void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&); 96 void setAnimationsLocked(bool); 96 97 97 98 private: … … 148 149 WebCore::IntPoint m_pendingRenderedContentsScrollPosition; 149 150 bool m_isActive; 151 bool m_animationsLocked; 150 152 }; 151 153 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp
r131617 r132275 69 69 } 70 70 71 void CoordinatedGraphicsLayer::didChangeAnimat edProperties()72 { 73 m_shouldSyncAnimat edProperties = true;71 void CoordinatedGraphicsLayer::didChangeAnimations() 72 { 73 m_shouldSyncAnimations = true; 74 74 if (client()) 75 75 client()->notifyFlushRequired(this); … … 94 94 void CoordinatedGraphicsLayer::setShouldUpdateVisibleRect() 95 95 { 96 if (!transform().isAffine())97 return;98 99 96 m_shouldUpdateVisibleRect = true; 100 97 for (size_t i = 0; i < children().size(); ++i) … … 118 115 , m_shouldSyncChildren(true) 119 116 , m_shouldSyncFilters(true) 120 , m_shouldSyncAnimat edProperties(true)117 , m_shouldSyncAnimations(true) 121 118 , m_fixedToViewport(false) 122 119 , m_canvasNeedsDisplay(false) … … 500 497 m_layerInfo.size = size(); 501 498 m_layerInfo.transform = transform(); 502 if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))503 m_effectiveTransform = transform();504 if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))505 m_effectiveOpacity = opacity();506 499 m_CoordinatedGraphicsLayerClient->syncLayerState(m_id, m_layerInfo); 507 500 } 508 501 509 void CoordinatedGraphicsLayer::syncAnimatedProperties() 510 { 511 m_animations.apply(this); 512 if (!m_shouldSyncAnimatedProperties) 513 return; 514 515 m_shouldSyncAnimatedProperties = false; 516 if (m_effectiveOpacity != opacity()) 517 m_CoordinatedGraphicsLayerClient->setLayerAnimatedOpacity(id(), m_effectiveOpacity); 518 if (m_effectiveTransform != transform()) 519 m_CoordinatedGraphicsLayerClient->setLayerAnimatedTransform(id(), m_effectiveTransform); 520 } 521 502 void CoordinatedGraphicsLayer::syncAnimations() 503 { 504 if (!m_shouldSyncAnimations) 505 return; 506 507 m_shouldSyncAnimations = false; 508 509 m_CoordinatedGraphicsLayerClient->setLayerAnimations(m_id, m_animations); 510 } 522 511 523 512 void CoordinatedGraphicsLayer::syncCanvas() … … 551 540 ensureImageBackingStore(); 552 541 syncLayerState(); 553 syncAnimat edProperties();542 syncAnimations(); 554 543 computeTransformedVisibleRect(); 555 544 syncChildren(); … … 750 739 } 751 740 741 bool CoordinatedGraphicsLayer::hasPendingVisibleChanges() 742 { 743 if (opacity() < 0.01 && !m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity)) 744 return false; 745 746 for (size_t i = 0; i < children().size(); ++i) { 747 if (toCoordinatedGraphicsLayer(children()[i])->hasPendingVisibleChanges()) 748 return true; 749 } 750 751 if (!m_shouldSyncLayerState && !m_shouldSyncChildren && !m_shouldSyncFilters && !m_shouldSyncAnimations && !m_canvasNeedsDisplay) 752 return false; 753 754 return selfOrAncestorHaveNonAffineTransforms() || !tiledBackingStoreVisibleRect().isEmpty(); 755 756 } 757 752 758 void CoordinatedGraphicsLayer::computeTransformedVisibleRect() 753 759 { 754 760 if (!m_shouldUpdateVisibleRect) 755 761 return; 762 756 763 m_shouldUpdateVisibleRect = false; 757 m_layerTransform.setLocalTransform( m_effectiveTransform);764 m_layerTransform.setLocalTransform(transform()); 758 765 m_layerTransform.setPosition(position()); 759 766 m_layerTransform.setAnchorPoint(anchorPoint()); … … 780 787 bool CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms() 781 788 { 789 if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform)) 790 return true; 791 782 792 if (!m_layerTransform.combined().isAffine()) 783 793 return true; … … 799 809 listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) >= 0; 800 810 801 m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, timeOffset, listsMatch));811 m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, WTF::currentTime() - timeOffset, listsMatch)); 802 812 m_animationStartedTimer.startOneShot(0); 803 didChange LayerState();813 didChangeAnimations(); 804 814 return true; 805 815 } … … 808 818 { 809 819 m_animations.pause(animationName, timeOffset); 820 didChangeAnimations(); 810 821 } 811 822 … … 813 824 { 814 825 m_animations.remove(animationName); 826 didChangeAnimations(); 815 827 } 816 828 … … 819 831 client()->notifyAnimationStarted(this, /* DOM time */ WTF::currentTime()); 820 832 } 821 822 void CoordinatedGraphicsLayer::setAnimatedTransform(const TransformationMatrix& transform)823 {824 m_effectiveTransform = transform;825 didChangeAnimatedProperties();826 m_shouldUpdateVisibleRect = true;827 }828 829 void CoordinatedGraphicsLayer::setAnimatedOpacity(float opacity)830 {831 m_effectiveOpacity = opacity;832 didChangeAnimatedProperties();833 }834 835 833 } 836 834 #endif -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h
r131297 r132275 43 43 namespace WebCore { 44 44 class CoordinatedGraphicsLayer; 45 class GraphicsLayerAnimations; 45 46 } 46 47 … … 67 68 #endif 68 69 69 virtual void setLayerAnimatedOpacity(WebLayerID, float) = 0; 70 virtual void setLayerAnimatedTransform(WebLayerID, const WebCore::TransformationMatrix&) = 0; 70 virtual void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&) = 0; 71 71 72 72 virtual void attachLayer(WebCore::CoordinatedGraphicsLayer*) = 0; … … 80 80 81 81 class CoordinatedGraphicsLayer : public WebCore::GraphicsLayer 82 , public TiledBackingStoreClient 83 , public WebKit::CoordinatedTileClient 84 , public GraphicsLayerAnimation::Client { 82 , public TiledBackingStoreClient 83 , public WebKit::CoordinatedTileClient { 85 84 public: 86 85 CoordinatedGraphicsLayer(GraphicsLayerClient*); … … 167 166 void updateContentBuffers(); 168 167 void purgeBackingStores(); 169 170 // GraphicsLayerAnimation::Client 171 virtual void setAnimatedTransform(const TransformationMatrix&); 172 virtual void setAnimatedOpacity(float); 168 bool hasPendingVisibleChanges(); 173 169 174 170 virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double); … … 189 185 bool m_shouldSyncChildren: 1; 190 186 bool m_shouldSyncFilters: 1; 191 bool m_shouldSyncAnimat edProperties: 1;187 bool m_shouldSyncAnimations: 1; 192 188 bool m_fixedToViewport : 1; 193 189 bool m_canvasNeedsDisplay : 1; 194 190 195 191 void notifyChange(); 196 void didChangeAnimat edProperties();192 void didChangeAnimations(); 197 193 void didChangeGeometry(); 198 194 void didChangeLayerState(); … … 212 208 void computeTransformedVisibleRect(); 213 209 void syncLayerParameters(); 214 void syncAnimat edProperties();210 void syncAnimations(); 215 211 void setShouldUpdateVisibleRect(); 216 212 float effectiveContentsScale(); -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp
r131741 r132275 83 83 , m_layerFlushSchedulingEnabled(true) 84 84 , m_forceRepaintAsyncCallbackID(0) 85 , m_animationsLocked(false) 85 86 { 86 87 // Create a root layer. … … 388 389 } 389 390 391 void LayerTreeCoordinator::lockAnimations() 392 { 393 m_animationsLocked = true; 394 m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(true)); 395 } 396 397 void LayerTreeCoordinator::unlockAnimations() 398 { 399 if (!m_animationsLocked) 400 return; 401 402 m_animationsLocked = false; 403 m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetAnimationsLocked(false)); 404 } 405 390 406 void LayerTreeCoordinator::performScheduledLayerFlush() 391 407 { … … 393 409 return; 394 410 411 // We lock the animations while performing layout, to avoid flickers caused by animations continuing in the UI process while 412 // the web process layout wants to cancel them. 413 lockAnimations(); 395 414 syncDisplayState(); 415 416 // We can unlock the animations before flushing if there are no visible changes, for example if there are content updates 417 // in a layer with opacity 0. 418 bool canUnlockBeforeFlush = !m_isValid || !toCoordinatedGraphicsLayer(m_rootLayer.get())->hasPendingVisibleChanges(); 419 if (canUnlockBeforeFlush) 420 unlockAnimations(); 396 421 397 422 if (!m_isValid) … … 581 606 582 607 583 void LayerTreeCoordinator::setLayerAnimatedOpacity(WebLayerID id, float opacity) 584 { 585 m_shouldSyncFrame = true; 586 m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimatedOpacity(id, opacity)); 587 } 588 589 void LayerTreeCoordinator::setLayerAnimatedTransform(WebLayerID id, const TransformationMatrix& transform) 590 { 591 m_shouldSyncFrame = true; 592 m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimatedTransform(id, transform)); 608 void LayerTreeCoordinator::setLayerAnimations(WebLayerID layerID, const GraphicsLayerAnimations& animations) 609 { 610 m_shouldSyncFrame = true; 611 m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetLayerAnimations(layerID, animations.getActiveAnimations())); 593 612 } 594 613 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h
r131807 r132275 85 85 virtual void syncLayerState(WebLayerID, const WebLayerInfo&); 86 86 virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&); 87 virtual void setLayerAnimatedOpacity(WebLayerID, float); 88 virtual void setLayerAnimatedTransform(WebLayerID, const WebCore::TransformationMatrix&); 87 virtual void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&); 89 88 #if ENABLE(CSS_FILTERS) 90 89 virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&); … … 122 121 void didPerformScheduledLayerFlush(); 123 122 void syncDisplayState(); 123 void lockAnimations(); 124 void unlockAnimations(); 124 125 125 126 void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*); … … 157 158 bool m_layerFlushSchedulingEnabled; 158 159 uint64_t m_forceRepaintAsyncCallbackID; 160 bool m_animationsLocked; 159 161 }; 160 162
Note: See TracChangeset
for help on using the changeset viewer.