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