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 CC_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_LAYER_TREE_HOST_IMPL_H_ |
6 #define CC_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_LAYER_TREE_HOST_IMPL_H_ |
7 | 7 |
8 #include "FloatPoint.h" | |
9 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
11 #include "base/time.h" | 10 #include "base/time.h" |
12 #include "cc/animation_events.h" | 11 #include "cc/animation_events.h" |
13 #include "cc/cc_export.h" | 12 #include "cc/cc_export.h" |
14 #include "cc/input_handler.h" | 13 #include "cc/input_handler.h" |
15 #include "cc/layer_sorter.h" | 14 #include "cc/layer_sorter.h" |
16 #include "cc/render_pass.h" | 15 #include "cc/render_pass.h" |
17 #include "cc/render_pass_sink.h" | 16 #include "cc/render_pass_sink.h" |
18 #include "cc/renderer.h" | 17 #include "cc/renderer.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 float sentPageScaleDelta() const { return m_sentPageScaleDelta; } | 70 float sentPageScaleDelta() const { return m_sentPageScaleDelta; } |
72 | 71 |
73 // Returns true if the passed parameters were different from those previousl
y | 72 // Returns true if the passed parameters were different from those previousl
y |
74 // cached. | 73 // cached. |
75 bool setPageScaleFactorAndLimits(float pageScaleFactor, | 74 bool setPageScaleFactorAndLimits(float pageScaleFactor, |
76 float minPageScaleFactor, | 75 float minPageScaleFactor, |
77 float maxPageScaleFactor); | 76 float maxPageScaleFactor); |
78 | 77 |
79 // Returns the bounds and offset of the scaled and translated viewport to us
e for pinch-zoom. | 78 // Returns the bounds and offset of the scaled and translated viewport to us
e for pinch-zoom. |
80 gfx::RectF bounds() const; | 79 gfx::RectF bounds() const; |
81 const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; } | 80 const gfx::Vector2dF& scrollDelta() const { return m_pinchViewportScrollDelt
a; } |
82 | 81 |
83 void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize =
size; } | 82 void setLayoutViewportSize(const gfx::SizeF& size) { m_layoutViewportSize =
size; } |
84 | 83 |
85 // Apply the scroll offset in layout space to the offset of the pinch-zoom v
iewport. The viewport cannot be | 84 // Apply the scroll offset in layout space to the offset of the pinch-zoom v
iewport. The viewport cannot be |
86 // scrolled outside of the layout viewport bounds. Returns the component of
the scroll that is un-applied due to | 85 // scrolled outside of the layout viewport bounds. Returns the component of
the scroll that is un-applied due to |
87 // this constraint. | 86 // this constraint. |
88 FloatSize applyScroll(const gfx::Vector2dF&); | 87 gfx::Vector2dF applyScroll(const gfx::Vector2dF&); |
89 | 88 |
90 WebKit::WebTransformationMatrix implTransform() const; | 89 WebKit::WebTransformationMatrix implTransform() const; |
91 | 90 |
92 private: | 91 private: |
93 float m_pageScaleFactor; | 92 float m_pageScaleFactor; |
94 float m_pageScaleDelta; | 93 float m_pageScaleDelta; |
95 float m_sentPageScaleDelta; | 94 float m_sentPageScaleDelta; |
96 float m_maxPageScaleFactor; | 95 float m_maxPageScaleFactor; |
97 float m_minPageScaleFactor; | 96 float m_minPageScaleFactor; |
98 | 97 |
99 FloatPoint m_pinchViewportScrollDelta; | 98 gfx::Vector2dF m_pinchViewportScrollDelta; |
100 gfx::SizeF m_layoutViewportSize; | 99 gfx::SizeF m_layoutViewportSize; |
101 }; | 100 }; |
102 | 101 |
103 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 102 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
104 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, | 103 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
105 public RendererClient, | 104 public RendererClient, |
106 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { | 105 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { |
107 typedef std::vector<LayerImpl*> LayerList; | 106 typedef std::vector<LayerImpl*> LayerList; |
108 | 107 |
109 public: | 108 public: |
110 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*); | 109 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*); |
111 virtual ~LayerTreeHostImpl(); | 110 virtual ~LayerTreeHostImpl(); |
112 | 111 |
113 // InputHandlerClient implementation | 112 // InputHandlerClient implementation |
114 virtual InputHandlerClient::ScrollStatus scrollBegin(const gfx::Point&, Inpu
tHandlerClient::ScrollInputType) OVERRIDE; | 113 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
115 virtual void scrollBy(const gfx::Point&, const IntSize&) OVERRIDE; | 114 virtual void scrollBy(gfx::Point, gfx::Vector2d) OVERRIDE; |
116 virtual void scrollEnd() OVERRIDE; | 115 virtual void scrollEnd() OVERRIDE; |
117 virtual void pinchGestureBegin() OVERRIDE; | 116 virtual void pinchGestureBegin() OVERRIDE; |
118 virtual void pinchGestureUpdate(float, const IntPoint&) OVERRIDE; | 117 virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE; |
119 virtual void pinchGestureEnd() OVERRIDE; | 118 virtual void pinchGestureEnd() OVERRIDE; |
120 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool anc
horPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration)
OVERRIDE; | 119 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchor
Point, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVE
RRIDE; |
121 virtual void scheduleAnimation() OVERRIDE; | 120 virtual void scheduleAnimation() OVERRIDE; |
122 | 121 |
123 struct CC_EXPORT FrameData : public RenderPassSink { | 122 struct CC_EXPORT FrameData : public RenderPassSink { |
124 FrameData(); | 123 FrameData(); |
125 ~FrameData(); | 124 ~FrameData(); |
126 | 125 |
127 std::vector<gfx::Rect> occludingScreenSpaceRects; | 126 std::vector<gfx::Rect> occludingScreenSpaceRects; |
128 RenderPassList renderPasses; | 127 RenderPassList renderPasses; |
129 RenderPassIdHashMap renderPassesById; | 128 RenderPassIdHashMap renderPassesById; |
130 LayerList* renderSurfaceLayerList; | 129 LayerList* renderSurfaceLayerList; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 205 |
207 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 206 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
208 void setDeviceScaleFactor(float); | 207 void setDeviceScaleFactor(float); |
209 | 208 |
210 float pageScaleFactor() const; | 209 float pageScaleFactor() const; |
211 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); | 210 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); |
212 | 211 |
213 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); | 212 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
214 WebKit::WebTransformationMatrix implTransform() const; | 213 WebKit::WebTransformationMatrix implTransform() const; |
215 | 214 |
216 void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor,
float scale, base::TimeDelta duration); | 215 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); |
217 | 216 |
218 SkColor backgroundColor() const { return m_backgroundColor; } | 217 SkColor backgroundColor() const { return m_backgroundColor; } |
219 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } | 218 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } |
220 | 219 |
221 bool hasTransparentBackground() const { return m_hasTransparentBackground; } | 220 bool hasTransparentBackground() const { return m_hasTransparentBackground; } |
222 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } | 221 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } |
223 | 222 |
224 bool needsAnimateLayers() const { return m_needsAnimateLayers; } | 223 bool needsAnimateLayers() const { return m_needsAnimateLayers; } |
225 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } | 224 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } |
226 | 225 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 277 |
279 // Virtual for testing. | 278 // Virtual for testing. |
280 virtual base::TimeDelta lowFrequencyAnimationInterval() const; | 279 virtual base::TimeDelta lowFrequencyAnimationInterval() const; |
281 | 280 |
282 LayerTreeHostImplClient* m_client; | 281 LayerTreeHostImplClient* m_client; |
283 int m_sourceFrameNumber; | 282 int m_sourceFrameNumber; |
284 | 283 |
285 private: | 284 private: |
286 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); | 285 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); |
287 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); | 286 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); |
288 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, const IntSize& scr
ollOffset, float pageScale); | 287 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro
llOffset, float pageScale); |
289 | 288 |
290 void setPageScaleDelta(float); | 289 void setPageScaleDelta(float); |
291 void updateMaxScrollPosition(); | 290 void updateMaxScrollOffset(); |
292 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); | 291 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); |
293 | 292 |
294 // Returns false if the frame should not be displayed. This function should | 293 // Returns false if the frame should not be displayed. This function should |
295 // only be called from prepareToDraw, as didDrawAllLayers must be called | 294 // only be called from prepareToDraw, as didDrawAllLayers must be called |
296 // if this helper function is called. | 295 // if this helper function is called. |
297 bool calculateRenderPasses(FrameData&); | 296 bool calculateRenderPasses(FrameData&); |
298 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base:
:Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat
eLayers); | 297 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base:
:Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat
eLayers); |
299 void setBackgroundTickingEnabled(bool); | 298 void setBackgroundTickingEnabled(bool); |
300 gfx::Size contentSize() const; | 299 gfx::Size contentSize() const; |
301 | 300 |
(...skipping 22 matching lines...) Expand all Loading... |
324 bool m_visible; | 323 bool m_visible; |
325 bool m_contentsTexturesPurged; | 324 bool m_contentsTexturesPurged; |
326 ManagedMemoryPolicy m_managedMemoryPolicy; | 325 ManagedMemoryPolicy m_managedMemoryPolicy; |
327 | 326 |
328 SkColor m_backgroundColor; | 327 SkColor m_backgroundColor; |
329 bool m_hasTransparentBackground; | 328 bool m_hasTransparentBackground; |
330 | 329 |
331 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 330 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
332 bool m_needsAnimateLayers; | 331 bool m_needsAnimateLayers; |
333 bool m_pinchGestureActive; | 332 bool m_pinchGestureActive; |
334 IntPoint m_previousPinchAnchor; | 333 gfx::Point m_previousPinchAnchor; |
335 | 334 |
336 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 335 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
337 | 336 |
338 // This is used for ticking animations slowly when hidden. | 337 // This is used for ticking animations slowly when hidden. |
339 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 338 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
340 | 339 |
341 LayerSorter m_layerSorter; | 340 LayerSorter m_layerSorter; |
342 | 341 |
343 // List of visible layers for the most recently prepared frame. Used for | 342 // List of visible layers for the most recently prepared frame. Used for |
344 // rendering and input event hit testing. | 343 // rendering and input event hit testing. |
345 LayerList m_renderSurfaceLayerList; | 344 LayerList m_renderSurfaceLayerList; |
346 | 345 |
347 PinchZoomViewport m_pinchZoomViewport; | 346 PinchZoomViewport m_pinchZoomViewport; |
348 | 347 |
349 scoped_ptr<FrameRateCounter> m_fpsCounter; | 348 scoped_ptr<FrameRateCounter> m_fpsCounter; |
350 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 349 scoped_ptr<DebugRectHistory> m_debugRectHistory; |
351 | 350 |
352 size_t m_numImplThreadScrolls; | 351 size_t m_numImplThreadScrolls; |
353 size_t m_numMainThreadScrolls; | 352 size_t m_numMainThreadScrolls; |
354 | 353 |
355 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 354 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
356 }; | 355 }; |
357 | 356 |
358 } // namespace cc | 357 } // namespace cc |
359 | 358 |
360 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 359 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |