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/time.h" | 9 #include "base/time.h" |
10 #include "CCAnimationEvents.h" | 10 #include "CCAnimationEvents.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 virtual void didLoseContextOnImplThread() = 0; | 38 virtual void didLoseContextOnImplThread() = 0; |
39 virtual void onSwapBuffersCompleteOnImplThread() = 0; | 39 virtual void onSwapBuffersCompleteOnImplThread() = 0; |
40 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) = 0; | 40 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) = 0; |
41 virtual void onCanDrawStateChanged(bool canDraw) = 0; | 41 virtual void onCanDrawStateChanged(bool canDraw) = 0; |
42 virtual void setNeedsRedrawOnImplThread() = 0; | 42 virtual void setNeedsRedrawOnImplThread() = 0; |
43 virtual void setNeedsCommitOnImplThread() = 0; | 43 virtual void setNeedsCommitOnImplThread() = 0; |
44 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) = 0; | 44 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) = 0; |
45 virtual void releaseContentsTexturesOnImplThread() = 0; | 45 virtual void releaseContentsTexturesOnImplThread() = 0; |
46 }; | 46 }; |
47 | 47 |
| 48 // CCPinchZoomViewport models the bounds and offset of the viewport that is used
during a pinch-zoom operation. |
| 49 // It tracks the layout-space dimensions of the viewport before any applied scal
e, and then tracks the layout-space |
| 50 // coordinates of the viewport respecting the pinch settings. |
| 51 class CCPinchZoomViewport { |
| 52 public: |
| 53 CCPinchZoomViewport(); |
| 54 |
| 55 float totalPageScaleFactor() const; |
| 56 |
| 57 void setPageScaleFactor(float factor) { m_pageScaleFactor = factor; } |
| 58 float pageScaleFactor() const { return m_pageScaleFactor; } |
| 59 |
| 60 void setPageScaleDelta(float delta); |
| 61 float pageScaleDelta() const { return m_pageScaleDelta; } |
| 62 |
| 63 float minPageScaleFactor() const { return m_minPageScaleFactor; } |
| 64 float maxPageScaleFactor() const { return m_maxPageScaleFactor; } |
| 65 |
| 66 void setSentPageScaleDelta(float delta) { m_sentPageScaleDelta = delta; } |
| 67 float sentPageScaleDelta() const { return m_sentPageScaleDelta; } |
| 68 |
| 69 // Returns true if the passed parameters were different from those previousl
y |
| 70 // cached. |
| 71 bool setPageScaleFactorAndLimits(float pageScaleFactor, |
| 72 float minPageScaleFactor, |
| 73 float maxPageScaleFactor); |
| 74 |
| 75 // Returns the bounds and offset of the scaled and translated viewport to us
e for pinch-zoom. |
| 76 FloatRect bounds() const; |
| 77 const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; } |
| 78 |
| 79 void setLayoutViewportSize(const FloatSize& size) { m_layoutViewportSize = s
ize; } |
| 80 |
| 81 // Apply the scroll offset in layout space to the offset of the pinch-zoom v
iewport. The viewport cannot be |
| 82 // scrolled outside of the layout viewport bounds. Returns the component of
the scroll that is un-applied due to |
| 83 // this constraint. |
| 84 FloatSize applyScroll(FloatSize&); |
| 85 |
| 86 WebKit::WebTransformationMatrix implTransform() const; |
| 87 |
| 88 private: |
| 89 float m_pageScaleFactor; |
| 90 float m_pageScaleDelta; |
| 91 float m_sentPageScaleDelta; |
| 92 float m_maxPageScaleFactor; |
| 93 float m_minPageScaleFactor; |
| 94 |
| 95 FloatPoint m_pinchViewportScrollDelta; |
| 96 FloatSize m_layoutViewportSize; |
| 97 }; |
| 98 |
48 // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering
state | 99 // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering
state |
49 class CCLayerTreeHostImpl : public CCInputHandlerClient, | 100 class CCLayerTreeHostImpl : public CCInputHandlerClient, |
50 public CCRendererClient, | 101 public CCRendererClient, |
51 public WebKit::WebCompositorOutputSurfaceClient { | 102 public WebKit::WebCompositorOutputSurfaceClient { |
52 typedef Vector<CCLayerImpl*> CCLayerList; | 103 typedef Vector<CCLayerImpl*> CCLayerList; |
53 | 104 |
54 public: | 105 public: |
55 static PassOwnPtr<CCLayerTreeHostImpl> create(const CCLayerTreeSettings&, CC
LayerTreeHostImplClient*); | 106 static PassOwnPtr<CCLayerTreeHostImpl> create(const CCLayerTreeSettings&, CC
LayerTreeHostImplClient*); |
56 virtual ~CCLayerTreeHostImpl(); | 107 virtual ~CCLayerTreeHostImpl(); |
57 | 108 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void setContentsTexturesPurged(); | 196 void setContentsTexturesPurged(); |
146 void resetContentsTexturesPurged(); | 197 void resetContentsTexturesPurged(); |
147 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } | 198 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy
tes; } |
148 | 199 |
149 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic
eViewportSize); | 200 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic
eViewportSize); |
150 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; } | 201 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; } |
151 | 202 |
152 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 203 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
153 void setDeviceScaleFactor(float); | 204 void setDeviceScaleFactor(float); |
154 | 205 |
155 float pageScale() const { return m_pageScale; } | 206 float pageScaleFactor() const; |
156 void setPageScaleFactorAndLimits(float pageScale, float minPageScale, float
maxPageScale); | 207 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); |
157 | 208 |
158 PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas(); | 209 PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas(); |
| 210 WebKit::WebTransformationMatrix implTransform() const; |
159 | 211 |
160 void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor,
float scale, double durationSec); | 212 void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor,
float scale, double durationSec); |
161 | 213 |
162 SkColor backgroundColor() const { return m_backgroundColor; } | 214 SkColor backgroundColor() const { return m_backgroundColor; } |
163 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } | 215 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } |
164 | 216 |
165 bool hasTransparentBackground() const { return m_hasTransparentBackground; } | 217 bool hasTransparentBackground() const { return m_hasTransparentBackground; } |
166 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } | 218 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } |
167 | 219 |
168 bool needsAnimateLayers() const { return m_needsAnimateLayers; } | 220 bool needsAnimateLayers() const { return m_needsAnimateLayers; } |
169 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } | 221 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } |
170 | 222 |
171 void setNeedsRedraw(); | 223 void setNeedsRedraw(); |
172 | 224 |
173 void renderingStats(CCRenderingStats*) const; | 225 void renderingStats(CCRenderingStats*) const; |
174 | 226 |
| 227 void updateRootScrollLayerImplTransform(); |
| 228 |
175 CCFrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } | 229 CCFrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } |
176 CCDebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get
(); } | 230 CCDebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get
(); } |
177 CCResourceProvider* resourceProvider() const { return m_resourceProvider.get
(); } | 231 CCResourceProvider* resourceProvider() const { return m_resourceProvider.get
(); } |
178 | 232 |
179 class CullRenderPassesWithCachedTextures { | 233 class CullRenderPassesWithCachedTextures { |
180 public: | 234 public: |
181 bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData
&) const; | 235 bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData
&) const; |
182 | 236 |
183 // Iterates from the root first, in order to remove the surfaces closest | 237 // Iterates from the root first, in order to remove the surfaces closest |
184 // to the root with cached textures, and all surfaces that draw into | 238 // to the root with cached textures, and all surfaces that draw into |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 int m_scrollingLayerIdFromPreviousTree; | 314 int m_scrollingLayerIdFromPreviousTree; |
261 bool m_scrollDeltaIsInScreenSpace; | 315 bool m_scrollDeltaIsInScreenSpace; |
262 CCLayerTreeSettings m_settings; | 316 CCLayerTreeSettings m_settings; |
263 IntSize m_layoutViewportSize; | 317 IntSize m_layoutViewportSize; |
264 IntSize m_deviceViewportSize; | 318 IntSize m_deviceViewportSize; |
265 float m_deviceScaleFactor; | 319 float m_deviceScaleFactor; |
266 bool m_visible; | 320 bool m_visible; |
267 bool m_contentsTexturesPurged; | 321 bool m_contentsTexturesPurged; |
268 size_t m_memoryAllocationLimitBytes; | 322 size_t m_memoryAllocationLimitBytes; |
269 | 323 |
270 float m_pageScale; | |
271 float m_pageScaleDelta; | |
272 float m_sentPageScaleDelta; | |
273 float m_minPageScale, m_maxPageScale; | |
274 | |
275 SkColor m_backgroundColor; | 324 SkColor m_backgroundColor; |
276 bool m_hasTransparentBackground; | 325 bool m_hasTransparentBackground; |
277 | 326 |
278 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 327 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
279 bool m_needsAnimateLayers; | 328 bool m_needsAnimateLayers; |
280 bool m_pinchGestureActive; | 329 bool m_pinchGestureActive; |
281 IntPoint m_previousPinchAnchor; | 330 IntPoint m_previousPinchAnchor; |
282 | 331 |
283 OwnPtr<CCPageScaleAnimation> m_pageScaleAnimation; | 332 OwnPtr<CCPageScaleAnimation> m_pageScaleAnimation; |
284 | 333 |
285 // This is used for ticking animations slowly when hidden. | 334 // This is used for ticking animations slowly when hidden. |
286 OwnPtr<CCLayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 335 OwnPtr<CCLayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
287 | 336 |
288 CCLayerSorter m_layerSorter; | 337 CCLayerSorter m_layerSorter; |
289 | 338 |
290 // List of visible layers for the most recently prepared frame. Used for | 339 // List of visible layers for the most recently prepared frame. Used for |
291 // rendering and input event hit testing. | 340 // rendering and input event hit testing. |
292 CCLayerList m_renderSurfaceLayerList; | 341 CCLayerList m_renderSurfaceLayerList; |
293 | 342 |
| 343 CCPinchZoomViewport m_pinchZoomViewport; |
| 344 |
294 OwnPtr<CCFrameRateCounter> m_fpsCounter; | 345 OwnPtr<CCFrameRateCounter> m_fpsCounter; |
295 OwnPtr<CCDebugRectHistory> m_debugRectHistory; | 346 OwnPtr<CCDebugRectHistory> m_debugRectHistory; |
296 | 347 |
297 DISALLOW_COPY_AND_ASSIGN(CCLayerTreeHostImpl); | 348 DISALLOW_COPY_AND_ASSIGN(CCLayerTreeHostImpl); |
298 }; | 349 }; |
299 | 350 |
300 }; | 351 }; |
301 | 352 |
302 #endif | 353 #endif |
OLD | NEW |