Changeset 147443 in webkit
- Timestamp:
- Apr 2, 2013 10:16:14 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147441 r147443 1 2013-04-02 ChangSeok Oh <changseok.oh@collabora.com> 2 3 [GTK][AC] Support preserves3D css property for clutter ac backend. 4 https://bugs.webkit.org/show_bug.cgi?id=113318 5 6 Reviewed by Gustavo Noronha Silva. 7 8 This patch brings preserve-3D css property support to WebKitGtk+ with clutter ac backed. 9 Most of the code is based on Mac port's implementation. The core concept is that 10 if a layer has preserve-3d property false, we mark itself and its immediate children 11 to make them flatten. And then we remove 3D factor in a modelView matrix 12 when applying it to each actor. 13 14 No new tests as this is covered with existing AC tests. 15 16 * platform/graphics/clutter/GraphicsLayerActor.cpp: 17 (_GraphicsLayerActorPrivate): 18 (graphics_layer_actor_init): 19 (graphicsLayerActorApplyTransform): 20 (graphicsLayerActorNew): 21 (graphicsLayerActorRemoveFromSuperLayer): 22 (graphicsLayerActorSetDrawsContent): 23 (graphicsLayerActorSetFlatten): 24 * platform/graphics/clutter/GraphicsLayerActor.h: 25 * platform/graphics/clutter/GraphicsLayerClutter.cpp: 26 (WebCore::GraphicsLayerClutter::~GraphicsLayerClutter): 27 (WebCore::GraphicsLayerClutter::platformLayer): 28 (WebCore::GraphicsLayerClutter::moveOrCopyAnimations): 29 (WebCore): 30 (WebCore::GraphicsLayerClutter::setPreserves3D): 31 (WebCore::GraphicsLayerClutter::flushCompositingState): 32 (WebCore::GraphicsLayerClutter::recursiveCommitChanges): 33 (WebCore::GraphicsLayerClutter::commitLayerChangesAfterSublayers): 34 (WebCore::GraphicsLayerClutter::commitLayerChangesBeforeSublayers): 35 (WebCore::GraphicsLayerClutter::updateGeometry): 36 (WebCore::GraphicsLayerClutter::updateSublayerList): 37 (WebCore::GraphicsLayerClutter::updateStructuralLayer): 38 (WebCore::GraphicsLayerClutter::ensureStructuralLayer): 39 (WebCore::GraphicsLayerClutter::structuralLayerPurpose): 40 (WebCore::GraphicsLayerClutter::layerForSuperlayer): 41 * platform/graphics/clutter/GraphicsLayerClutter.h: 42 (CommitState): 43 (WebCore::GraphicsLayerClutter::CommitState::CommitState): 44 (GraphicsLayerClutter): 45 (WebCore::GraphicsLayerClutter::primaryLayer): 46 1 47 2013-04-02 Adam Klein <adamk@chromium.org> 2 48 -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp
r147145 r147443 29 29 #include "PlatformContextCairo.h" 30 30 #include "RefPtrCairo.h" 31 #include "TransformationMatrix.h" 31 32 #include <wtf/text/CString.h> 32 33 … … 45 46 PlatformClutterLayerClient* layerClient; 46 47 47 gboolean drawsContent; 48 bool flatten; 49 bool drawsContent; 48 50 49 51 float scrollX; … … 102 104 103 105 clutter_actor_set_reactive(CLUTTER_ACTOR(self), FALSE); 106 107 self->priv->flatten = true; 104 108 105 109 // Default used by GraphicsLayer. … … 203 207 cogl_matrix_translate(matrix, translateX, translateY, 0); 204 208 205 CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, matrix); 209 CoglMatrix modelViewTransform = TransformationMatrix(); 210 CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, &modelViewTransform); 211 212 if (priv->flatten) 213 modelViewTransform = TransformationMatrix(&modelViewTransform).to2dTransform(); 214 cogl_matrix_multiply(matrix, matrix, &modelViewTransform); 206 215 } 207 216 … … 300 309 { 301 310 GraphicsLayerActor* layer = GRAPHICS_LAYER_ACTOR(g_object_new(GRAPHICS_LAYER_TYPE_ACTOR, 0)); 302 layer->priv->layerType = type; 311 GraphicsLayerActorPrivate* priv = layer->priv; 312 313 priv->layerType = type; 314 if (priv->layerType == GraphicsLayerClutter::LayerTypeTransformLayer) 315 priv->flatten = false; 303 316 304 317 return layer; … … 437 450 } 438 451 452 void graphicsLayerActorRemoveFromSuperLayer(GraphicsLayerActor* layer) 453 { 454 ClutterActor* actor = CLUTTER_ACTOR(layer); 455 ClutterActor* parentActor = clutter_actor_get_parent(actor); 456 if (!parentActor) 457 return; 458 459 clutter_actor_remove_child(parentActor, actor); 460 } 461 439 462 GraphicsLayerClutter::LayerType graphicsLayerActorGetLayerType(GraphicsLayerActor* layer) 440 463 { … … 475 498 } 476 499 477 void graphicsLayerActorSetDrawsContent(GraphicsLayerActor* layer, gbooleandrawsContent)500 void graphicsLayerActorSetDrawsContent(GraphicsLayerActor* layer, bool drawsContent) 478 501 { 479 502 GraphicsLayerActorPrivate* priv = layer->priv; … … 492 515 } 493 516 517 void graphicsLayerActorSetFlatten(GraphicsLayerActor* layer, bool flatten) 518 { 519 GraphicsLayerActorPrivate* priv = layer->priv; 520 if (flatten == priv->flatten) 521 return; 522 523 priv->flatten = flatten; 524 } 525 494 526 WebCore::PlatformClutterAnimation* graphicsLayerActorGetAnimationForKey(GraphicsLayerActor* layer, const String key) 495 527 { -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.h
r147145 r147443 90 90 float graphicsLayerActorGetTranslateY(GraphicsLayerActor*); 91 91 gint graphicsLayerActorGetnChildren(GraphicsLayerActor*); 92 void graphicsLayerActorRemoveFromSuperLayer(GraphicsLayerActor*); 92 93 WebCore::GraphicsLayerClutter::LayerType graphicsLayerActorGetLayerType(GraphicsLayerActor*); 93 94 void graphicsLayerActorSetLayerType(GraphicsLayerActor*, WebCore::GraphicsLayerClutter::LayerType); 95 void graphicsLayerActorReplaceSublayer(GraphicsLayerActor*, ClutterActor*, ClutterActor*); 94 96 void graphicsLayerActorSetSublayers(GraphicsLayerActor*, WebCore::GraphicsLayerActorList&); 95 97 gboolean graphicsLayerActorGetDrawsContent(GraphicsLayerActor*); 96 void graphicsLayerActorSetDrawsContent(GraphicsLayerActor*, gboolean drawsContent); 98 void graphicsLayerActorSetDrawsContent(GraphicsLayerActor*, bool drawsContent); 99 void graphicsLayerActorSetFlatten(GraphicsLayerActor*, bool flatten); 97 100 98 101 WebCore::PlatformClutterAnimation* graphicsLayerActorGetAnimationForKey(GraphicsLayerActor*, const String); -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp
r147145 r147443 41 41 #include "ScaleTransformOperation.h" 42 42 #include "TransformState.h" 43 #include "TransformationMatrix.h" 43 44 #include "TranslateTransformOperation.h" 44 45 #include <limits.h> … … 298 299 g_idle_add(idleDestroy, m_layer.leakRef()); 299 300 } 301 302 if (m_structuralLayer) { 303 graphicsLayerActorSetClient(m_structuralLayer.get(), 0); 304 g_idle_add(idleDestroy, m_structuralLayer.leakRef()); 305 } 300 306 } 301 307 … … 309 315 ClutterActor* GraphicsLayerClutter::platformLayer() const 310 316 { 311 return CLUTTER_ACTOR( m_layer.get());317 return CLUTTER_ACTOR(primaryLayer()); 312 318 } 313 319 … … 387 393 GraphicsLayer::setTransform(t); 388 394 noteLayerPropertyChanged(TransformChanged); 395 } 396 397 void GraphicsLayerClutter::moveOrCopyAnimations(MoveOrCopy operation, GraphicsLayerActor* fromLayer, GraphicsLayerActor* toLayer) 398 { 399 notImplemented(); 400 } 401 402 void GraphicsLayerClutter::setPreserves3D(bool preserves3D) 403 { 404 if (preserves3D == m_preserves3D) 405 return; 406 407 GraphicsLayer::setPreserves3D(preserves3D); 408 noteLayerPropertyChanged(Preserves3DChanged); 389 409 } 390 410 … … 555 575 { 556 576 TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect)); 557 recursiveCommitChanges(state); 558 } 559 560 void GraphicsLayerClutter::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale) 561 { 562 // FIXME: Save the state before sending down to kids and restore it after 563 TransformState localState = state; 564 577 recursiveCommitChanges(CommitState(), state); 578 } 579 580 void GraphicsLayerClutter::recursiveCommitChanges(const CommitState& commitState, const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale) 581 { 565 582 if (appliesPageScale()) { 566 583 pageScaleFactor = this->pageScaleFactor(); … … 580 597 for (size_t i = 0; i < numChildren; ++i) { 581 598 GraphicsLayerClutter* currentChild = static_cast<GraphicsLayerClutter*>(childLayers[i]); 582 currentChild->recursiveCommitChanges( localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);599 currentChild->recursiveCommitChanges(commitState, state, pageScaleFactor, baseRelativePosition, affectedByPageScale); 583 600 } 584 601 … … 599 616 return; 600 617 618 if (m_uncommittedChanges & ChildrenChanged) 619 updateSublayerList(); 620 601 621 m_uncommittedChanges = NoChange; 602 622 } … … 619 639 return; 620 640 641 // Need to handle Preserves3DChanged first, because it affects which layers subsequent properties are applied to 642 if (m_uncommittedChanges & Preserves3DChanged) 643 updateStructuralLayer(); 644 645 if (m_uncommittedChanges & GeometryChanged) 646 updateGeometry(pageScaleFactor, positionRelativeToBase); 647 648 if (m_uncommittedChanges & DrawsContentChanged) 649 updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase); 650 621 651 if (m_uncommittedChanges & NameChanged) 622 652 updateLayerNames(); 623 653 624 if (m_uncommittedChanges & ChildrenChanged)625 updateSublayerList();626 627 if (m_uncommittedChanges & GeometryChanged)628 updateGeometry(pageScaleFactor, positionRelativeToBase);629 630 654 if (m_uncommittedChanges & TransformChanged) 631 655 updateTransform(); 632 656 633 if (m_uncommittedChanges & DrawsContentChanged) 634 updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase); 657 if (m_uncommittedChanges & OpacityChanged) 658 updateOpacityOnLayer(); 659 660 if (m_uncommittedChanges & AnimationChanged) 661 updateAnimations(); 635 662 636 663 if (m_uncommittedChanges & DirtyRectsChanged) 637 664 repaintLayerDirtyRects(); 638 665 639 if (m_uncommittedChanges & OpacityChanged)640 update OpacityOnLayer();641 642 if (m_uncommittedChanges & AnimationChanged)643 updateAnimations();666 if (m_uncommittedChanges & ChildrenChanged) { 667 updateSublayerList(); 668 // Sublayers may set this flag again, so clear it to avoid always updating sublayers in commitLayerChangesAfterSublayers(). 669 m_uncommittedChanges &= ~ChildrenChanged; 670 } 644 671 } 645 672 … … 647 674 { 648 675 // FIXME: Need to support page scaling. 676 if (m_structuralLayer) { 677 clutter_actor_set_position(CLUTTER_ACTOR(m_structuralLayer.get()), m_position.x(), m_position.y()); 678 clutter_actor_set_size(CLUTTER_ACTOR(m_structuralLayer.get()), m_size.width(), m_size.height()); 679 graphicsLayerActorSetAnchorPoint(m_structuralLayer.get(), m_anchorPoint.x(), m_anchorPoint.y(), m_anchorPoint.z()); 680 } 681 649 682 clutter_actor_set_position(CLUTTER_ACTOR(m_layer.get()), m_position.x(), m_position.y()); 650 683 clutter_actor_set_size(CLUTTER_ACTOR(m_layer.get()), m_size.width(), m_size.height()); … … 656 689 void GraphicsLayerClutter::updateSublayerList() 657 690 { 658 GraphicsLayerActorList newSublayers; 691 GraphicsLayerActorList structuralLayerChildren; 692 GraphicsLayerActorList primaryLayerChildren; 693 694 GraphicsLayerActorList& childListForSublayers = m_structuralLayer ? structuralLayerChildren : primaryLayerChildren; 695 696 if (m_structuralLayer) 697 structuralLayerChildren.append(m_layer); 698 659 699 const Vector<GraphicsLayer*>& childLayers = children(); 660 661 700 size_t numChildren = childLayers.size(); 662 701 for (size_t i = 0; i < numChildren; ++i) { … … 664 703 GraphicsLayerActor* childLayer = currentChild->layerForSuperlayer(); 665 704 ASSERT(GRAPHICS_LAYER_IS_ACTOR(childLayer)); 666 667 newSublayers.append(childLayer); 668 } 669 670 graphicsLayerActorSetSublayers(m_layer.get(), newSublayers); 705 childListForSublayers.append(childLayer); 706 707 // The child layer only preserves 3D if either itself or its parent has preserves3D set. 708 graphicsLayerActorSetFlatten(childLayer, !(preserves3D() || currentChild->preserves3D())); 709 } 710 711 if (m_structuralLayer) 712 graphicsLayerActorSetSublayers(m_structuralLayer.get(), structuralLayerChildren); 713 714 graphicsLayerActorSetSublayers(m_layer.get(), primaryLayerChildren); 671 715 } 672 716 … … 680 724 CoglMatrix matrix = m_transform; 681 725 clutter_actor_set_transform(CLUTTER_ACTOR(primaryLayer()), &matrix); 726 } 727 728 void GraphicsLayerClutter::updateStructuralLayer() 729 { 730 ensureStructuralLayer(structuralLayerPurpose()); 731 } 732 733 void GraphicsLayerClutter::ensureStructuralLayer(StructuralLayerPurpose purpose) 734 { 735 const LayerChangeFlags structuralLayerChangeFlags = NameChanged 736 | GeometryChanged 737 | TransformChanged 738 | ChildrenTransformChanged 739 | ChildrenChanged 740 | BackfaceVisibilityChanged 741 | OpacityChanged; 742 743 if (purpose == NoStructuralLayer) { 744 if (m_structuralLayer) { 745 // Replace the transformLayer in the parent with this layer. 746 graphicsLayerActorRemoveFromSuperLayer(m_layer.get()); 747 748 // If m_layer doesn't have a parent, it means it's the root layer and 749 // is likely hosted by something that is not expecting to be changed 750 ClutterActor* parentActor = clutter_actor_get_parent(CLUTTER_ACTOR(m_structuralLayer.get())); 751 ASSERT(parentActor); 752 graphicsLayerActorReplaceSublayer(GRAPHICS_LAYER_ACTOR(parentActor), CLUTTER_ACTOR(m_structuralLayer.get()), CLUTTER_ACTOR(m_layer.get())); 753 754 moveOrCopyAnimations(Move, m_structuralLayer.get(), m_layer.get()); 755 756 // Release the structural layer. 757 m_structuralLayer = 0; 758 759 m_uncommittedChanges |= structuralLayerChangeFlags; 760 } 761 return; 762 } 763 764 bool structuralLayerChanged = false; 765 if (purpose == StructuralLayerForPreserves3D) { 766 if (m_structuralLayer && (graphicsLayerActorGetLayerType(m_structuralLayer.get()) != GraphicsLayerClutter::LayerTypeTransformLayer)) 767 m_structuralLayer = 0; 768 769 if (!m_structuralLayer) { 770 m_structuralLayer = graphicsLayerActorNewWithClient(GraphicsLayerClutter::LayerTypeTransformLayer, this); 771 structuralLayerChanged = true; 772 } 773 } else { 774 if (m_structuralLayer && (graphicsLayerActorGetLayerType(m_structuralLayer.get()) != GraphicsLayerClutter::LayerTypeLayer)) 775 m_structuralLayer = 0; 776 777 if (!m_structuralLayer) { 778 m_structuralLayer = graphicsLayerActorNewWithClient(GraphicsLayerClutter::LayerTypeLayer, this); 779 structuralLayerChanged = true; 780 } 781 } 782 783 if (!structuralLayerChanged) 784 return; 785 786 m_uncommittedChanges |= structuralLayerChangeFlags; 787 788 // We've changed the layer that our parent added to its sublayer list, so tell it to update 789 // sublayers again in its commitLayerChangesAfterSublayers(). 790 static_cast<GraphicsLayerClutter*>(parent())->noteSublayersChanged(); 791 792 // Set properties of m_layer to their default values, since these are expressed on on the structural layer. 793 FloatPoint point(0, 0); 794 FloatPoint3D anchorPoint(0.5f, 0.5f, 0); 795 clutter_actor_set_position(CLUTTER_ACTOR(m_layer.get()), point.x(), point.y()); 796 graphicsLayerActorSetAnchorPoint(m_layer.get(), anchorPoint.x(), anchorPoint.y(), anchorPoint.z()); 797 798 CoglMatrix matrix = TransformationMatrix(); 799 clutter_actor_set_transform(CLUTTER_ACTOR(m_layer.get()), &matrix); 800 801 clutter_actor_set_opacity(CLUTTER_ACTOR(m_layer.get()), 255); 802 803 moveOrCopyAnimations(Move, m_layer.get(), m_structuralLayer.get()); 804 } 805 806 GraphicsLayerClutter::StructuralLayerPurpose GraphicsLayerClutter::structuralLayerPurpose() const 807 { 808 if (preserves3D()) 809 return StructuralLayerForPreserves3D; 810 811 return NoStructuralLayer; 682 812 } 683 813 … … 1100 1230 GraphicsLayerActor* GraphicsLayerClutter::layerForSuperlayer() const 1101 1231 { 1102 return m_ layer.get();1232 return m_structuralLayer ? m_structuralLayer.get() : m_layer.get(); 1103 1233 } 1104 1234 -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h
r146608 r147443 80 80 virtual void setNeedsDisplayInRect(const FloatRect&); 81 81 82 virtual void setPreserves3D(bool); 83 82 84 virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize, const Animation*, const String& animationName, double timeOffset); 83 85 virtual void removeAnimation(const String& animationName); … … 86 88 virtual void flushCompositingStateForThisLayerOnly(); 87 89 88 void recursiveCommitChanges(const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false); 90 struct CommitState { 91 bool ancestorHasTransformAnimation; 92 CommitState() 93 : ancestorHasTransformAnimation(false) 94 { } 95 }; 96 void recursiveCommitChanges(const CommitState&, const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false); 89 97 90 98 private: … … 104 112 virtual void platformClutterLayerPaintContents(GraphicsContext&, const IntRect& clip); 105 113 106 GraphicsLayerActor* primaryLayer() const { return m_ layer.get(); }114 GraphicsLayerActor* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); } 107 115 GraphicsLayerActor* layerForSuperlayer() const; 108 116 GraphicsLayerActor* animatedLayer(AnimatedPropertyID) const; … … 126 134 bool setTransformAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformClutterAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const IntSize& boxSize); 127 135 bool setTransformAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformClutterAnimation*, int functionIndex, TransformOperation::OperationType, bool isMatrixAnimation, const IntSize& boxSize); 136 137 enum MoveOrCopy { Move, Copy }; 138 void moveOrCopyAnimations(MoveOrCopy, GraphicsLayerActor* fromLayer, GraphicsLayerActor* toLayer); 128 139 129 140 bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation); … … 148 159 ContentsMediaLayerChanged = 1 << 16, 149 160 ContentsCanvasLayerChanged = 1 << 17, 150 ContentsRectChanged = 1 << 18, 151 MaskLayerChanged = 1 << 19, 152 ReplicatedLayerChanged = 1 << 20, 153 ContentsNeedsDisplay = 1 << 21, 154 AcceleratesDrawingChanged = 1 << 22, 155 ContentsScaleChanged = 1 << 23 161 ContentsColorLayerChanged = 1 << 18, 162 ContentsRectChanged = 1 << 19, 163 MaskLayerChanged = 1 << 20, 164 ReplicatedLayerChanged = 1 << 21, 165 ContentsNeedsDisplay = 1 << 22, 166 AcceleratesDrawingChanged = 1 << 23, 167 ContentsScaleChanged = 1 << 24, 168 ContentsVisibilityChanged = 1 << 25, 169 VisibleRectChanged = 1 << 26, 170 FiltersChanged = 1 << 27, 171 DebugIndicatorsChanged = 1 << 28 156 172 }; 157 173 … … 161 177 162 178 void updateBackfaceVisibility(); 179 void updateStructuralLayer(); 163 180 void updateLayerNames(); 164 181 void updateSublayerList(); … … 169 186 void updateAnimations(); 170 187 188 enum StructuralLayerPurpose { 189 NoStructuralLayer = 0, 190 StructuralLayerForPreserves3D, 191 StructuralLayerForReplicaFlattening 192 }; 193 void ensureStructuralLayer(StructuralLayerPurpose); 194 StructuralLayerPurpose structuralLayerPurpose() const; 195 171 196 void repaintLayerDirtyRects(); 172 197 173 198 GRefPtr<GraphicsLayerActor> m_layer; 199 GRefPtr<GraphicsLayerActor> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer. 174 200 175 201 Vector<FloatRect> m_dirtyRects;
Note: See TracChangeset
for help on using the changeset viewer.