[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 5 | #ifndef CC_LAYER_TREE_HOST_IMPL_H_ |
| 6 | #define CC_LAYER_TREE_HOST_IMPL_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 8 | #include "base/basictypes.h" |
| 9 | #include "base/memory/scoped_ptr.h" |
| 10 | #include "base/time.h" |
[email protected] | aa0a9d3 | 2012-10-24 01:58:10 | [diff] [blame] | 11 | #include "cc/animation_events.h" |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 12 | #include "cc/animation_registrar.h" |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 13 | #include "cc/cc_export.h" |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 14 | #include "cc/input_handler.h" |
[email protected] | a46f3293 | 2012-12-07 21:43:16 | [diff] [blame] | 15 | #include "cc/output_surface_client.h" |
[email protected] | a823df8 | 2013-01-10 02:38:17 | [diff] [blame] | 16 | #include "cc/pinch_zoom_viewport.h" |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 17 | #include "cc/render_pass.h" |
| 18 | #include "cc/render_pass_sink.h" |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 19 | #include "cc/renderer.h" |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 20 | #include "cc/tile_manager.h" |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 21 | #include "cc/top_controls_manager_client.h" |
[email protected] | b9dcf43a | 2013-01-09 00:15:29 | [diff] [blame] | 22 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 23 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | b9dcf43a | 2013-01-09 00:15:29 | [diff] [blame] | 24 | #include "third_party/skia/include/core/SkPicture.h" |
[email protected] | 167ed9d5 | 2012-10-31 20:47:58 | [diff] [blame] | 25 | #include "ui/gfx/rect.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 26 | |
| 27 | namespace cc { |
| 28 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 29 | class CompletionEvent; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 30 | class CompositorFrameMetadata; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 31 | class DebugRectHistory; |
| 32 | class FrameRateCounter; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 33 | class LayerImpl; |
| 34 | class LayerTreeHostImplTimeSourceAdapter; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 35 | class LayerTreeImpl; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 36 | class PageScaleAnimation; |
[email protected] | 0edbfbe9f | 2013-01-17 03:33:03 | [diff] [blame] | 37 | class PaintTimeCounter; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 38 | class RenderPassDrawQuad; |
| 39 | class ResourceProvider; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 40 | class TopControlsManager; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 41 | struct RendererCapabilities; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 42 | struct RenderingStats; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 43 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 44 | // LayerTreeHost->Proxy callback interface. |
| 45 | class LayerTreeHostImplClient { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 46 | public: |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 47 | virtual void didLoseOutputSurfaceOnImplThread() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 48 | virtual void onSwapBuffersCompleteOnImplThread() = 0; |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 49 | virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 50 | virtual void onCanDrawStateChanged(bool canDraw) = 0; |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 51 | virtual void onHasPendingTreeStateChanged(bool hasPendingTree) = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 52 | virtual void setNeedsRedrawOnImplThread() = 0; |
[email protected] | 6367cda | 2013-01-23 00:21:13 | [diff] [blame] | 53 | virtual void didSwapUseIncompleteTileOnImplThread() = 0; |
| 54 | virtual void didUploadVisibleHighResolutionTileOnImplThread() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 55 | virtual void setNeedsCommitOnImplThread() = 0; |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 56 | virtual void setNeedsManageTilesOnImplThread() = 0; |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 57 | virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime) = 0; |
[email protected] | b1969fa | 2012-10-17 20:16:29 | [diff] [blame] | 58 | // Returns true if resources were deleted by this call. |
[email protected] | a0a0084 | 2012-10-22 22:50:28 | [diff] [blame] | 59 | virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) = 0; |
[email protected] | 3d21e02 | 2012-10-25 20:03:08 | [diff] [blame] | 60 | virtual void sendManagedMemoryStats() = 0; |
[email protected] | 74d9063c | 2013-01-18 03:14:47 | [diff] [blame] | 61 | virtual bool isInsideDraw() = 0; |
[email protected] | 362f1e8b | 2013-01-21 16:54:30 | [diff] [blame] | 62 | virtual void renewTreePriority() = 0; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 63 | }; |
| 64 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 65 | // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering state |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 66 | class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
| 67 | public RendererClient, |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 68 | public TileManagerClient, |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 69 | public OutputSurfaceClient, |
| 70 | public TopControlsManagerClient { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 71 | typedef std::vector<LayerImpl*> LayerList; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 72 | |
| 73 | public: |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 74 | static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy*); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 75 | virtual ~LayerTreeHostImpl(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 76 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 77 | // InputHandlerClient implementation |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 78 | virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandlerClient::ScrollInputType) OVERRIDE; |
[email protected] | a971096 | 2012-11-14 20:11:02 | [diff] [blame] | 79 | virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 80 | virtual void scrollEnd() OVERRIDE; |
| 81 | virtual void pinchGestureBegin() OVERRIDE; |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 82 | virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 83 | virtual void pinchGestureEnd() OVERRIDE; |
[email protected] | 69a2a5be | 2012-11-14 06:51:44 | [diff] [blame] | 84 | virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 85 | virtual void scheduleAnimation() OVERRIDE; |
[email protected] | 2f1acc26 | 2012-11-16 21:42:22 | [diff] [blame] | 86 | virtual bool haveTouchEventHandlersAt(const gfx::Point&) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 87 | |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 88 | // TopControlsManagerClient implementation. |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame^] | 89 | virtual void setActiveTreeNeedsUpdateDrawProperties() OVERRIDE; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 90 | virtual void setNeedsRedraw() OVERRIDE; |
[email protected] | 69b50ec | 2013-01-19 04:58:01 | [diff] [blame] | 91 | virtual bool haveRootScrollLayer() const OVERRIDE; |
| 92 | virtual float rootScrollLayerTotalScrollY() const OVERRIDE; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 93 | |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 94 | struct CC_EXPORT FrameData : public RenderPassSink { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 95 | FrameData(); |
| 96 | ~FrameData(); |
| 97 | |
[email protected] | 167ed9d5 | 2012-10-31 20:47:58 | [diff] [blame] | 98 | std::vector<gfx::Rect> occludingScreenSpaceRects; |
[email protected] | 4d8804e | 2012-11-15 01:51:10 | [diff] [blame] | 99 | std::vector<gfx::Rect> nonOccludingScreenSpaceRects; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 100 | RenderPassList renderPasses; |
| 101 | RenderPassIdHashMap renderPassesById; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 102 | const LayerList* renderSurfaceLayerList; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 103 | LayerList willDrawLayers; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 104 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 105 | // RenderPassSink implementation. |
| 106 | virtual void appendRenderPass(scoped_ptr<RenderPass>) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | // Virtual for testing. |
| 110 | virtual void beginCommit(); |
| 111 | virtual void commitComplete(); |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 112 | virtual void animate(base::TimeTicks monotonicTime, base::Time wallClockTime); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 113 | |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 114 | void manageTiles(); |
| 115 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 116 | // Returns false if problems occured preparing the frame, and we should try |
| 117 | // to avoid displaying the frame. If prepareToDraw is called, |
| 118 | // didDrawAllLayers must also be called, regardless of whether drawLayers is |
| 119 | // called between the two. |
| 120 | virtual bool prepareToDraw(FrameData&); |
[email protected] | 85167c7 | 2012-12-04 03:56:07 | [diff] [blame] | 121 | virtual void drawLayers(FrameData&); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 122 | // Must be called if and only if prepareToDraw was called. |
| 123 | void didDrawAllLayers(const FrameData&); |
| 124 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 125 | // RendererClient implementation |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 126 | virtual const gfx::Size& deviceViewportSize() const OVERRIDE; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 127 | virtual const LayerTreeSettings& settings() const OVERRIDE; |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 128 | virtual void didLoseOutputSurface() OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 129 | virtual void onSwapBuffersComplete() OVERRIDE; |
| 130 | virtual void setFullRootLayerDamage() OVERRIDE; |
[email protected] | a0a0084 | 2012-10-22 22:50:28 | [diff] [blame] | 131 | virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
| 132 | virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 133 | virtual bool hasImplThread() const OVERRIDE; |
[email protected] | f35e232 | 2012-12-15 21:45:52 | [diff] [blame] | 134 | virtual bool shouldClearRootRenderPass() const OVERRIDE; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 135 | virtual CompositorFrameMetadata makeCompositorFrameMetadata() const OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 136 | |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 137 | // TileManagerClient implementation. |
| 138 | virtual void ScheduleManageTiles() OVERRIDE; |
[email protected] | 74d9063c | 2013-01-18 03:14:47 | [diff] [blame] | 139 | virtual void DidUploadVisibleHighResolutionTile() OVERRIDE; |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 140 | |
[email protected] | a46f3293 | 2012-12-07 21:43:16 | [diff] [blame] | 141 | // OutputSurfaceClient implementation. |
| 142 | virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE; |
| 143 | virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 144 | |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 145 | // Called from LayerTreeImpl. |
| 146 | void OnCanDrawStateChangedForTree(LayerTreeImpl*); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 147 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 148 | // Implementation |
| 149 | bool canDraw(); |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 150 | OutputSurface* outputSurface() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 151 | |
| 152 | std::string layerTreeAsText() const; |
[email protected] | 4a23c374c | 2012-12-08 08:38:55 | [diff] [blame] | 153 | std::string layerTreeAsJson() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 154 | |
| 155 | void finishAllRendering(); |
| 156 | int sourceAnimationFrameNumber() const; |
| 157 | |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 158 | bool initializeRenderer(scoped_ptr<OutputSurface>); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 159 | bool isContextLost(); |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 160 | TileManager* tileManager() { return m_tileManager.get(); } |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 161 | Renderer* renderer() { return m_renderer.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 162 | const RendererCapabilities& rendererCapabilities() const; |
| 163 | |
| 164 | bool swapBuffers(); |
| 165 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 166 | void readback(void* pixels, const gfx::Rect&); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 167 | |
[email protected] | 69b50ec | 2013-01-19 04:58:01 | [diff] [blame] | 168 | LayerTreeImpl* activeTree() { return m_activeTree.get(); } |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 169 | const LayerTreeImpl* activeTree() const { return m_activeTree.get(); } |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 170 | LayerTreeImpl* pendingTree() { return m_pendingTree.get(); } |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 171 | const LayerTreeImpl* pendingTree() const { return m_pendingTree.get(); } |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 172 | const LayerTreeImpl* recycleTree() const { return m_recycleTree.get(); } |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 173 | void createPendingTree(); |
[email protected] | 6367cda | 2013-01-23 00:21:13 | [diff] [blame] | 174 | void checkForCompletedTileUploads(); |
[email protected] | 9bd1cb5 | 2013-01-03 22:26:33 | [diff] [blame] | 175 | virtual void activatePendingTreeIfNeeded(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 176 | |
[email protected] | a3029014 | 2013-01-05 01:27:00 | [diff] [blame] | 177 | // Shortcuts to layers on the active tree. |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 178 | LayerImpl* rootLayer() const; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 179 | LayerImpl* rootScrollLayer() const; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 180 | LayerImpl* currentlyScrollingLayer() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 181 | |
| 182 | bool visible() const { return m_visible; } |
| 183 | void setVisible(bool); |
| 184 | |
[email protected] | a0a0084 | 2012-10-22 22:50:28 | [diff] [blame] | 185 | size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.bytesLimitWhenVisible; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 186 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 187 | void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& deviceViewportSize); |
| 188 | const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 189 | |
| 190 | float deviceScaleFactor() const { return m_deviceScaleFactor; } |
| 191 | void setDeviceScaleFactor(float); |
| 192 | |
| 193 | float pageScaleFactor() const; |
| 194 | void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor); |
| 195 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 196 | scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 197 | gfx::Transform implTransform() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 198 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 199 | void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 200 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 201 | bool needsAnimateLayers() const { return !m_animationRegistrar->active_animation_controllers().empty(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 202 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 203 | void renderingStats(RenderingStats*) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 204 | |
[email protected] | d3afa11 | 2012-12-08 06:24:28 | [diff] [blame] | 205 | void sendManagedMemoryStats( |
| 206 | size_t memoryVisibleBytes, |
| 207 | size_t memoryVisibleAndNearbyBytes, |
| 208 | size_t memoryUseBytes); |
| 209 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 210 | FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } |
[email protected] | 0edbfbe9f | 2013-01-17 03:33:03 | [diff] [blame] | 211 | PaintTimeCounter* paintTimeCounter() const { return m_paintTimeCounter.get(); } |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 212 | DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get(); } |
| 213 | ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); } |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 214 | TopControlsManager* topControlsManager() const { return m_topControlsManager.get(); } |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 215 | |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 216 | Proxy* proxy() const { return m_proxy; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 217 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 218 | AnimationRegistrar* animationRegistrar() const { return m_animationRegistrar.get(); } |
| 219 | |
[email protected] | f511afb | 2012-11-30 01:55:20 | [diff] [blame] | 220 | void setDebugState(const LayerTreeDebugState& debugState) { m_debugState = debugState; } |
| 221 | const LayerTreeDebugState& debugState() const { return m_debugState; } |
| 222 | |
[email protected] | 0edbfbe9f | 2013-01-17 03:33:03 | [diff] [blame] | 223 | void savePaintTime(const base::TimeDelta& totalPaintTime); |
| 224 | |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 225 | class CC_EXPORT CullRenderPassesWithCachedTextures { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 226 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 227 | bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 228 | |
| 229 | // Iterates from the root first, in order to remove the surfaces closest |
| 230 | // to the root with cached textures, and all surfaces that draw into |
| 231 | // them. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 232 | size_t renderPassListBegin(const RenderPassList& list) const { return list.size() - 1; } |
| 233 | size_t renderPassListEnd(const RenderPassList&) const { return 0 - 1; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 234 | size_t renderPassListNext(size_t it) const { return it - 1; } |
| 235 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 236 | CullRenderPassesWithCachedTextures(Renderer& renderer) : m_renderer(renderer) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 237 | private: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 238 | Renderer& m_renderer; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 239 | }; |
| 240 | |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 241 | class CC_EXPORT CullRenderPassesWithNoQuads { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 242 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 243 | bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 244 | |
| 245 | // Iterates in draw order, so that when a surface is removed, and its |
| 246 | // target becomes empty, then its target can be removed also. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 247 | size_t renderPassListBegin(const RenderPassList&) const { return 0; } |
| 248 | size_t renderPassListEnd(const RenderPassList& list) const { return list.size(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 249 | size_t renderPassListNext(size_t it) const { return it + 1; } |
| 250 | }; |
| 251 | |
| 252 | template<typename RenderPassCuller> |
| 253 | static void removeRenderPasses(RenderPassCuller, FrameData&); |
| 254 | |
[email protected] | a823df8 | 2013-01-10 02:38:17 | [diff] [blame] | 255 | float totalPageScaleFactorForTesting() const { return m_pinchZoomViewport.total_page_scale_factor(); } |
[email protected] | 2d69299 | 2012-12-19 01:19:32 | [diff] [blame] | 256 | |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 257 | const PinchZoomViewport& pinchZoomViewport() const { return m_pinchZoomViewport; } |
| 258 | |
[email protected] | b9dcf43a | 2013-01-09 00:15:29 | [diff] [blame] | 259 | skia::RefPtr<SkPicture> capturePicture(); |
| 260 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 261 | bool pinchGestureActive() const { return m_pinchGestureActive; } |
| 262 | |
[email protected] | 362f1e8b | 2013-01-21 16:54:30 | [diff] [blame] | 263 | void setTreePriority(TreePriority priority); |
| 264 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 265 | protected: |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 266 | LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy*); |
[email protected] | 2e7ca42 | 2012-12-20 02:57:27 | [diff] [blame] | 267 | void activatePendingTree(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 268 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 269 | // Virtual for testing. |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 270 | virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 271 | |
| 272 | // Virtual for testing. |
| 273 | virtual base::TimeDelta lowFrequencyAnimationInterval() const; |
| 274 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 275 | const AnimationRegistrar::AnimationControllerMap& activeAnimationControllers() const { return m_animationRegistrar->active_animation_controllers(); } |
| 276 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 277 | LayerTreeHostImplClient* m_client; |
[email protected] | 61de581 | 2012-11-08 07:03:44 | [diff] [blame] | 278 | Proxy* m_proxy; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 279 | |
| 280 | private: |
[email protected] | 2d69299 | 2012-12-19 01:19:32 | [diff] [blame] | 281 | void animatePageScale(base::TimeTicks monotonicTime); |
| 282 | void animateScrollbars(base::TimeTicks monotonicTime); |
| 283 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 284 | void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); |
| 285 | void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 286 | void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scrollOffset, float pageScale); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 287 | |
| 288 | void setPageScaleDelta(float); |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame^] | 289 | gfx::Vector2dF scrollPinchZoomViewport(gfx::Vector2dF delta); |
| 290 | gfx::Vector2dF scrollLayerWithViewportSpaceDelta(LayerImpl* layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewportDelta); |
| 291 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 292 | void updateMaxScrollOffset(); |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 293 | void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& renderSurfaceLayerList); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 294 | |
| 295 | // Returns false if the frame should not be displayed. This function should |
| 296 | // only be called from prepareToDraw, as didDrawAllLayers must be called |
| 297 | // if this helper function is called. |
| 298 | bool calculateRenderPasses(FrameData&); |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 299 | void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base::Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimateLayers); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 300 | void setBackgroundTickingEnabled(bool); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 301 | |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 302 | void sendDidLoseOutputSurfaceRecursive(LayerImpl*); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 303 | void clearRenderSurfaces(); |
| 304 | bool ensureRenderSurfaceLayerList(); |
| 305 | void clearCurrentlyScrollingLayer(); |
| 306 | |
[email protected] | 30faac9 | 2012-10-29 00:06:29 | [diff] [blame] | 307 | void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 308 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 309 | void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 310 | |
[email protected] | b9dcf43a | 2013-01-09 00:15:29 | [diff] [blame] | 311 | static LayerImpl* getNonCompositedContentLayerRecursive(LayerImpl* layer); |
| 312 | |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 313 | scoped_ptr<OutputSurface> m_outputSurface; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 314 | scoped_ptr<ResourceProvider> m_resourceProvider; |
| 315 | scoped_ptr<Renderer> m_renderer; |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 316 | scoped_ptr<TileManager> m_tileManager; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 317 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 318 | // Tree currently being drawn. |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 319 | scoped_ptr<LayerTreeImpl> m_activeTree; |
| 320 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 321 | // In impl-side painting mode, tree with possibly incomplete rasterized |
| 322 | // content. May be promoted to active by activatePendingTreeIfNeeded(). |
| 323 | scoped_ptr<LayerTreeImpl> m_pendingTree; |
| 324 | |
| 325 | // In impl-side painting mode, inert tree with layers that can be recycled |
| 326 | // by the next sync from the main thread. |
| 327 | scoped_ptr<LayerTreeImpl> m_recycleTree; |
| 328 | |
[email protected] | 31bfe27 | 2012-10-19 18:49:52 | [diff] [blame] | 329 | bool m_scrollDeltaIsInViewportSpace; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 330 | LayerTreeSettings m_settings; |
[email protected] | f511afb | 2012-11-30 01:55:20 | [diff] [blame] | 331 | LayerTreeDebugState m_debugState; |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 332 | gfx::Size m_layoutViewportSize; |
| 333 | gfx::Size m_deviceViewportSize; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 334 | float m_deviceScaleFactor; |
| 335 | bool m_visible; |
[email protected] | a0a0084 | 2012-10-22 22:50:28 | [diff] [blame] | 336 | ManagedMemoryPolicy m_managedMemoryPolicy; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 337 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 338 | bool m_pinchGestureActive; |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 339 | gfx::Point m_previousPinchAnchor; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 340 | |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 341 | scoped_ptr<TopControlsManager> m_topControlsManager; |
| 342 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 343 | scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 344 | |
| 345 | // This is used for ticking animations slowly when hidden. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 346 | scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 347 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 348 | PinchZoomViewport m_pinchZoomViewport; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 349 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 350 | scoped_ptr<FrameRateCounter> m_fpsCounter; |
[email protected] | 0edbfbe9f | 2013-01-17 03:33:03 | [diff] [blame] | 351 | scoped_ptr<PaintTimeCounter> m_paintTimeCounter; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 352 | scoped_ptr<DebugRectHistory> m_debugRectHistory; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 353 | |
[email protected] | f2bbb4e | 2012-12-07 21:40:49 | [diff] [blame] | 354 | int64 m_numImplThreadScrolls; |
| 355 | int64 m_numMainThreadScrolls; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 356 | |
[email protected] | f2bbb4e | 2012-12-07 21:40:49 | [diff] [blame] | 357 | int64 m_cumulativeNumLayersDrawn; |
| 358 | |
| 359 | int64 m_cumulativeNumMissingTiles; |
[email protected] | 9c2be6a | 2012-11-27 19:16:10 | [diff] [blame] | 360 | |
[email protected] | d3afa11 | 2012-12-08 06:24:28 | [diff] [blame] | 361 | size_t m_lastSentMemoryVisibleBytes; |
| 362 | size_t m_lastSentMemoryVisibleAndNearbyBytes; |
| 363 | size_t m_lastSentMemoryUseBytes; |
| 364 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 365 | scoped_ptr<AnimationRegistrar> m_animationRegistrar; |
| 366 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 367 | DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 368 | }; |
| 369 | |
[email protected] | 0023e8b | 2012-10-15 12:52:45 | [diff] [blame] | 370 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 371 | |
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 372 | #endif // CC_LAYER_TREE_HOST_IMPL_H_ |