2 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
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.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef GraphicsLayerTextureMapper_h
21 #define GraphicsLayerTextureMapper_h
23 #include "GraphicsLayer.h"
24 #include "GraphicsLayerClient.h"
26 #include "TextureMapperLayer.h"
27 #include "TextureMapperTiledBackingStore.h"
32 class GraphicsLayerTextureMapper : public GraphicsLayer {
34 explicit GraphicsLayerTextureMapper(GraphicsLayerClient*);
35 virtual ~GraphicsLayerTextureMapper();
37 void setScrollClient(TextureMapperLayer::ScrollingClient* client) { m_layer->setScrollClient(client); }
38 void setID(uint32_t id) { m_layer->setID(id); }
40 // reimps from GraphicsLayer.h
41 virtual void setNeedsDisplay();
42 virtual void setContentsNeedsDisplay();
43 virtual void setNeedsDisplayInRect(const FloatRect&);
44 virtual bool setChildren(const Vector<GraphicsLayer*>&);
45 virtual void addChild(GraphicsLayer*);
46 virtual void addChildAtIndex(GraphicsLayer*, int index);
47 virtual void addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling);
48 virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
49 virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
50 virtual void setMaskLayer(GraphicsLayer* layer);
51 virtual void setPosition(const FloatPoint& p);
52 virtual void setAnchorPoint(const FloatPoint3D& p);
53 virtual void setSize(const FloatSize& size);
54 virtual void setTransform(const TransformationMatrix& t);
55 virtual void setChildrenTransform(const TransformationMatrix& t);
56 virtual void setPreserves3D(bool b);
57 virtual void setMasksToBounds(bool b);
58 virtual void setDrawsContent(bool b);
59 virtual void setContentsVisible(bool);
60 virtual void setContentsOpaque(bool b);
61 virtual void setBackfaceVisibility(bool b);
62 virtual void setOpacity(float opacity);
63 virtual void setContentsRect(const IntRect& r);
64 virtual void setReplicatedByLayer(GraphicsLayer*);
65 virtual void setContentsToImage(Image*);
66 virtual void setContentsToSolidColor(const Color&);
67 Color solidColor() const { return m_solidColor; }
68 virtual void setContentsToMedia(PlatformLayer*);
69 virtual void setContentsToCanvas(PlatformLayer* canvas) { setContentsToMedia(canvas); }
70 virtual void setShowDebugBorder(bool) OVERRIDE;
71 virtual void setDebugBorder(const Color&, float width) OVERRIDE;
72 virtual void setShowRepaintCounter(bool) OVERRIDE;
73 virtual void flushCompositingState(const FloatRect&);
74 virtual void flushCompositingStateForThisLayerOnly();
75 virtual void setName(const String& name);
76 virtual PlatformLayer* platformLayer() const { return m_contentsLayer; }
78 inline int changeMask() const { return m_changeMask; }
80 virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double);
81 virtual void pauseAnimation(const String&, double);
82 virtual void removeAnimation(const String&);
83 void setAnimations(const GraphicsLayerAnimations&);
85 TextureMapperLayer* layer() const { return m_layer.get(); }
87 void didCommitScrollOffset(const IntSize&);
88 void setIsScrollable(bool);
89 bool isScrollable() const { return m_isScrollable; }
91 #if ENABLE(CSS_FILTERS)
92 virtual bool setFilters(const FilterOperations&);
95 // FIXME: It will be removed after removing dependency of CoordinatedGraphicsScene on GraphicsLayerTextureMapper.
96 void setHasOwnBackingStore(bool b) { m_hasOwnBackingStore = b; }
97 void setBackingStore(PassRefPtr<TextureMapperBackingStore>);
99 void setFixedToViewport(bool);
100 bool fixedToViewport() const { return m_fixedToViewport; }
102 Color debugBorderColor() const { return m_debugBorderColor; }
103 float debugBorderWidth() const { return m_debugBorderWidth; }
104 void setRepaintCount(int);
107 virtual void willBeDestroyed();
109 void commitLayerChanges();
110 void updateDebugBorderAndRepaintCount();
111 void updateBackingStoreIfNeeded();
112 void prepareBackingStoreIfNeeded();
113 bool shouldHaveBackingStore() const;
115 // This set of flags help us defer which properties of the layer have been
116 // modified by the compositor, so we can know what to look for in the next flush.
120 ChildrenChange = (1L << 1),
121 MaskLayerChange = (1L << 2),
122 ReplicaLayerChange = (1L << 3),
124 ContentChange = (1L << 4),
125 ContentsRectChange = (1L << 5),
126 ContentsVisibleChange = (1L << 6),
127 ContentsOpaqueChange = (1L << 7),
129 PositionChange = (1L << 8),
130 AnchorPointChange = (1L << 9),
131 SizeChange = (1L << 10),
132 TransformChange = (1L << 11),
133 ChildrenTransformChange = (1L << 12),
134 Preserves3DChange = (1L << 13),
136 MasksToBoundsChange = (1L << 14),
137 DrawsContentChange = (1L << 15),
138 OpacityChange = (1L << 16),
139 BackfaceVisibilityChange = (1L << 17),
141 BackingStoreChange = (1L << 18),
142 DisplayChange = (1L << 19),
143 ContentsDisplayChange = (1L << 20),
144 BackgroundColorChange = (1L << 21),
146 AnimationChange = (1L << 22),
147 FilterChange = (1L << 23),
149 DebugVisualsChange = (1L << 24),
150 RepaintCountChange = (1L << 25),
152 FixedToViewporChange = (1L << 26),
153 AnimationStarted = (1L << 27),
155 CommittedScrollOffsetChange = (1L << 28),
156 IsScrollableChange = (1L << 29)
158 void notifyChange(ChangeMask);
160 OwnPtr<TextureMapperLayer> m_layer;
161 RefPtr<TextureMapperTiledBackingStore> m_compositedImage;
162 NativeImagePtr m_compositedNativeImagePtr;
163 RefPtr<TextureMapperBackingStore> m_backingStore;
167 bool m_hasOwnBackingStore;
168 bool m_fixedToViewport;
171 Color m_debugBorderColor;
172 float m_debugBorderWidth;
174 TextureMapperPlatformLayer* m_contentsLayer;
175 FloatRect m_needsDisplayRect;
176 GraphicsLayerAnimations m_animations;
177 double m_animationStartTime;
179 IntSize m_committedScrollOffset;
183 inline static GraphicsLayerTextureMapper* toGraphicsLayerTextureMapper(GraphicsLayer* layer)
185 return static_cast<GraphicsLayerTextureMapper*>(layer);
188 TextureMapperLayer* toTextureMapperLayer(GraphicsLayer*);
191 #endif // GraphicsLayerTextureMapper_h