[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] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 6 | #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 8 | #include <list> |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 9 | #include <set> |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 13 | #include "base/basictypes.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 14 | #include "base/containers/hash_tables.h" |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 15 | #include "base/memory/scoped_ptr.h" |
[email protected] | 1b0df50 | 2013-06-27 23:39:58 | [diff] [blame] | 16 | #include "base/time/time.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 17 | #include "cc/animation/animation_events.h" |
| 18 | #include "cc/animation/animation_registrar.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 19 | #include "cc/base/cc_export.h" |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 20 | #include "cc/input/input_handler.h" |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 21 | #include "cc/input/layer_scroll_offset_delegate.h" |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 22 | #include "cc/input/top_controls_manager_client.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 23 | #include "cc/layers/layer_lists.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 24 | #include "cc/layers/render_pass_sink.h" |
[email protected] | df3c24c9 | 2013-06-19 03:54:35 | [diff] [blame] | 25 | #include "cc/output/begin_frame_args.h" |
[email protected] | fd32d12 | 2013-06-29 13:11:04 | [diff] [blame] | 26 | #include "cc/output/managed_memory_policy.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 27 | #include "cc/output/output_surface_client.h" |
| 28 | #include "cc/output/renderer.h" |
[email protected] | 89e8267a | 2013-03-18 07:50:56 | [diff] [blame] | 29 | #include "cc/quads/render_pass.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 30 | #include "cc/resources/resource_provider.h" |
[email protected] | e12dd0e | 2013-03-18 08:24:40 | [diff] [blame] | 31 | #include "cc/resources/tile_manager.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 32 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 33 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 167ed9d5 | 2012-10-31 20:47:58 | [diff] [blame] | 34 | #include "ui/gfx/rect.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 35 | |
| 36 | namespace cc { |
| 37 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 38 | class CompletionEvent; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 39 | class CompositorFrameMetadata; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 40 | class DebugRectHistory; |
| 41 | class FrameRateCounter; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 42 | class LayerImpl; |
| 43 | class LayerTreeHostImplTimeSourceAdapter; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 44 | class LayerTreeImpl; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 45 | class PageScaleAnimation; |
[email protected] | 0edbfbe9f | 2013-01-17 03:33:03 | [diff] [blame] | 46 | class PaintTimeCounter; |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 47 | class MemoryHistory; |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 48 | class RenderingStatsInstrumentation; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 49 | class RenderPassDrawQuad; |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 50 | class ScrollbarLayerImplBase; |
[email protected] | ea468c6c | 2013-09-10 08:25:11 | [diff] [blame] | 51 | class TextureMailboxDeleter; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 52 | class TopControlsManager; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 53 | class UIResourceBitmap; |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 54 | class UIResourceRequest; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 55 | struct RendererCapabilities; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 56 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 57 | // LayerTreeHost->Proxy callback interface. |
| 58 | class LayerTreeHostImplClient { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 59 | public: |
| 60 | virtual void DidLoseOutputSurfaceOnImplThread() = 0; |
[email protected] | 4d7e46a | 2013-11-08 05:33:40 | [diff] [blame^] | 61 | virtual void DidSwapBuffersOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 62 | virtual void OnSwapBuffersCompleteOnImplThread() = 0; |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 63 | virtual void BeginImplFrame(const BeginFrameArgs& args) = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 64 | virtual void OnCanDrawStateChanged(bool can_draw) = 0; |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 65 | virtual void NotifyReadyToActivate() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 66 | virtual void SetNeedsRedrawOnImplThread() = 0; |
[email protected] | 1cd9f555 | 2013-04-26 04:22:03 | [diff] [blame] | 67 | virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) = 0; |
[email protected] | 8612679 | 2013-03-16 20:07:54 | [diff] [blame] | 68 | virtual void DidInitializeVisibleTileOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 69 | virtual void SetNeedsCommitOnImplThread() = 0; |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 70 | virtual void SetNeedsManageTilesOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 71 | virtual void PostAnimationEventsToMainThreadOnImplThread( |
| 72 | scoped_ptr<AnimationEventsVector> events, |
| 73 | base::Time wall_clock_time) = 0; |
| 74 | // Returns true if resources were deleted by this call. |
| 75 | virtual bool ReduceContentsTextureMemoryOnImplThread( |
| 76 | size_t limit_bytes, |
| 77 | int priority_cutoff) = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 78 | virtual void SendManagedMemoryStats() = 0; |
| 79 | virtual bool IsInsideDraw() = 0; |
| 80 | virtual void RenewTreePriority() = 0; |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 81 | virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0; |
[email protected] | 2a61ad5 | 2013-05-13 14:01:29 | [diff] [blame] | 82 | virtual void DidActivatePendingTree() = 0; |
[email protected] | bac0e55 | 2013-11-05 22:38:51 | [diff] [blame] | 83 | virtual void DidManageTiles() = 0; |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 84 | |
| 85 | protected: |
| 86 | virtual ~LayerTreeHostImplClient() {} |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 87 | }; |
| 88 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 89 | // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
| 90 | // state. |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 91 | class CC_EXPORT LayerTreeHostImpl |
| 92 | : public InputHandler, |
| 93 | public RendererClient, |
| 94 | public TileManagerClient, |
| 95 | public OutputSurfaceClient, |
| 96 | public TopControlsManagerClient, |
| 97 | public base::SupportsWeakPtr<LayerTreeHostImpl> { |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 98 | public: |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 99 | static scoped_ptr<LayerTreeHostImpl> Create( |
| 100 | const LayerTreeSettings& settings, |
| 101 | LayerTreeHostImplClient* client, |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 102 | Proxy* proxy, |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 103 | RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 104 | SharedBitmapManager* manager); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 105 | virtual ~LayerTreeHostImpl(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 106 | |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 107 | // InputHandler implementation |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 108 | virtual void BindToClient(InputHandlerClient* client) OVERRIDE; |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 109 | virtual InputHandler::ScrollStatus ScrollBegin( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 110 | gfx::Point viewport_point, |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 111 | InputHandler::ScrollInputType type) OVERRIDE; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 112 | virtual bool ScrollBy(gfx::Point viewport_point, |
| 113 | gfx::Vector2dF scroll_delta) OVERRIDE; |
[email protected] | c28df4c1 | 2013-05-22 17:36:49 | [diff] [blame] | 114 | virtual bool ScrollVerticallyByPage(gfx::Point viewport_point, |
| 115 | ScrollDirection direction) OVERRIDE; |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 116 | virtual void SetRootLayerScrollOffsetDelegate( |
| 117 | LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE; |
| 118 | virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 119 | virtual void ScrollEnd() OVERRIDE; |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 120 | virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE; |
[email protected] | 6e921bd | 2013-04-29 21:10:20 | [diff] [blame] | 121 | virtual void NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) OVERRIDE; |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 122 | virtual void MouseMoveAt(gfx::Point viewport_point) OVERRIDE; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 123 | virtual void PinchGestureBegin() OVERRIDE; |
| 124 | virtual void PinchGestureUpdate(float magnify_delta, |
| 125 | gfx::Point anchor) OVERRIDE; |
| 126 | virtual void PinchGestureEnd() OVERRIDE; |
| 127 | virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, |
| 128 | bool anchor_point, |
| 129 | float page_scale, |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 130 | base::TimeDelta duration) OVERRIDE; |
| 131 | virtual void ScheduleAnimation() OVERRIDE; |
| 132 | virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE; |
[email protected] | b76329d | 2013-06-11 04:15:08 | [diff] [blame] | 133 | virtual void SetLatencyInfoForInputEvent(const ui::LatencyInfo& latency_info) |
| 134 | OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 135 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 136 | // TopControlsManagerClient implementation. |
[email protected] | 59adb11 | 2013-04-09 04:48:44 | [diff] [blame] | 137 | virtual void DidChangeTopControlsPosition() OVERRIDE; |
| 138 | virtual bool HaveRootScrollLayer() const OVERRIDE; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 139 | |
[email protected] | 21c9dee7 | 2013-06-15 01:20:05 | [diff] [blame] | 140 | void StartScrollbarAnimation(); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 141 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 142 | struct CC_EXPORT FrameData : public RenderPassSink { |
| 143 | FrameData(); |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 144 | virtual ~FrameData(); |
[email protected] | 3480672 | 2013-08-09 23:51:21 | [diff] [blame] | 145 | scoped_ptr<base::Value> AsValue() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 146 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 147 | std::vector<gfx::Rect> occluding_screen_space_rects; |
| 148 | std::vector<gfx::Rect> non_occluding_screen_space_rects; |
| 149 | RenderPassList render_passes; |
| 150 | RenderPassIdHashMap render_passes_by_id; |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 151 | const LayerImplList* render_surface_layer_list; |
| 152 | LayerImplList will_draw_layers; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 153 | bool contains_incomplete_tile; |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 154 | bool has_no_damage; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 155 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 156 | // RenderPassSink implementation. |
| 157 | virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; |
| 158 | }; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 159 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 160 | virtual void BeginCommit(); |
| 161 | virtual void CommitComplete(); |
| 162 | virtual void Animate(base::TimeTicks monotonic_time, |
| 163 | base::Time wall_clock_time); |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 164 | virtual void UpdateAnimationState(bool start_ready_animations); |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 165 | void MainThreadHasStoppedFlinging(); |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 166 | void UpdateBackgroundAnimateTicking(bool should_background_tick); |
[email protected] | b9d4a36 | 2013-04-23 05:36:27 | [diff] [blame] | 167 | void SetViewportDamage(gfx::Rect damage_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 168 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 169 | virtual void ManageTiles(); |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 170 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 171 | // Returns false if problems occured preparing the frame, and we should try |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 172 | // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 173 | // must also be called, regardless of whether DrawLayers is called between the |
| 174 | // two. |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 175 | virtual bool PrepareToDraw(FrameData* frame, |
| 176 | gfx::Rect device_viewport_damage_rect); |
[email protected] | f0c2a24 | 2013-03-15 19:34:52 | [diff] [blame] | 177 | virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 178 | // Must be called if and only if PrepareToDraw was called. |
| 179 | void DidDrawAllLayers(const FrameData& frame); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 180 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 181 | const LayerTreeSettings& settings() const { return settings_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 182 | |
[email protected] | 0309ba5e0 | 2013-06-26 04:11:08 | [diff] [blame] | 183 | // Evict all textures by enforcing a memory policy with an allocation of 0. |
| 184 | void EvictTexturesForTesting(); |
| 185 | |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 186 | // When blocking, this prevents client_->NotifyReadyToActivate() from being |
| 187 | // called. When disabled, it calls client_->NotifyReadyToActivate() |
| 188 | // immediately if any notifications had been blocked while blocking. |
| 189 | virtual void BlockNotifyReadyToActivateForTesting(bool block); |
| 190 | |
[email protected] | 425e533 | 2013-09-21 04:10:03 | [diff] [blame] | 191 | // This allows us to inject DidInitializeVisibleTile events for testing. |
| 192 | void DidInitializeVisibleTileForTesting(); |
| 193 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 194 | bool device_viewport_valid_for_tile_management() const { |
| 195 | return device_viewport_valid_for_tile_management_; |
| 196 | } |
| 197 | |
| 198 | // Viewport size in draw space: this size is in physical pixels and is used |
| 199 | // for draw properties, tilings, quads and render passes. |
| 200 | gfx::Size DrawViewportSize() const; |
| 201 | |
| 202 | // Viewport size for scrolling and fixed-position compensation. This value |
| 203 | // excludes the URL bar and non-overlay scrollbars and is in DIP (and |
| 204 | // invariant relative to page scale). |
| 205 | gfx::SizeF UnscaledScrollableViewportSize() const; |
| 206 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 207 | // RendererClient implementation |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 208 | |
| 209 | // Viewport rectangle and clip in nonflipped window space. These rects |
| 210 | // should only be used by Renderer subclasses to populate glViewport/glClip |
| 211 | // and their software-mode equivalents. |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 212 | virtual gfx::Rect DeviceViewport() const OVERRIDE; |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 213 | virtual gfx::Rect DeviceClip() const OVERRIDE; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 214 | virtual void SetFullRootLayerDamage() OVERRIDE; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 215 | virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE; |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 216 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 217 | // TileManagerClient implementation. |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 218 | virtual void NotifyReadyToActivate() OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 219 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 220 | // OutputSurfaceClient implementation. |
[email protected] | 2b154b2 | 2013-06-07 09:03:27 | [diff] [blame] | 221 | virtual bool DeferredInitialize( |
| 222 | scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; |
[email protected] | 50af3c2 | 2013-07-13 03:50:20 | [diff] [blame] | 223 | virtual void ReleaseGL() OVERRIDE; |
[email protected] | 1cd9f555 | 2013-04-26 04:22:03 | [diff] [blame] | 224 | virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE; |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 225 | virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE; |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 226 | virtual void SetExternalDrawConstraints( |
| 227 | const gfx::Transform& transform, |
| 228 | gfx::Rect viewport, |
| 229 | gfx::Rect clip, |
| 230 | bool valid_for_tile_management) OVERRIDE; |
[email protected] | 049fc7a | 2013-06-18 12:32:35 | [diff] [blame] | 231 | virtual void DidLoseOutputSurface() OVERRIDE; |
[email protected] | 4d7e46a | 2013-11-08 05:33:40 | [diff] [blame^] | 232 | virtual void DidSwapBuffers() OVERRIDE; |
[email protected] | a7335e0b | 2013-09-18 09:34:51 | [diff] [blame] | 233 | virtual void OnSwapBuffersComplete() OVERRIDE; |
| 234 | virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE; |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 235 | virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
[email protected] | 5f07afc | 2013-07-19 05:17:18 | [diff] [blame] | 236 | virtual void SetTreeActivationCallback(const base::Closure& callback) |
| 237 | OVERRIDE; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 238 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 239 | // Called from LayerTreeImpl. |
| 240 | void OnCanDrawStateChangedForTree(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 241 | |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 242 | // Implementation. |
[email protected] | 6133cc23 | 2013-07-30 18:47:07 | [diff] [blame] | 243 | bool CanDraw() const; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 244 | OutputSurface* output_surface() const { return output_surface_.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 245 | |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 246 | void SetOffscreenContextProvider( |
| 247 | const scoped_refptr<ContextProvider>& offscreen_context_provider); |
| 248 | ContextProvider* offscreen_context_provider() const { |
| 249 | return offscreen_context_provider_.get(); |
| 250 | } |
| 251 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 252 | std::string LayerTreeAsJson() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 253 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 254 | void FinishAllRendering(); |
| 255 | int SourceAnimationFrameNumber() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 256 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 257 | virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface); |
| 258 | bool IsContextLost(); |
| 259 | TileManager* tile_manager() { return tile_manager_.get(); } |
| 260 | Renderer* renderer() { return renderer_.get(); } |
| 261 | const RendererCapabilities& GetRendererCapabilities() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 262 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 263 | virtual bool SwapBuffers(const FrameData& frame); |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 264 | void SetNeedsBeginImplFrame(bool enable); |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 265 | void DidModifyTilePriorities(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 266 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 267 | void Readback(void* pixels, gfx::Rect rect_in_device_viewport); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 268 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 269 | LayerTreeImpl* active_tree() { return active_tree_.get(); } |
| 270 | const LayerTreeImpl* active_tree() const { return active_tree_.get(); } |
| 271 | LayerTreeImpl* pending_tree() { return pending_tree_.get(); } |
| 272 | const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } |
| 273 | const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } |
[email protected] | 2f0d92f | 2013-06-11 04:07:20 | [diff] [blame] | 274 | virtual void CreatePendingTree(); |
[email protected] | 1e212c9bb | 2013-09-07 04:32:14 | [diff] [blame] | 275 | virtual void UpdateVisibleTiles(); |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 276 | virtual void ActivatePendingTree(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 277 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 278 | // Shortcuts to layers on the active tree. |
| 279 | LayerImpl* RootLayer() const; |
| 280 | LayerImpl* RootScrollLayer() const; |
| 281 | LayerImpl* CurrentlyScrollingLayer() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 282 | |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 283 | int scroll_layer_id_when_mouse_over_scrollbar() { |
| 284 | return scroll_layer_id_when_mouse_over_scrollbar_; |
| 285 | } |
| 286 | |
[email protected] | 251699b | 2013-10-09 00:21:26 | [diff] [blame] | 287 | bool IsCurrentlyScrolling() const; |
| 288 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 289 | virtual void SetVisible(bool visible); |
| 290 | bool visible() const { return visible_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 291 | |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 292 | void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); } |
[email protected] | 59adb11 | 2013-04-09 04:48:44 | [diff] [blame] | 293 | void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); } |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 294 | |
[email protected] | 206a392 | 2013-05-17 06:34:12 | [diff] [blame] | 295 | ManagedMemoryPolicy ActualManagedMemoryPolicy() const; |
| 296 | |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 297 | size_t memory_allocation_limit_bytes() const; |
[email protected] | 990e050a | 2013-09-23 18:50:21 | [diff] [blame] | 298 | int memory_allocation_priority_cutoff() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 299 | |
[email protected] | 18ce5970 | 2013-04-09 04:58:40 | [diff] [blame] | 300 | void SetViewportSize(gfx::Size device_viewport_size); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 301 | |
[email protected] | d908376 | 2013-03-24 01:36:40 | [diff] [blame] | 302 | void SetOverdrawBottomHeight(float overdraw_bottom_height); |
| 303 | float overdraw_bottom_height() const { return overdraw_bottom_height_; } |
| 304 | |
[email protected] | 9f4f6a3 | 2013-09-04 21:35:12 | [diff] [blame] | 305 | void SetOverhangUIResource(UIResourceId overhang_ui_resource_id, |
| 306 | gfx::Size overhang_ui_resource_size); |
| 307 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 308 | void SetDeviceScaleFactor(float device_scale_factor); |
| 309 | float device_scale_factor() const { return device_scale_factor_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 310 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 311 | const gfx::Transform& DrawTransform() const; |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 312 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 313 | scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 314 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 315 | bool needs_animate_layers() const { |
| 316 | return !animation_registrar_->active_animation_controllers().empty(); |
| 317 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 318 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 319 | void SendManagedMemoryStats( |
| 320 | size_t memory_visible_bytes, |
| 321 | size_t memory_visible_and_nearby_bytes, |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 322 | size_t memory_use_bytes); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 323 | |
[email protected] | d7626ffd | 2013-03-29 00:17:42 | [diff] [blame] | 324 | void set_max_memory_needed_bytes(size_t bytes) { |
| 325 | max_memory_needed_bytes_ = bytes; |
| 326 | } |
| 327 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 328 | FrameRateCounter* fps_counter() { |
| 329 | return fps_counter_.get(); |
| 330 | } |
| 331 | PaintTimeCounter* paint_time_counter() { |
| 332 | return paint_time_counter_.get(); |
| 333 | } |
| 334 | MemoryHistory* memory_history() { |
| 335 | return memory_history_.get(); |
| 336 | } |
| 337 | DebugRectHistory* debug_rect_history() { |
| 338 | return debug_rect_history_.get(); |
| 339 | } |
| 340 | ResourceProvider* resource_provider() { |
| 341 | return resource_provider_.get(); |
| 342 | } |
| 343 | TopControlsManager* top_controls_manager() { |
| 344 | return top_controls_manager_.get(); |
| 345 | } |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 346 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 347 | Proxy* proxy() const { return proxy_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 348 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 349 | AnimationRegistrar* animation_registrar() const { |
| 350 | return animation_registrar_.get(); |
| 351 | } |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 352 | |
[email protected] | 6e7fdeb | 2013-07-09 14:28:38 | [diff] [blame] | 353 | void SetDebugState(const LayerTreeDebugState& new_debug_state); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 354 | const LayerTreeDebugState& debug_state() const { return debug_state_; } |
[email protected] | f511afb | 2012-11-30 01:55:20 | [diff] [blame] | 355 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 356 | class CC_EXPORT CullRenderPassesWithNoQuads { |
| 357 | public: |
| 358 | bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad, |
| 359 | const FrameData& frame) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 360 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 361 | // Iterates in draw order, so that when a surface is removed, and its |
| 362 | // target becomes empty, then its target can be removed also. |
| 363 | size_t RenderPassListBegin(const RenderPassList& list) const { return 0; } |
| 364 | size_t RenderPassListEnd(const RenderPassList& list) const { |
| 365 | return list.size(); |
| 366 | } |
| 367 | size_t RenderPassListNext(size_t it) const { return it + 1; } |
| 368 | }; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 369 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 370 | template <typename RenderPassCuller> |
| 371 | static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 372 | |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 373 | gfx::Vector2dF accumulated_root_overscroll() const { |
| 374 | return accumulated_root_overscroll_; |
| 375 | } |
| 376 | gfx::Vector2dF current_fling_velocity() const { |
| 377 | return current_fling_velocity_; |
| 378 | } |
| 379 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 380 | bool pinch_gesture_active() const { return pinch_gesture_active_; } |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 381 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 382 | void SetTreePriority(TreePriority priority); |
[email protected] | 362f1e8b | 2013-01-21 16:54:30 | [diff] [blame] | 383 | |
[email protected] | 8347d69 | 2013-05-17 23:22:38 | [diff] [blame] | 384 | void ResetCurrentFrameTimeForNextFrame(); |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 385 | virtual base::TimeTicks CurrentFrameTimeTicks(); |
[email protected] | fb7425a | 2013-04-22 16:28:55 | [diff] [blame] | 386 | base::Time CurrentFrameTime(); |
[email protected] | 829ad97 | 2013-01-28 23:36:10 | [diff] [blame] | 387 | |
[email protected] | 21c9dee7 | 2013-06-15 01:20:05 | [diff] [blame] | 388 | virtual base::TimeTicks CurrentPhysicalTimeTicks() const; |
| 389 | |
[email protected] | 3480672 | 2013-08-09 23:51:21 | [diff] [blame] | 390 | scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } |
| 391 | scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 392 | scoped_ptr<base::Value> ActivationStateAsValue() const; |
[email protected] | 131a0c2 | 2013-02-12 18:31:08 | [diff] [blame] | 393 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 394 | bool page_scale_animation_active() const { return !!page_scale_animation_; } |
[email protected] | 498ddd0 | 2013-02-28 23:59:25 | [diff] [blame] | 395 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 396 | virtual void CreateUIResource(UIResourceId uid, |
| 397 | const UIResourceBitmap& bitmap); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 398 | // Deletes a UI resource. May safely be called more than once. |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 399 | virtual void DeleteUIResource(UIResourceId uid); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 400 | void EvictAllUIResources(); |
| 401 | bool EvictedUIResourcesExist() const; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 402 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 403 | virtual ResourceProvider::ResourceId ResourceIdForUIResource( |
| 404 | UIResourceId uid) const; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 405 | |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 406 | virtual bool IsUIResourceOpaque(UIResourceId uid) const; |
| 407 | |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 408 | struct UIResourceData { |
| 409 | ResourceProvider::ResourceId resource_id; |
| 410 | gfx::Size size; |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 411 | bool opaque; |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 412 | }; |
| 413 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 414 | protected: |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 415 | LayerTreeHostImpl( |
| 416 | const LayerTreeSettings& settings, |
| 417 | LayerTreeHostImplClient* client, |
| 418 | Proxy* proxy, |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 419 | RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 420 | SharedBitmapManager* manager); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 421 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 422 | // Virtual for testing. |
| 423 | virtual void AnimateLayers(base::TimeTicks monotonic_time, |
| 424 | base::Time wall_clock_time); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 425 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 426 | // Virtual for testing. |
| 427 | virtual base::TimeDelta LowFrequencyAnimationInterval() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 428 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 429 | const AnimationRegistrar::AnimationControllerMap& |
| 430 | active_animation_controllers() const { |
| 431 | return animation_registrar_->active_animation_controllers(); |
| 432 | } |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 433 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 434 | bool manage_tiles_needed() const { return tile_priorities_dirty_; } |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 435 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 436 | LayerTreeHostImplClient* client_; |
| 437 | Proxy* proxy_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 438 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 439 | private: |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 440 | void CreateAndSetRenderer( |
| 441 | OutputSurface* output_surface, |
| 442 | ResourceProvider* resource_provider, |
| 443 | bool skip_gl_renderer); |
[email protected] | 50af3c2 | 2013-07-13 03:50:20 | [diff] [blame] | 444 | void CreateAndSetTileManager(ResourceProvider* resource_provider, |
[email protected] | b6eb8e33 | 2013-09-10 00:51:01 | [diff] [blame] | 445 | ContextProvider* context_provider, |
[email protected] | 50af3c2 | 2013-07-13 03:50:20 | [diff] [blame] | 446 | bool using_map_image); |
[email protected] | 5064464 | 2013-06-20 13:58:55 | [diff] [blame] | 447 | void ReleaseTreeResources(); |
| 448 | void EnforceZeroBudget(bool zero_budget); |
[email protected] | 2b154b2 | 2013-06-07 09:03:27 | [diff] [blame] | 449 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 450 | void AnimatePageScale(base::TimeTicks monotonic_time); |
| 451 | void AnimateScrollbars(base::TimeTicks monotonic_time); |
[email protected] | ffb2720f | 2013-03-15 19:18:37 | [diff] [blame] | 452 | void AnimateTopControls(base::TimeTicks monotonic_time); |
[email protected] | 2d69299 | 2012-12-19 01:19:32 | [diff] [blame] | 453 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 454 | gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 455 | LayerImpl* layer_impl, |
| 456 | float scale_from_viewport_to_screen_space, |
| 457 | gfx::PointF viewport_point, |
| 458 | gfx::Vector2dF viewport_delta); |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 459 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 460 | void UpdateMaxScrollOffset(); |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 461 | void TrackDamageForAllSurfaces( |
| 462 | LayerImpl* root_draw_layer, |
| 463 | const LayerImplList& render_surface_layer_list); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 464 | |
[email protected] | 8be1a9bf | 2013-05-01 03:45:19 | [diff] [blame] | 465 | void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy); |
| 466 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 467 | // Returns false if the frame should not be displayed. This function should |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 468 | // only be called from PrepareToDraw, as DidDrawAllLayers must be called |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 469 | // if this helper function is called. |
| 470 | bool CalculateRenderPasses(FrameData* frame); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 471 | |
[email protected] | 5064464 | 2013-06-20 13:58:55 | [diff] [blame] | 472 | void SendReleaseResourcesRecursive(LayerImpl* current); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 473 | bool EnsureRenderSurfaceLayerList(); |
| 474 | void ClearCurrentlyScrollingLayer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 475 | |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 476 | bool HandleMouseOverScrollbar(LayerImpl* layer_impl, |
| 477 | gfx::PointF device_viewport_point); |
| 478 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 479 | void AnimateScrollbarsRecursive(LayerImpl* layer, |
| 480 | base::TimeTicks time); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 481 | |
[email protected] | 21c9dee7 | 2013-06-15 01:20:05 | [diff] [blame] | 482 | void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) const; |
| 483 | |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 484 | LayerImpl* FindScrollLayerForDeviceViewportPoint( |
| 485 | gfx::PointF device_viewport_point, |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 486 | InputHandler::ScrollInputType type, |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 487 | LayerImpl* layer_hit_by_point, |
[email protected] | 59a7d55 | 2013-10-22 03:36:43 | [diff] [blame] | 488 | bool* scroll_on_main_thread) const; |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 489 | float DeviceSpaceDistanceToLayer(gfx::PointF device_viewport_point, |
| 490 | LayerImpl* layer_impl); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 491 | void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time); |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 492 | void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy, |
| 493 | bool zero_budget); |
[email protected] | 0309ba5e0 | 2013-06-26 04:11:08 | [diff] [blame] | 494 | void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 495 | |
[email protected] | 8bb6cfa | 2013-07-23 00:11:19 | [diff] [blame] | 496 | void DidInitializeVisibleTile(); |
| 497 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 498 | void MarkUIResourceNotEvicted(UIResourceId uid); |
| 499 | |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 500 | typedef base::hash_map<UIResourceId, UIResourceData> |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 501 | UIResourceMap; |
| 502 | UIResourceMap ui_resource_map_; |
| 503 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 504 | // Resources that were evicted by EvictAllUIResources. Resources are removed |
| 505 | // from this when they are touched by a create or destroy from the UI resource |
| 506 | // request queue. |
| 507 | std::set<UIResourceId> evicted_ui_resources_; |
| 508 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 509 | scoped_ptr<OutputSurface> output_surface_; |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 510 | scoped_refptr<ContextProvider> offscreen_context_provider_; |
[email protected] | fbe89f7 | 2013-05-21 07:24:24 | [diff] [blame] | 511 | |
| 512 | // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile- |
| 513 | // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice(). |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 514 | scoped_ptr<ResourceProvider> resource_provider_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 515 | scoped_ptr<TileManager> tile_manager_; |
[email protected] | fbe89f7 | 2013-05-21 07:24:24 | [diff] [blame] | 516 | scoped_ptr<Renderer> renderer_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 517 | |
[email protected] | 1bcced2 | 2013-09-24 13:51:19 | [diff] [blame] | 518 | GlobalStateThatImpactsTilePriority global_tile_state_; |
| 519 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 520 | // Tree currently being drawn. |
| 521 | scoped_ptr<LayerTreeImpl> active_tree_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 522 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 523 | // In impl-side painting mode, tree with possibly incomplete rasterized |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 524 | // content. May be promoted to active by ActivatePendingTree(). |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 525 | scoped_ptr<LayerTreeImpl> pending_tree_; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 526 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 527 | // In impl-side painting mode, inert tree with layers that can be recycled |
| 528 | // by the next sync from the main thread. |
| 529 | scoped_ptr<LayerTreeImpl> recycle_tree_; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 530 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 531 | InputHandlerClient* input_handler_client_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 532 | bool did_lock_scrolling_layer_; |
| 533 | bool should_bubble_scrolls_; |
[email protected] | d41d7cb9 | 2013-10-15 16:08:09 | [diff] [blame] | 534 | bool last_scroll_did_bubble_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 535 | bool wheel_scrolling_; |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 536 | int scroll_layer_id_when_mouse_over_scrollbar_; |
[email protected] | a23451e | 2013-06-07 20:58:26 | [diff] [blame] | 537 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 538 | bool tile_priorities_dirty_; |
[email protected] | a23451e | 2013-06-07 20:58:26 | [diff] [blame] | 539 | |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 540 | // The optional delegate for the root layer scroll offset. |
| 541 | LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 542 | LayerTreeSettings settings_; |
| 543 | LayerTreeDebugState debug_state_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 544 | bool visible_; |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 545 | ManagedMemoryPolicy cached_managed_memory_policy_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 546 | |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 547 | gfx::Vector2dF accumulated_root_overscroll_; |
[email protected] | 6e921bd | 2013-04-29 21:10:20 | [diff] [blame] | 548 | gfx::Vector2dF current_fling_velocity_; |
| 549 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 550 | bool pinch_gesture_active_; |
[email protected] | 2fa342b8 | 2013-09-24 03:19:13 | [diff] [blame] | 551 | bool pinch_gesture_end_should_clear_scrolling_layer_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 552 | gfx::Point previous_pinch_anchor_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 553 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 554 | // This is set by AnimateLayers() and used by UpdateAnimationState() |
| 555 | // when sending animation events to the main thread. |
| 556 | base::Time last_animation_time_; |
[email protected] | 6ad55bb2 | 2013-02-08 21:34:33 | [diff] [blame] | 557 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 558 | scoped_ptr<TopControlsManager> top_controls_manager_; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 559 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 560 | scoped_ptr<PageScaleAnimation> page_scale_animation_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 561 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 562 | // This is used for ticking animations slowly when hidden. |
| 563 | scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 564 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 565 | scoped_ptr<FrameRateCounter> fps_counter_; |
| 566 | scoped_ptr<PaintTimeCounter> paint_time_counter_; |
| 567 | scoped_ptr<MemoryHistory> memory_history_; |
| 568 | scoped_ptr<DebugRectHistory> debug_rect_history_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 569 | |
[email protected] | ea468c6c | 2013-09-10 08:25:11 | [diff] [blame] | 570 | scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; |
| 571 | |
[email protected] | d7626ffd | 2013-03-29 00:17:42 | [diff] [blame] | 572 | // The maximum memory that would be used by the prioritized resource |
| 573 | // manager, if there were no limit on memory usage. |
| 574 | size_t max_memory_needed_bytes_; |
| 575 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 576 | size_t last_sent_memory_visible_bytes_; |
| 577 | size_t last_sent_memory_visible_and_nearby_bytes_; |
| 578 | size_t last_sent_memory_use_bytes_; |
[email protected] | 5064464 | 2013-06-20 13:58:55 | [diff] [blame] | 579 | bool zero_budget_; |
[email protected] | d3afa11 | 2012-12-08 06:24:28 | [diff] [blame] | 580 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 581 | // Viewport size passed in from the main thread, in physical pixels. This |
| 582 | // value is the default size for all concepts of physical viewport (draw |
| 583 | // viewport, scrolling viewport and device viewport), but it can be |
| 584 | // overridden. |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 585 | gfx::Size device_viewport_size_; |
| 586 | |
| 587 | // Conversion factor from CSS pixels to physical pixels when |
| 588 | // pageScaleFactor=1. |
| 589 | float device_scale_factor_; |
| 590 | |
[email protected] | 9f4f6a3 | 2013-09-04 21:35:12 | [diff] [blame] | 591 | // UI resource to use for drawing overhang gutters. |
| 592 | UIResourceId overhang_ui_resource_id_; |
| 593 | gfx::Size overhang_ui_resource_size_; |
| 594 | |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 595 | // Vertical amount of the viewport size that's known to covered by a |
| 596 | // browser-side UI element, such as an on-screen-keyboard. This affects |
| 597 | // scrollable size since we want to still be able to scroll to the bottom of |
| 598 | // the page when the keyboard is up. |
| 599 | float overdraw_bottom_height_; |
| 600 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 601 | // Optional top-level constraints that can be set by the OutputSurface. |
| 602 | // - external_transform_ applies a transform above the root layer |
| 603 | // - external_viewport_ is used DrawProperties, tile management and |
| 604 | // glViewport/window projection matrix. |
| 605 | // - external_clip_ specifies a top-level clip rect |
| 606 | // - external_stencil_test_enabled_ tells CC to respect existing stencil bits |
| 607 | // (When these are specified, device_viewport_size_ remains used only for |
| 608 | // scrollable size.) |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 609 | gfx::Transform external_transform_; |
| 610 | gfx::Rect external_viewport_; |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 611 | gfx::Rect external_clip_; |
| 612 | bool device_viewport_valid_for_tile_management_; |
[email protected] | c32a196 | 2013-07-30 19:41:17 | [diff] [blame] | 613 | bool external_stencil_test_enabled_; |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 614 | |
[email protected] | 878705be | 2013-04-15 22:44:02 | [diff] [blame] | 615 | gfx::Rect viewport_damage_rect_; |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 616 | |
[email protected] | fb7425a | 2013-04-22 16:28:55 | [diff] [blame] | 617 | base::TimeTicks current_frame_timeticks_; |
| 618 | base::Time current_frame_time_; |
[email protected] | 829ad97 | 2013-01-28 23:36:10 | [diff] [blame] | 619 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 620 | scoped_ptr<AnimationRegistrar> animation_registrar_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 621 | |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 622 | RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
| 623 | |
[email protected] | 8bb6cfa | 2013-07-23 00:11:19 | [diff] [blame] | 624 | bool need_to_update_visible_tiles_before_draw_; |
[email protected] | 39643fb | 2013-07-09 17:28:19 | [diff] [blame] | 625 | |
[email protected] | 5f07afc | 2013-07-19 05:17:18 | [diff] [blame] | 626 | // Optional callback to notify of new tree activations. |
[email protected] | 2022c67 | 2013-07-23 19:55:26 | [diff] [blame] | 627 | base::Closure tree_activation_callback_; |
[email protected] | 5f07afc | 2013-07-19 05:17:18 | [diff] [blame] | 628 | |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 629 | SharedBitmapManager* shared_bitmap_manager_; |
| 630 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 631 | DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 632 | }; |
| 633 | |
[email protected] | 0023e8b | 2012-10-15 12:52:45 | [diff] [blame] | 634 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 635 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 636 | #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |