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