Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: cc/CCLayerTreeHostImpl.h

Issue 10916279: Chromium compositor change implementing page-scale driven pinch-zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Reduce number of prepared tiles and correct existing tests. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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() : m_pageScaleFactor(1) { }
53
54 void setTotalPageScaleFactor(float factor) { m_pageScaleFactor = factor; }
55
56 // Returns the bounds and offset of the scaled and translated viewport to us e for pinch-zoom.
57 FloatRect bounds() const;
58 const FloatPoint& scrollDelta() const { return m_pinchViewportScrollDelta; }
59
60 const FloatSize& unpinchedBounds() const { return m_unpinchedBounds; }
61 void setUnpinchedBounds(const FloatSize& bounds) { m_unpinchedBounds = bound s; }
62
63 // Apply the scroll offset in layout space to the offset of the pinch-zoom v iewport. The viewport cannot be
64 // scrolled outside of the unpinched bounds. Returns the component of the sc roll that is un-applied due to
65 // this constraint.
66 FloatSize applyScroll(FloatSize&);
67
68 private:
69 float m_pageScaleFactor;
70 FloatPoint m_pinchViewportScrollDelta;
71
72 FloatSize m_unpinchedBounds;
73 };
74
47 // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering state 75 // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering state
48 class CCLayerTreeHostImpl : public CCInputHandlerClient, 76 class CCLayerTreeHostImpl : public CCInputHandlerClient,
49 public CCRendererClient, 77 public CCRendererClient,
50 public WebKit::WebCompositorOutputSurfaceClient { 78 public WebKit::WebCompositorOutputSurfaceClient {
51 WTF_MAKE_NONCOPYABLE(CCLayerTreeHostImpl); 79 WTF_MAKE_NONCOPYABLE(CCLayerTreeHostImpl);
52 typedef Vector<CCLayerImpl*> CCLayerList; 80 typedef Vector<CCLayerImpl*> CCLayerList;
53 81
54 public: 82 public:
55 static PassOwnPtr<CCLayerTreeHostImpl> create(const CCLayerTreeSettings&, CC LayerTreeHostImplClient*); 83 static PassOwnPtr<CCLayerTreeHostImpl> create(const CCLayerTreeSettings&, CC LayerTreeHostImplClient*);
56 virtual ~CCLayerTreeHostImpl(); 84 virtual ~CCLayerTreeHostImpl();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 void setContentsTexturesPurged(); 173 void setContentsTexturesPurged();
146 void resetContentsTexturesPurged(); 174 void resetContentsTexturesPurged();
147 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy tes; } 175 size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBy tes; }
148 176
149 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic eViewportSize); 177 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic eViewportSize);
150 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; } 178 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; }
151 179
152 float deviceScaleFactor() const { return m_deviceScaleFactor; } 180 float deviceScaleFactor() const { return m_deviceScaleFactor; }
153 void setDeviceScaleFactor(float); 181 void setDeviceScaleFactor(float);
154 182
155 float pageScale() const { return m_pageScale; } 183 float pageScaleFactor() const { return m_pageScaleFactor; }
156 void setPageScaleFactorAndLimits(float pageScale, float minPageScale, float maxPageScale); 184 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa ctor, float maxPageScaleFactor);
157 185
158 PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas(); 186 PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas();
187 WebKit::WebTransformationMatrix implTransform() const;
159 188
160 void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, double durationSec); 189 void startPageScaleAnimation(const IntSize& tragetPosition, bool useAnchor, float scale, double durationSec);
161 190
162 SkColor backgroundColor() const { return m_backgroundColor; } 191 SkColor backgroundColor() const { return m_backgroundColor; }
163 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } 192 void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
164 193
165 bool hasTransparentBackground() const { return m_hasTransparentBackground; } 194 bool hasTransparentBackground() const { return m_hasTransparentBackground; }
166 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; } 195 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; }
167 196
168 bool needsAnimateLayers() const { return m_needsAnimateLayers; } 197 bool needsAnimateLayers() const { return m_needsAnimateLayers; }
169 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } 198 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; }
170 199
171 void setNeedsRedraw(); 200 void setNeedsRedraw();
172 201
173 void renderingStats(CCRenderingStats&) const; 202 void renderingStats(CCRenderingStats&) const;
174 203
204 void updateRootScrollLayerImplTransform();
205
175 CCFrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } 206 CCFrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); }
176 CCDebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get (); } 207 CCDebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get (); }
177 CCResourceProvider* resourceProvider() const { return m_resourceProvider.get (); } 208 CCResourceProvider* resourceProvider() const { return m_resourceProvider.get (); }
178 209
179 class CullRenderPassesWithCachedTextures { 210 class CullRenderPassesWithCachedTextures {
180 public: 211 public:
181 bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData &) const; 212 bool shouldRemoveRenderPass(const CCRenderPassDrawQuad&, const FrameData &) const;
182 213
183 // Iterates from the root first, in order to remove the surfaces closest 214 // 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 215 // to the root with cached textures, and all surfaces that draw into
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 int m_scrollingLayerIdFromPreviousTree; 291 int m_scrollingLayerIdFromPreviousTree;
261 bool m_scrollDeltaIsInScreenSpace; 292 bool m_scrollDeltaIsInScreenSpace;
262 CCLayerTreeSettings m_settings; 293 CCLayerTreeSettings m_settings;
263 IntSize m_layoutViewportSize; 294 IntSize m_layoutViewportSize;
264 IntSize m_deviceViewportSize; 295 IntSize m_deviceViewportSize;
265 float m_deviceScaleFactor; 296 float m_deviceScaleFactor;
266 bool m_visible; 297 bool m_visible;
267 bool m_contentsTexturesPurged; 298 bool m_contentsTexturesPurged;
268 size_t m_memoryAllocationLimitBytes; 299 size_t m_memoryAllocationLimitBytes;
269 300
270 float m_pageScale; 301 float m_pageScaleFactor;
271 float m_pageScaleDelta; 302 float m_pageScaleDelta;
272 float m_sentPageScaleDelta; 303 float m_sentPageScaleDelta;
273 float m_minPageScale, m_maxPageScale; 304 float m_minPageScaleFactor, m_maxPageScaleFactor;
274 305
275 SkColor m_backgroundColor; 306 SkColor m_backgroundColor;
276 bool m_hasTransparentBackground; 307 bool m_hasTransparentBackground;
277 308
278 // If this is true, it is necessary to traverse the layer tree ticking the a nimators. 309 // If this is true, it is necessary to traverse the layer tree ticking the a nimators.
279 bool m_needsAnimateLayers; 310 bool m_needsAnimateLayers;
280 bool m_pinchGestureActive; 311 bool m_pinchGestureActive;
281 IntPoint m_previousPinchAnchor; 312 IntPoint m_previousPinchAnchor;
282 313
283 OwnPtr<CCPageScaleAnimation> m_pageScaleAnimation; 314 OwnPtr<CCPageScaleAnimation> m_pageScaleAnimation;
284 315
285 // This is used for ticking animations slowly when hidden. 316 // This is used for ticking animations slowly when hidden.
286 OwnPtr<CCLayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; 317 OwnPtr<CCLayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter;
287 318
288 CCLayerSorter m_layerSorter; 319 CCLayerSorter m_layerSorter;
289 320
290 // List of visible layers for the most recently prepared frame. Used for 321 // List of visible layers for the most recently prepared frame. Used for
291 // rendering and input event hit testing. 322 // rendering and input event hit testing.
292 CCLayerList m_renderSurfaceLayerList; 323 CCLayerList m_renderSurfaceLayerList;
293 324
325 bool m_applyPinchZoomInImpl;
326 CCPinchZoomViewport m_pinchZoomViewport;
327
294 OwnPtr<CCFrameRateCounter> m_fpsCounter; 328 OwnPtr<CCFrameRateCounter> m_fpsCounter;
295 OwnPtr<CCDebugRectHistory> m_debugRectHistory; 329 OwnPtr<CCDebugRectHistory> m_debugRectHistory;
296 }; 330 };
297 331
298 }; 332 };
299 333
300 #endif 334 #endif
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostCommon.cpp ('k') | cc/CCLayerTreeHostImpl.cpp » ('j') | cc/CCSettings.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698