GraphicsLayerAcagi.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
  3. Copyright (C) 2014 Sony Computer Entertainment Inc.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef GraphicsLayerAcagi_h
  18. #define GraphicsLayerAcagi_h
  19. #if USE(ACCELERATED_COMPOSITING) && USE(ACAGI)
  20. #include "AcagiLayer.h"
  21. #include "AcagiTiledBackingStore.h"
  22. #include "GraphicsLayer.h"
  23. #include "GraphicsLayerClient.h"
  24. #include "Image.h"
  25. #include "PlatformLayerAcagi.h"
  26. #include "Timer.h"
  27. namespace WebCore {
  28. class GraphicsLayerAcagi : public GraphicsLayer, public PlatformLayerAcagi::Client {
  29. public:
  30. explicit GraphicsLayerAcagi(GraphicsLayerClient*);
  31. virtual ~GraphicsLayerAcagi();
  32. void setScrollClient(AcagiLayer::ScrollingClient* client) { m_layer->setScrollClient(client); }
  33. void setID(uint32_t id) { m_layer->setID(id); }
  34. // reimps from GraphicsLayer.h
  35. virtual void setNeedsDisplay();
  36. virtual void setContentsNeedsDisplay();
  37. virtual void setNeedsDisplayInRect(const FloatRect&);
  38. virtual bool setChildren(const Vector<GraphicsLayer*>&);
  39. virtual void addChild(GraphicsLayer*);
  40. virtual void addChildAtIndex(GraphicsLayer*, int index);
  41. virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
  42. virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
  43. virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
  44. virtual void setMaskLayer(GraphicsLayer*);
  45. virtual void setPosition(const FloatPoint&);
  46. virtual void setAnchorPoint(const FloatPoint3D&);
  47. virtual void setSize(const FloatSize&);
  48. virtual void setTransform(const TransformationMatrix&);
  49. virtual void setChildrenTransform(const TransformationMatrix&);
  50. virtual void setPreserves3D(bool);
  51. virtual void setMasksToBounds(bool);
  52. virtual void setDrawsContent(bool);
  53. virtual void setContentsVisible(bool);
  54. virtual void setContentsOpaque(bool);
  55. virtual void setBackfaceVisibility(bool);
  56. virtual void setOpacity(float);
  57. virtual void setContentsRect(const IntRect&);
  58. virtual void setReplicatedByLayer(GraphicsLayer*);
  59. virtual void setContentsToImage(Image*);
  60. virtual void setContentsToSolidColor(const Color&);
  61. Color solidColor() const { return m_solidColor; }
  62. virtual void setContentsToMedia(PlatformLayer*);
  63. virtual void setContentsToCanvas(PlatformLayer* canvas) { setContentsToMedia(canvas); }
  64. virtual void setShowDebugBorder(bool) OVERRIDE;
  65. virtual void setDebugBorder(const Color&, float width) OVERRIDE;
  66. virtual void setShowRepaintCounter(bool) OVERRIDE;
  67. virtual void flushCompositingState(const FloatRect&);
  68. virtual void flushCompositingStateForThisLayerOnly();
  69. virtual void setName(const String&);
  70. virtual PlatformLayer* platformLayer() const { return m_contentsLayer; }
  71. inline int changeMask() const { return m_changeMask; }
  72. virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double);
  73. virtual void pauseAnimation(const String&, double);
  74. virtual void removeAnimation(const String&);
  75. void setAnimations(const GraphicsLayerAnimations&);
  76. AcagiLayer* layer() const { return m_layer.get(); }
  77. void didCommitScrollOffset(const IntSize&);
  78. void setIsScrollable(bool);
  79. bool isScrollable() const { return m_isScrollable; }
  80. void setFixedToViewport(bool);
  81. bool fixedToViewport() const { return m_fixedToViewport; }
  82. Color debugBorderColor() const { return m_debugBorderColor; }
  83. float debugBorderWidth() const { return m_debugBorderWidth; }
  84. void setRepaintCount(int);
  85. void setActualVisibleRect(const IntRect& actualVisibleRect) { m_actualVisibleRect = actualVisibleRect; }
  86. private:
  87. virtual void willBeDestroyed();
  88. void commitLayerChanges();
  89. void updateDebugBorderAndRepaintCount();
  90. void updateBackingStoreIfNeeded();
  91. void prepareBackingStoreIfNeeded();
  92. bool shouldHaveBackingStore() const;
  93. virtual void setPlatformLayerNeedsDisplay() OVERRIDE { setContentsNeedsDisplay(); }
  94. // This set of flags help us defer which properties of the layer have been
  95. // modified by the compositor, so we can know what to look for in the next flush.
  96. enum ChangeMask {
  97. NoChanges = 0,
  98. ChildrenChange = (1L << 1),
  99. MaskLayerChange = (1L << 2),
  100. ReplicaLayerChange = (1L << 3),
  101. ContentChange = (1L << 4),
  102. ContentsRectChange = (1L << 5),
  103. ContentsVisibleChange = (1L << 6),
  104. ContentsOpaqueChange = (1L << 7),
  105. PositionChange = (1L << 8),
  106. AnchorPointChange = (1L << 9),
  107. SizeChange = (1L << 10),
  108. TransformChange = (1L << 11),
  109. ChildrenTransformChange = (1L << 12),
  110. Preserves3DChange = (1L << 13),
  111. MasksToBoundsChange = (1L << 14),
  112. DrawsContentChange = (1L << 15),
  113. OpacityChange = (1L << 16),
  114. BackfaceVisibilityChange = (1L << 17),
  115. BackingStoreChange = (1L << 18),
  116. DisplayChange = (1L << 19),
  117. ContentsDisplayChange = (1L << 20),
  118. BackgroundColorChange = (1L << 21),
  119. AnimationChange = (1L << 22),
  120. FilterChange = (1L << 23),
  121. DebugVisualsChange = (1L << 24),
  122. RepaintCountChange = (1L << 25),
  123. FixedToViewporChange = (1L << 26),
  124. AnimationStarted = (1L << 27),
  125. CommittedScrollOffsetChange = (1L << 28),
  126. IsScrollableChange = (1L << 29)
  127. };
  128. void notifyChange(ChangeMask);
  129. OwnPtr<AcagiLayer> m_layer;
  130. RefPtr<AcagiTiledBackingStore> m_compositedImage;
  131. NativeImagePtr m_compositedNativeImagePtr;
  132. RefPtr<AcagiBackingStore> m_backingStore;
  133. int m_changeMask;
  134. bool m_needsDisplay;
  135. bool m_hasOwnBackingStore;
  136. bool m_fixedToViewport;
  137. Color m_solidColor;
  138. Color m_debugBorderColor;
  139. float m_debugBorderWidth;
  140. PlatformLayerAcagi* m_contentsLayer;
  141. FloatRect m_needsDisplayRect;
  142. FloatRect m_actualVisibleRect;
  143. GraphicsLayerAnimations m_animations;
  144. double m_animationStartTime;
  145. IntSize m_committedScrollOffset;
  146. bool m_isScrollable;
  147. };
  148. inline static GraphicsLayerAcagi* toGraphicsLayerAcagi(GraphicsLayer* layer)
  149. {
  150. return static_cast<GraphicsLayerAcagi*>(layer);
  151. }
  152. AcagiLayer* toAcagiLayer(GraphicsLayer*);
  153. }
  154. #endif // USE(ACCELERATED_COMPOSITING) && USE(ACAGI)
  155. #endif // GraphicsLayerAcagi_h