OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CCLayerTreeHostImpl_h | 5 #ifndef CCLayerTreeHostImpl_h |
6 #define CCLayerTreeHostImpl_h | 6 #define CCLayerTreeHostImpl_h |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void setSentPageScaleDelta(float delta) { m_sentPageScaleDelta = delta; } | 67 void setSentPageScaleDelta(float delta) { m_sentPageScaleDelta = delta; } |
68 float sentPageScaleDelta() const { return m_sentPageScaleDelta; } | 68 float sentPageScaleDelta() const { return m_sentPageScaleDelta; } |
69 | 69 |
70 // Returns true if the passed parameters were different from those previousl
y | 70 // Returns true if the passed parameters were different from those previousl
y |
71 // cached. | 71 // cached. |
72 bool setPageScaleFactorAndLimits(float pageScaleFactor, | 72 bool setPageScaleFactorAndLimits(float pageScaleFactor, |
73 float minPageScaleFactor, | 73 float minPageScaleFactor, |
74 float maxPageScaleFactor); | 74 float maxPageScaleFactor); |
75 | 75 |
76 // Returns the bounds and offset of the scaled and translated viewport to us
e for pinch-zoom. | 76 // Returns the bounds and offset of the scaled and translated viewport to us
e for pinch-zoom. |
77 FloatRect bounds() const; | 77 gfx::RectF bounds() const; |
78 const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; } | 78 const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; } |
79 | 79 |
80 void setLayoutViewportSize(const FloatSize& size) { m_layoutViewportSize = s
ize; } | 80 void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize =
size; } |
81 | 81 |
82 // Apply the scroll offset in layout space to the offset of the pinch-zoom v
iewport. The viewport cannot be | 82 // Apply the scroll offset in layout space to the offset of the pinch-zoom v
iewport. The viewport cannot be |
83 // scrolled outside of the layout viewport bounds. Returns the component of
the scroll that is un-applied due to | 83 // scrolled outside of the layout viewport bounds. Returns the component of
the scroll that is un-applied due to |
84 // this constraint. | 84 // this constraint. |
85 FloatSize applyScroll(FloatSize&); | 85 FloatSize applyScroll(FloatSize&); |
86 | 86 |
87 WebKit::WebTransformationMatrix implTransform() const; | 87 WebKit::WebTransformationMatrix implTransform() const; |
88 | 88 |
89 private: | 89 private: |
90 float m_pageScaleFactor; | 90 float m_pageScaleFactor; |
91 float m_pageScaleDelta; | 91 float m_pageScaleDelta; |
92 float m_sentPageScaleDelta; | 92 float m_sentPageScaleDelta; |
93 float m_maxPageScaleFactor; | 93 float m_maxPageScaleFactor; |
94 float m_minPageScaleFactor; | 94 float m_minPageScaleFactor; |
95 | 95 |
96 FloatPoint m_pinchViewportScrollDelta; | 96 FloatPoint m_pinchViewportScrollDelta; |
97 FloatSize m_layoutViewportSize; | 97 gfx::SizeF m_layoutViewportSize; |
98 }; | 98 }; |
99 | 99 |
100 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 100 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
101 class LayerTreeHostImpl : public InputHandlerClient, | 101 class LayerTreeHostImpl : public InputHandlerClient, |
102 public RendererClient, | 102 public RendererClient, |
103 public WebKit::WebCompositorOutputSurfaceClient { | 103 public WebKit::WebCompositorOutputSurfaceClient { |
104 typedef std::vector<LayerImpl*> LayerList; | 104 typedef std::vector<LayerImpl*> LayerList; |
105 | 105 |
106 public: | 106 public: |
107 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*); | 107 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Returns false if problems occured preparing the frame, and we should try | 139 // Returns false if problems occured preparing the frame, and we should try |
140 // to avoid displaying the frame. If prepareToDraw is called, | 140 // to avoid displaying the frame. If prepareToDraw is called, |
141 // didDrawAllLayers must also be called, regardless of whether drawLayers is | 141 // didDrawAllLayers must also be called, regardless of whether drawLayers is |
142 // called between the two. | 142 // called between the two. |
143 virtual bool prepareToDraw(FrameData&); | 143 virtual bool prepareToDraw(FrameData&); |
144 virtual void drawLayers(const FrameData&); | 144 virtual void drawLayers(const FrameData&); |
145 // Must be called if and only if prepareToDraw was called. | 145 // Must be called if and only if prepareToDraw was called. |
146 void didDrawAllLayers(const FrameData&); | 146 void didDrawAllLayers(const FrameData&); |
147 | 147 |
148 // RendererClient implementation | 148 // RendererClient implementation |
149 virtual const IntSize& deviceViewportSize() const OVERRIDE; | 149 virtual const gfx::Size& deviceViewportSize() const OVERRIDE; |
150 virtual const LayerTreeSettings& settings() const OVERRIDE; | 150 virtual const LayerTreeSettings& settings() const OVERRIDE; |
151 virtual void didLoseContext() OVERRIDE; | 151 virtual void didLoseContext() OVERRIDE; |
152 virtual void onSwapBuffersComplete() OVERRIDE; | 152 virtual void onSwapBuffersComplete() OVERRIDE; |
153 virtual void setFullRootLayerDamage() OVERRIDE; | 153 virtual void setFullRootLayerDamage() OVERRIDE; |
154 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE; | 154 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE; |
155 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE; | 155 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE; |
156 | 156 |
157 // WebCompositorOutputSurfaceClient implementation. | 157 // WebCompositorOutputSurfaceClient implementation. |
158 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; | 158 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; |
159 | 159 |
160 // Implementation | 160 // Implementation |
161 bool canDraw(); | 161 bool canDraw(); |
162 GraphicsContext* context() const; | 162 GraphicsContext* context() const; |
163 | 163 |
164 std::string layerTreeAsText() const; | 164 std::string layerTreeAsText() const; |
165 | 165 |
166 void finishAllRendering(); | 166 void finishAllRendering(); |
167 int sourceAnimationFrameNumber() const; | 167 int sourceAnimationFrameNumber() const; |
168 | 168 |
169 bool initializeRenderer(scoped_ptr<GraphicsContext>); | 169 bool initializeRenderer(scoped_ptr<GraphicsContext>); |
170 bool isContextLost(); | 170 bool isContextLost(); |
171 Renderer* renderer() { return m_renderer.get(); } | 171 Renderer* renderer() { return m_renderer.get(); } |
172 const RendererCapabilities& rendererCapabilities() const; | 172 const RendererCapabilities& rendererCapabilities() const; |
173 | 173 |
174 bool swapBuffers(); | 174 bool swapBuffers(); |
175 | 175 |
176 void readback(void* pixels, const IntRect&); | 176 void readback(void* pixels, const gfx::Rect&); |
177 | 177 |
178 void setRootLayer(scoped_ptr<LayerImpl>); | 178 void setRootLayer(scoped_ptr<LayerImpl>); |
179 LayerImpl* rootLayer() { return m_rootLayerImpl.get(); } | 179 LayerImpl* rootLayer() { return m_rootLayerImpl.get(); } |
180 | 180 |
181 void setHudLayer(HeadsUpDisplayLayerImpl* layerImpl) { m_hudLayerImpl = laye
rImpl; } | 181 void setHudLayer(HeadsUpDisplayLayerImpl* layerImpl) { m_hudLayerImpl = laye
rImpl; } |
182 HeadsUpDisplayLayerImpl* hudLayer() { return m_hudLayerImpl; } | 182 HeadsUpDisplayLayerImpl* hudLayer() { return m_hudLayerImpl; } |
183 | 183 |
184 // Release ownership of the current layer tree and replace it with an empty | 184 // Release ownership of the current layer tree and replace it with an empty |
185 // tree. Returns the root layer of the detached tree. | 185 // tree. Returns the root layer of the detached tree. |
186 scoped_ptr<LayerImpl> detachLayerTree(); | 186 scoped_ptr<LayerImpl> detachLayerTree(); |
187 | 187 |
188 LayerImpl* rootScrollLayer() const { return m_rootScrollLayerImpl; } | 188 LayerImpl* rootScrollLayer() const { return m_rootScrollLayerImpl; } |
189 | 189 |
190 bool visible() const { return m_visible; } | 190 bool visible() const { return m_visible; } |
191 void setVisible(bool); | 191 void setVisible(bool); |
192 | 192 |
193 int sourceFrameNumber() const { return m_sourceFrameNumber; } | 193 int sourceFrameNumber() const { return m_sourceFrameNumber; } |
194 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumb
er; } | 194 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumb
er; } |
195 | 195 |
196 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } | 196 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } |
197 void setContentsTexturesPurged(); | 197 void setContentsTexturesPurged(); |
198 void resetContentsTexturesPurged(); | 198 void resetContentsTexturesPurged(); |
199 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } | 199 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } |
200 | 200 |
201 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic
eViewportSize); | 201 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d
eviceViewportSize); |
202 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; } | 202 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } |
203 | 203 |
204 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 204 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
205 void setDeviceScaleFactor(float); | 205 void setDeviceScaleFactor(float); |
206 | 206 |
207 float pageScaleFactor() const; | 207 float pageScaleFactor() const; |
208 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); | 208 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); |
209 | 209 |
210 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); | 210 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
211 WebKit::WebTransformationMatrix implTransform() const; | 211 WebKit::WebTransformationMatrix implTransform() const; |
212 | 212 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 void setPageScaleDelta(float); | 287 void setPageScaleDelta(float); |
288 void updateMaxScrollPosition(); | 288 void updateMaxScrollPosition(); |
289 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); | 289 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); |
290 | 290 |
291 // Returns false if the frame should not be displayed. This function should | 291 // Returns false if the frame should not be displayed. This function should |
292 // only be called from prepareToDraw, as didDrawAllLayers must be called | 292 // only be called from prepareToDraw, as didDrawAllLayers must be called |
293 // if this helper function is called. | 293 // if this helper function is called. |
294 bool calculateRenderPasses(FrameData&); | 294 bool calculateRenderPasses(FrameData&); |
295 void animateLayersRecursive(LayerImpl*, double monotonicTime, double wallClo
ckTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimateLayers); | 295 void animateLayersRecursive(LayerImpl*, double monotonicTime, double wallClo
ckTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimateLayers); |
296 void setBackgroundTickingEnabled(bool); | 296 void setBackgroundTickingEnabled(bool); |
297 IntSize contentSize() const; | 297 gfx::Size contentSize() const; |
298 | 298 |
299 void sendDidLoseContextRecursive(LayerImpl*); | 299 void sendDidLoseContextRecursive(LayerImpl*); |
300 void clearRenderSurfaces(); | 300 void clearRenderSurfaces(); |
301 bool ensureRenderSurfaceLayerList(); | 301 bool ensureRenderSurfaceLayerList(); |
302 void clearCurrentlyScrollingLayer(); | 302 void clearCurrentlyScrollingLayer(); |
303 | 303 |
304 void animateScrollbarsRecursive(LayerImpl*, double monotonicTime); | 304 void animateScrollbarsRecursive(LayerImpl*, double monotonicTime); |
305 | 305 |
306 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 306 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
307 | 307 |
308 scoped_ptr<GraphicsContext> m_context; | 308 scoped_ptr<GraphicsContext> m_context; |
309 scoped_ptr<ResourceProvider> m_resourceProvider; | 309 scoped_ptr<ResourceProvider> m_resourceProvider; |
310 scoped_ptr<Renderer> m_renderer; | 310 scoped_ptr<Renderer> m_renderer; |
311 scoped_ptr<LayerImpl> m_rootLayerImpl; | 311 scoped_ptr<LayerImpl> m_rootLayerImpl; |
312 LayerImpl* m_rootScrollLayerImpl; | 312 LayerImpl* m_rootScrollLayerImpl; |
313 LayerImpl* m_currentlyScrollingLayerImpl; | 313 LayerImpl* m_currentlyScrollingLayerImpl; |
314 HeadsUpDisplayLayerImpl* m_hudLayerImpl; | 314 HeadsUpDisplayLayerImpl* m_hudLayerImpl; |
315 int m_scrollingLayerIdFromPreviousTree; | 315 int m_scrollingLayerIdFromPreviousTree; |
316 bool m_scrollDeltaIsInViewportSpace; | 316 bool m_scrollDeltaIsInViewportSpace; |
317 LayerTreeSettings m_settings; | 317 LayerTreeSettings m_settings; |
318 IntSize m_layoutViewportSize; | 318 gfx::Size m_layoutViewportSize; |
319 IntSize m_deviceViewportSize; | 319 gfx::Size m_deviceViewportSize; |
320 float m_deviceScaleFactor; | 320 float m_deviceScaleFactor; |
321 bool m_visible; | 321 bool m_visible; |
322 bool m_contentsTexturesPurged; | 322 bool m_contentsTexturesPurged; |
323 ManagedMemoryPolicy m_managedMemoryPolicy; | 323 ManagedMemoryPolicy m_managedMemoryPolicy; |
324 | 324 |
325 SkColor m_backgroundColor; | 325 SkColor m_backgroundColor; |
326 bool m_hasTransparentBackground; | 326 bool m_hasTransparentBackground; |
327 | 327 |
328 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 328 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
329 bool m_needsAnimateLayers; | 329 bool m_needsAnimateLayers; |
(...skipping 18 matching lines...) Expand all Loading... |
348 | 348 |
349 size_t m_numImplThreadScrolls; | 349 size_t m_numImplThreadScrolls; |
350 size_t m_numMainThreadScrolls; | 350 size_t m_numMainThreadScrolls; |
351 | 351 |
352 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 352 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
353 }; | 353 }; |
354 | 354 |
355 } // namespace cc | 355 } // namespace cc |
356 | 356 |
357 #endif | 357 #endif |
OLD | NEW |