blob: 57221b2fdc084e3e9ce3fb4d9923bae653773d1a [file] [log] [blame]
[email protected]cd57cc5a2012-10-12 22:43:411// Copyright 2011 The Chromium Authors. All rights reserved.
[email protected]0fb25002012-10-12 07:20:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]cd57cc5a2012-10-12 22:43:414
[email protected]556fd292013-03-18 08:03:045#ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_
6#define CC_TREES_LAYER_TREE_HOST_IMPL_H_
[email protected]cd57cc5a2012-10-12 22:43:417
[email protected]bf691c22013-03-26 21:15:068#include <string>
9#include <vector>
10
[email protected]c4040a522012-10-21 15:01:4011#include "base/basictypes.h"
12#include "base/memory/scoped_ptr.h"
13#include "base/time.h"
[email protected]95e4e1a02013-03-18 07:09:0914#include "cc/animation/animation_events.h"
15#include "cc/animation/animation_registrar.h"
[email protected]681ccff2013-03-18 06:13:5216#include "cc/base/cc_export.h"
[email protected]e4c3c87a2013-04-22 02:28:4017#include "cc/debug/latency_info.h"
[email protected]3052b10f2013-03-18 07:41:2118#include "cc/input/input_handler.h"
[email protected]1960a712013-04-30 17:06:4719#include "cc/input/layer_scroll_offset_delegate.h"
[email protected]3052b10f2013-03-18 07:41:2120#include "cc/input/top_controls_manager_client.h"
[email protected]50761e92013-03-29 20:51:2821#include "cc/layers/layer_lists.h"
[email protected]cc3cfaa2013-03-18 09:05:5222#include "cc/layers/render_pass_sink.h"
[email protected]7f0d825f2013-03-18 07:24:3023#include "cc/output/output_surface_client.h"
24#include "cc/output/renderer.h"
[email protected]89e8267a2013-03-18 07:50:5625#include "cc/quads/render_pass.h"
[email protected]e12dd0e2013-03-18 08:24:4026#include "cc/resources/tile_manager.h"
[email protected]b9dcf43a2013-01-09 00:15:2927#include "skia/ext/refptr.h"
[email protected]ddf9df82012-10-16 06:52:4628#include "third_party/skia/include/core/SkColor.h"
[email protected]b9dcf43a2013-01-09 00:15:2929#include "third_party/skia/include/core/SkPicture.h"
[email protected]167ed9d52012-10-31 20:47:5830#include "ui/gfx/rect.h"
[email protected]cd57cc5a2012-10-12 22:43:4131
32namespace cc {
33
[email protected]96baf3e2012-10-22 23:09:5534class CompletionEvent;
[email protected]bf189f62012-12-18 03:42:1135class CompositorFrameMetadata;
[email protected]96baf3e2012-10-22 23:09:5536class DebugRectHistory;
37class FrameRateCounter;
[email protected]96baf3e2012-10-22 23:09:5538class LayerImpl;
39class LayerTreeHostImplTimeSourceAdapter;
[email protected]8bef40572012-12-11 21:38:0840class LayerTreeImpl;
[email protected]96baf3e2012-10-22 23:09:5541class PageScaleAnimation;
[email protected]0edbfbe9f2013-01-17 03:33:0342class PaintTimeCounter;
[email protected]1191d9d2013-02-02 06:00:3343class MemoryHistory;
[email protected]372bad5f2013-03-21 16:38:4344class RenderingStatsInstrumentation;
[email protected]96baf3e2012-10-22 23:09:5545class RenderPassDrawQuad;
46class ResourceProvider;
[email protected]3ba4cae2013-01-16 03:58:3847class TopControlsManager;
[email protected]cd57cc5a2012-10-12 22:43:4148struct RendererCapabilities;
[email protected]cd57cc5a2012-10-12 22:43:4149
[email protected]96baf3e2012-10-22 23:09:5550// LayerTreeHost->Proxy callback interface.
51class LayerTreeHostImplClient {
[email protected]c1bb5af2013-03-13 19:06:2752 public:
53 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
54 virtual void OnSwapBuffersCompleteOnImplThread() = 0;
55 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
56 base::TimeDelta interval) = 0;
[email protected]c8cbae72013-05-23 10:45:0357 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time) = 0;
[email protected]c1bb5af2013-03-13 19:06:2758 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
59 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) = 0;
60 virtual void SetNeedsRedrawOnImplThread() = 0;
[email protected]1cd9f5552013-04-26 04:22:0361 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) = 0;
[email protected]86126792013-03-16 20:07:5462 virtual void DidInitializeVisibleTileOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:2763 virtual void SetNeedsCommitOnImplThread() = 0;
64 virtual void SetNeedsManageTilesOnImplThread() = 0;
65 virtual void PostAnimationEventsToMainThreadOnImplThread(
66 scoped_ptr<AnimationEventsVector> events,
67 base::Time wall_clock_time) = 0;
68 // Returns true if resources were deleted by this call.
69 virtual bool ReduceContentsTextureMemoryOnImplThread(
70 size_t limit_bytes,
71 int priority_cutoff) = 0;
72 virtual void ReduceWastedContentsTextureMemoryOnImplThread() = 0;
73 virtual void SendManagedMemoryStats() = 0;
74 virtual bool IsInsideDraw() = 0;
75 virtual void RenewTreePriority() = 0;
[email protected]0fc818e2013-03-18 06:45:2076 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
[email protected]c8cbae72013-05-23 10:45:0377 virtual void DidReceiveLastInputEventForBeginFrameOnImplThread(
78 base::TimeTicks frame_time) = 0;
[email protected]2a61ad52013-05-13 14:01:2979 virtual void DidActivatePendingTree() = 0;
[email protected]bf691c22013-03-26 21:15:0680
81 protected:
82 virtual ~LayerTreeHostImplClient() {}
[email protected]cd57cc5a2012-10-12 22:43:4183};
84
[email protected]c1bb5af2013-03-13 19:06:2785// LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
86// state.
[email protected]200a9c062013-05-20 04:34:3787class CC_EXPORT LayerTreeHostImpl
88 : public InputHandler,
89 public RendererClient,
90 public TileManagerClient,
91 public OutputSurfaceClient,
92 public TopControlsManagerClient,
93 public base::SupportsWeakPtr<LayerTreeHostImpl> {
[email protected]e216fef02013-03-20 22:56:1094 public:
[email protected]c1bb5af2013-03-13 19:06:2795 static scoped_ptr<LayerTreeHostImpl> Create(
96 const LayerTreeSettings& settings,
97 LayerTreeHostImplClient* client,
[email protected]372bad5f2013-03-21 16:38:4398 Proxy* proxy,
99 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:27100 virtual ~LayerTreeHostImpl();
[email protected]cd57cc5a2012-10-12 22:43:41101
[email protected]5ff3c9782013-04-29 17:35:12102 // InputHandler implementation
[email protected]200a9c062013-05-20 04:34:37103 virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
[email protected]5ff3c9782013-04-29 17:35:12104 virtual InputHandler::ScrollStatus ScrollBegin(
[email protected]c1bb5af2013-03-13 19:06:27105 gfx::Point viewport_point,
[email protected]5ff3c9782013-04-29 17:35:12106 InputHandler::ScrollInputType type) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27107 virtual bool ScrollBy(gfx::Point viewport_point,
108 gfx::Vector2dF scroll_delta) OVERRIDE;
[email protected]c28df4c12013-05-22 17:36:49109 virtual bool ScrollVerticallyByPage(gfx::Point viewport_point,
110 ScrollDirection direction) OVERRIDE;
[email protected]1960a712013-04-30 17:06:47111 virtual void SetRootLayerScrollOffsetDelegate(
112 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE;
113 virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27114 virtual void ScrollEnd() OVERRIDE;
[email protected]5ff3c9782013-04-29 17:35:12115 virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
[email protected]6e921bd2013-04-29 21:10:20116 virtual void NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27117 virtual void PinchGestureBegin() OVERRIDE;
118 virtual void PinchGestureUpdate(float magnify_delta,
119 gfx::Point anchor) OVERRIDE;
120 virtual void PinchGestureEnd() OVERRIDE;
121 virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
122 bool anchor_point,
123 float page_scale,
124 base::TimeTicks start_time,
125 base::TimeDelta duration) OVERRIDE;
126 virtual void ScheduleAnimation() OVERRIDE;
127 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
[email protected]c8cbae72013-05-23 10:45:03128 virtual void DidReceiveLastInputEventForBeginFrame(
[email protected]ef915f532013-04-22 20:56:32129 base::TimeTicks frame_time) OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41130
[email protected]c1bb5af2013-03-13 19:06:27131 // TopControlsManagerClient implementation.
[email protected]59adb112013-04-09 04:48:44132 virtual void DidChangeTopControlsPosition() OVERRIDE;
133 virtual bool HaveRootScrollLayer() const OVERRIDE;
[email protected]3ba4cae2013-01-16 03:58:38134
[email protected]0fc818e2013-03-18 06:45:20135 void StartScrollbarAnimation(base::TimeTicks now);
136
[email protected]c1bb5af2013-03-13 19:06:27137 struct CC_EXPORT FrameData : public RenderPassSink {
138 FrameData();
[email protected]ca2902e92013-03-28 01:45:35139 virtual ~FrameData();
[email protected]cd57cc5a2012-10-12 22:43:41140
[email protected]c1bb5af2013-03-13 19:06:27141 std::vector<gfx::Rect> occluding_screen_space_rects;
142 std::vector<gfx::Rect> non_occluding_screen_space_rects;
143 RenderPassList render_passes;
144 RenderPassIdHashMap render_passes_by_id;
[email protected]50761e92013-03-29 20:51:28145 const LayerImplList* render_surface_layer_list;
146 LayerImplList will_draw_layers;
[email protected]c1bb5af2013-03-13 19:06:27147 bool contains_incomplete_tile;
[email protected]e0341352013-04-06 05:01:20148 bool has_no_damage;
[email protected]e4c3c87a2013-04-22 02:28:40149 LatencyInfo latency_info;
[email protected]cd57cc5a2012-10-12 22:43:41150
[email protected]c1bb5af2013-03-13 19:06:27151 // RenderPassSink implementation.
152 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
153 };
[email protected]cd57cc5a2012-10-12 22:43:41154
[email protected]c1bb5af2013-03-13 19:06:27155 virtual void BeginCommit();
156 virtual void CommitComplete();
157 virtual void Animate(base::TimeTicks monotonic_time,
158 base::Time wall_clock_time);
[email protected]3d9f7432013-04-06 00:35:18159 virtual void UpdateAnimationState(bool start_ready_animations);
[email protected]200a9c062013-05-20 04:34:37160 void MainThreadHasStoppedFlinging();
[email protected]3d9f7432013-04-06 00:35:18161 void UpdateBackgroundAnimateTicking(bool should_background_tick);
[email protected]b9d4a362013-04-23 05:36:27162 void SetViewportDamage(gfx::Rect damage_rect);
[email protected]cd57cc5a2012-10-12 22:43:41163
[email protected]c1bb5af2013-03-13 19:06:27164 void ManageTiles();
[email protected]8947cbe2012-11-28 05:27:43165
[email protected]c1bb5af2013-03-13 19:06:27166 // Returns false if problems occured preparing the frame, and we should try
[email protected]ed511b8d2013-03-25 03:29:29167 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
[email protected]c1bb5af2013-03-13 19:06:27168 // must also be called, regardless of whether DrawLayers is called between the
169 // two.
[email protected]e0341352013-04-06 05:01:20170 virtual bool PrepareToDraw(FrameData* frame,
171 gfx::Rect device_viewport_damage_rect);
[email protected]f0c2a242013-03-15 19:34:52172 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
[email protected]c1bb5af2013-03-13 19:06:27173 // Must be called if and only if PrepareToDraw was called.
174 void DidDrawAllLayers(const FrameData& frame);
[email protected]cd57cc5a2012-10-12 22:43:41175
[email protected]c1bb5af2013-03-13 19:06:27176 const LayerTreeSettings& settings() const { return settings_; }
[email protected]cd57cc5a2012-10-12 22:43:41177
[email protected]ffb2720f2013-03-15 19:18:37178 // Returns the currently visible viewport size in DIP. This value excludes
179 // the URL bar and non-overlay scrollbars.
180 gfx::SizeF VisibleViewportSize() const;
181
[email protected]c1bb5af2013-03-13 19:06:27182 // RendererClient implementation
183 private:
184 virtual gfx::Size DeviceViewportSize() const OVERRIDE;
185 virtual const LayerTreeSettings& Settings() const OVERRIDE;
186 public:
187 virtual void DidLoseOutputSurface() OVERRIDE;
188 virtual void OnSwapBuffersComplete() OVERRIDE;
189 virtual void SetFullRootLayerDamage() OVERRIDE;
190 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
191 OVERRIDE;
192 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
193 OVERRIDE;
194 virtual bool HasImplThread() const OVERRIDE;
195 virtual bool ShouldClearRootRenderPass() const OVERRIDE;
196 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE;
[email protected]73673592013-04-03 22:14:32197 virtual bool AllowPartialSwap() const OVERRIDE;
[email protected]8947cbe2012-11-28 05:27:43198
[email protected]c1bb5af2013-03-13 19:06:27199 // TileManagerClient implementation.
200 virtual void ScheduleManageTiles() OVERRIDE;
[email protected]86126792013-03-16 20:07:54201 virtual void DidInitializeVisibleTile() OVERRIDE;
[email protected]fcb846d2013-05-22 01:42:36202 virtual bool ShouldForceTileUploadsRequiredForActivationToComplete() const
203 OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41204
[email protected]c1bb5af2013-03-13 19:06:27205 // OutputSurfaceClient implementation.
[email protected]1cd9f5552013-04-26 04:22:03206 virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27207 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
208 base::TimeDelta interval) OVERRIDE;
[email protected]c8cbae72013-05-23 10:45:03209 virtual void BeginFrame(base::TimeTicks frame_time)
210 OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27211 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
212 OVERRIDE;
[email protected]3b31c6ac2012-12-06 21:27:29213
[email protected]c1bb5af2013-03-13 19:06:27214 // Called from LayerTreeImpl.
215 void OnCanDrawStateChangedForTree();
[email protected]cd57cc5a2012-10-12 22:43:41216
[email protected]c1bb5af2013-03-13 19:06:27217 // Implementation
218 bool CanDraw();
219 OutputSurface* output_surface() const { return output_surface_.get(); }
[email protected]cd57cc5a2012-10-12 22:43:41220
[email protected]c1bb5af2013-03-13 19:06:27221 std::string LayerTreeAsText() const;
222 std::string LayerTreeAsJson() const;
[email protected]cd57cc5a2012-10-12 22:43:41223
[email protected]c1bb5af2013-03-13 19:06:27224 void FinishAllRendering();
225 int SourceAnimationFrameNumber() const;
[email protected]cd57cc5a2012-10-12 22:43:41226
[email protected]c1bb5af2013-03-13 19:06:27227 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
228 bool IsContextLost();
229 TileManager* tile_manager() { return tile_manager_.get(); }
230 Renderer* renderer() { return renderer_.get(); }
231 const RendererCapabilities& GetRendererCapabilities() const;
[email protected]cd57cc5a2012-10-12 22:43:41232
[email protected]e0341352013-04-06 05:01:20233 virtual bool SwapBuffers(const FrameData& frame);
[email protected]c8cbae72013-05-23 10:45:03234 void SetNeedsBeginFrame(bool enable);
[email protected]cd57cc5a2012-10-12 22:43:41235
[email protected]c1bb5af2013-03-13 19:06:27236 void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
[email protected]cd57cc5a2012-10-12 22:43:41237
[email protected]c1bb5af2013-03-13 19:06:27238 LayerTreeImpl* active_tree() { return active_tree_.get(); }
239 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
240 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
241 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
242 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
243 void CreatePendingTree();
244 void CheckForCompletedTileUploads();
245 virtual bool ActivatePendingTreeIfNeeded();
[email protected]cd57cc5a2012-10-12 22:43:41246
[email protected]c1bb5af2013-03-13 19:06:27247 // Shortcuts to layers on the active tree.
248 LayerImpl* RootLayer() const;
249 LayerImpl* RootScrollLayer() const;
250 LayerImpl* CurrentlyScrollingLayer() const;
[email protected]cd57cc5a2012-10-12 22:43:41251
[email protected]c1bb5af2013-03-13 19:06:27252 virtual void SetVisible(bool visible);
253 bool visible() const { return visible_; }
[email protected]cd57cc5a2012-10-12 22:43:41254
[email protected]d7eb8c72013-03-23 22:57:13255 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
[email protected]59adb112013-04-09 04:48:44256 void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); }
[email protected]d7eb8c72013-03-23 22:57:13257
[email protected]206a3922013-05-17 06:34:12258 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
259
[email protected]c1bb5af2013-03-13 19:06:27260 size_t memory_allocation_limit_bytes() const {
[email protected]46b8acc2013-03-19 22:38:35261 return managed_memory_policy_.bytes_limit_when_visible;
[email protected]c1bb5af2013-03-13 19:06:27262 }
[email protected]cd57cc5a2012-10-12 22:43:41263
[email protected]18ce59702013-04-09 04:58:40264 void SetViewportSize(gfx::Size device_viewport_size);
[email protected]c1bb5af2013-03-13 19:06:27265 gfx::Size device_viewport_size() const { return device_viewport_size_; }
[email protected]cd57cc5a2012-10-12 22:43:41266
[email protected]d9083762013-03-24 01:36:40267 void SetOverdrawBottomHeight(float overdraw_bottom_height);
268 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
269
[email protected]c1bb5af2013-03-13 19:06:27270 void SetDeviceScaleFactor(float device_scale_factor);
271 float device_scale_factor() const { return device_scale_factor_; }
[email protected]cd57cc5a2012-10-12 22:43:41272
[email protected]c1bb5af2013-03-13 19:06:27273 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
[email protected]cd57cc5a2012-10-12 22:43:41274
[email protected]c1bb5af2013-03-13 19:06:27275 bool needs_animate_layers() const {
276 return !animation_registrar_->active_animation_controllers().empty();
277 }
[email protected]cd57cc5a2012-10-12 22:43:41278
[email protected]c1bb5af2013-03-13 19:06:27279 void SendManagedMemoryStats(
280 size_t memory_visible_bytes,
281 size_t memory_visible_and_nearby_bytes,
[email protected]ed511b8d2013-03-25 03:29:29282 size_t memory_use_bytes);
[email protected]c1bb5af2013-03-13 19:06:27283
[email protected]d7626ffd2013-03-29 00:17:42284 void set_max_memory_needed_bytes(size_t bytes) {
285 max_memory_needed_bytes_ = bytes;
286 }
287
[email protected]c1bb5af2013-03-13 19:06:27288 FrameRateCounter* fps_counter() {
289 return fps_counter_.get();
290 }
291 PaintTimeCounter* paint_time_counter() {
292 return paint_time_counter_.get();
293 }
294 MemoryHistory* memory_history() {
295 return memory_history_.get();
296 }
297 DebugRectHistory* debug_rect_history() {
298 return debug_rect_history_.get();
299 }
300 ResourceProvider* resource_provider() {
301 return resource_provider_.get();
302 }
303 TopControlsManager* top_controls_manager() {
304 return top_controls_manager_.get();
305 }
[email protected]ff762fb2012-12-12 19:18:37306
[email protected]c1bb5af2013-03-13 19:06:27307 Proxy* proxy() const { return proxy_; }
[email protected]cd57cc5a2012-10-12 22:43:41308
[email protected]c1bb5af2013-03-13 19:06:27309 AnimationRegistrar* animation_registrar() const {
310 return animation_registrar_.get();
311 }
[email protected]de4afb5e2012-12-20 00:11:34312
[email protected]c1bb5af2013-03-13 19:06:27313 void SetDebugState(const LayerTreeDebugState& debug_state);
314 const LayerTreeDebugState& debug_state() const { return debug_state_; }
[email protected]f511afb2012-11-30 01:55:20315
[email protected]c1bb5af2013-03-13 19:06:27316 class CC_EXPORT CullRenderPassesWithCachedTextures {
317 public:
318 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
319 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41320
[email protected]c1bb5af2013-03-13 19:06:27321 // Iterates from the root first, in order to remove the surfaces closest
322 // to the root with cached textures, and all surfaces that draw into
323 // them.
324 size_t RenderPassListBegin(const RenderPassList& list) const {
325 return list.size() - 1;
326 }
327 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
328 size_t RenderPassListNext(size_t it) const { return it - 1; }
[email protected]cd57cc5a2012-10-12 22:43:41329
[email protected]bf691c22013-03-26 21:15:06330 explicit CullRenderPassesWithCachedTextures(Renderer* renderer)
[email protected]c1bb5af2013-03-13 19:06:27331 : renderer_(renderer) {}
332 private:
[email protected]bf691c22013-03-26 21:15:06333 Renderer* renderer_;
[email protected]c1bb5af2013-03-13 19:06:27334 };
[email protected]cd57cc5a2012-10-12 22:43:41335
[email protected]c1bb5af2013-03-13 19:06:27336 class CC_EXPORT CullRenderPassesWithNoQuads {
337 public:
338 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
339 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41340
[email protected]c1bb5af2013-03-13 19:06:27341 // Iterates in draw order, so that when a surface is removed, and its
342 // target becomes empty, then its target can be removed also.
343 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
344 size_t RenderPassListEnd(const RenderPassList& list) const {
345 return list.size();
346 }
347 size_t RenderPassListNext(size_t it) const { return it + 1; }
348 };
[email protected]cd57cc5a2012-10-12 22:43:41349
[email protected]c1bb5af2013-03-13 19:06:27350 template <typename RenderPassCuller>
351 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41352
[email protected]c1bb5af2013-03-13 19:06:27353 skia::RefPtr<SkPicture> CapturePicture();
[email protected]b9dcf43a2013-01-09 00:15:29354
[email protected]a2b5ded2013-05-20 21:32:53355 gfx::Vector2dF accumulated_root_overscroll() const {
356 return accumulated_root_overscroll_;
357 }
358 gfx::Vector2dF current_fling_velocity() const {
359 return current_fling_velocity_;
360 }
361
[email protected]c1bb5af2013-03-13 19:06:27362 bool pinch_gesture_active() const { return pinch_gesture_active_; }
[email protected]166db5c82013-01-09 23:54:31363
[email protected]c1bb5af2013-03-13 19:06:27364 void SetTreePriority(TreePriority priority);
[email protected]362f1e8b2013-01-21 16:54:30365
[email protected]8347d692013-05-17 23:22:38366 void ResetCurrentFrameTimeForNextFrame();
[email protected]fb7425a2013-04-22 16:28:55367 base::TimeTicks CurrentFrameTimeTicks();
368 base::Time CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10369
[email protected]c1bb5af2013-03-13 19:06:27370 scoped_ptr<base::Value> AsValue() const;
371 scoped_ptr<base::Value> ActivationStateAsValue() const;
[email protected]131a0c22013-02-12 18:31:08372
[email protected]c1bb5af2013-03-13 19:06:27373 bool page_scale_animation_active() const { return !!page_scale_animation_; }
[email protected]498ddd02013-02-28 23:59:25374
[email protected]c1bb5af2013-03-13 19:06:27375 protected:
[email protected]372bad5f2013-03-21 16:38:43376 LayerTreeHostImpl(
377 const LayerTreeSettings& settings,
378 LayerTreeHostImplClient* client,
379 Proxy* proxy,
380 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:27381 void ActivatePendingTree();
[email protected]cd57cc5a2012-10-12 22:43:41382
[email protected]c1bb5af2013-03-13 19:06:27383 // Virtual for testing.
384 virtual void AnimateLayers(base::TimeTicks monotonic_time,
385 base::Time wall_clock_time);
[email protected]cd57cc5a2012-10-12 22:43:41386
[email protected]c1bb5af2013-03-13 19:06:27387 // Virtual for testing.
388 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
[email protected]cd57cc5a2012-10-12 22:43:41389
[email protected]c1bb5af2013-03-13 19:06:27390 const AnimationRegistrar::AnimationControllerMap&
391 active_animation_controllers() const {
392 return animation_registrar_->active_animation_controllers();
393 }
[email protected]de4afb5e2012-12-20 00:11:34394
[email protected]c1bb5af2013-03-13 19:06:27395 LayerTreeHostImplClient* client_;
396 Proxy* proxy_;
[email protected]cd57cc5a2012-10-12 22:43:41397
[email protected]c1bb5af2013-03-13 19:06:27398 private:
399 void AnimatePageScale(base::TimeTicks monotonic_time);
400 void AnimateScrollbars(base::TimeTicks monotonic_time);
[email protected]ffb2720f2013-03-15 19:18:37401 void AnimateTopControls(base::TimeTicks monotonic_time);
[email protected]2d692992012-12-19 01:19:32402
[email protected]c1bb5af2013-03-13 19:06:27403 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
[email protected]ed511b8d2013-03-25 03:29:29404 LayerImpl* layer_impl,
405 float scale_from_viewport_to_screen_space,
406 gfx::PointF viewport_point,
407 gfx::Vector2dF viewport_delta);
[email protected]615c78a2013-01-24 23:44:16408
[email protected]c1bb5af2013-03-13 19:06:27409 void UpdateMaxScrollOffset();
[email protected]50761e92013-03-29 20:51:28410 void TrackDamageForAllSurfaces(
411 LayerImpl* root_draw_layer,
412 const LayerImplList& render_surface_layer_list);
[email protected]cd57cc5a2012-10-12 22:43:41413
[email protected]8be1a9bf2013-05-01 03:45:19414 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
415
[email protected]c1bb5af2013-03-13 19:06:27416 // Returns false if the frame should not be displayed. This function should
[email protected]ed511b8d2013-03-25 03:29:29417 // only be called from PrepareToDraw, as DidDrawAllLayers must be called
[email protected]c1bb5af2013-03-13 19:06:27418 // if this helper function is called.
419 bool CalculateRenderPasses(FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41420
[email protected]c1bb5af2013-03-13 19:06:27421 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current);
422 void ClearRenderSurfaces();
423 bool EnsureRenderSurfaceLayerList();
424 void ClearCurrentlyScrollingLayer();
[email protected]cd57cc5a2012-10-12 22:43:41425
[email protected]c1bb5af2013-03-13 19:06:27426 void AnimateScrollbarsRecursive(LayerImpl* layer,
427 base::TimeTicks time);
[email protected]cd57cc5a2012-10-12 22:43:41428
[email protected]c1bb5af2013-03-13 19:06:27429 void DumpRenderSurfaces(std::string* str,
430 int indent,
431 const LayerImpl* layer) const;
[email protected]cd57cc5a2012-10-12 22:43:41432
[email protected]c1bb5af2013-03-13 19:06:27433 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer);
[email protected]b9dcf43a2013-01-09 00:15:29434
[email protected]0fc818e2013-03-18 06:45:20435 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
436
[email protected]c1bb5af2013-03-13 19:06:27437 scoped_ptr<OutputSurface> output_surface_;
[email protected]fbe89f72013-05-21 07:24:24438
439 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
440 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
[email protected]c1bb5af2013-03-13 19:06:27441 scoped_ptr<ResourceProvider> resource_provider_;
[email protected]c1bb5af2013-03-13 19:06:27442 scoped_ptr<TileManager> tile_manager_;
[email protected]fbe89f72013-05-21 07:24:24443 scoped_ptr<Renderer> renderer_;
[email protected]3b31c6ac2012-12-06 21:27:29444
[email protected]c1bb5af2013-03-13 19:06:27445 // Tree currently being drawn.
446 scoped_ptr<LayerTreeImpl> active_tree_;
[email protected]3b31c6ac2012-12-06 21:27:29447
[email protected]c1bb5af2013-03-13 19:06:27448 // In impl-side painting mode, tree with possibly incomplete rasterized
449 // content. May be promoted to active by ActivatePendingTreeIfNeeded().
450 scoped_ptr<LayerTreeImpl> pending_tree_;
[email protected]48871fc2013-01-23 07:36:51451
[email protected]c1bb5af2013-03-13 19:06:27452 // In impl-side painting mode, inert tree with layers that can be recycled
453 // by the next sync from the main thread.
454 scoped_ptr<LayerTreeImpl> recycle_tree_;
[email protected]48871fc2013-01-23 07:36:51455
[email protected]200a9c062013-05-20 04:34:37456 InputHandlerClient* input_handler_client_;
[email protected]c1bb5af2013-03-13 19:06:27457 bool did_lock_scrolling_layer_;
458 bool should_bubble_scrolls_;
459 bool wheel_scrolling_;
[email protected]1960a712013-04-30 17:06:47460 // The optional delegate for the root layer scroll offset.
461 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
[email protected]c1bb5af2013-03-13 19:06:27462 LayerTreeSettings settings_;
463 LayerTreeDebugState debug_state_;
[email protected]c1bb5af2013-03-13 19:06:27464 gfx::Size device_viewport_size_;
[email protected]d9083762013-03-24 01:36:40465 float overdraw_bottom_height_;
[email protected]c1bb5af2013-03-13 19:06:27466 float device_scale_factor_;
467 bool visible_;
468 ManagedMemoryPolicy managed_memory_policy_;
[email protected]cd57cc5a2012-10-12 22:43:41469
[email protected]a2b5ded2013-05-20 21:32:53470 gfx::Vector2dF accumulated_root_overscroll_;
[email protected]6e921bd2013-04-29 21:10:20471 gfx::Vector2dF current_fling_velocity_;
472
[email protected]c1bb5af2013-03-13 19:06:27473 bool pinch_gesture_active_;
474 gfx::Point previous_pinch_anchor_;
[email protected]cd57cc5a2012-10-12 22:43:41475
[email protected]c1bb5af2013-03-13 19:06:27476 // This is set by AnimateLayers() and used by UpdateAnimationState()
477 // when sending animation events to the main thread.
478 base::Time last_animation_time_;
[email protected]6ad55bb22013-02-08 21:34:33479
[email protected]c1bb5af2013-03-13 19:06:27480 scoped_ptr<TopControlsManager> top_controls_manager_;
[email protected]3ba4cae2013-01-16 03:58:38481
[email protected]c1bb5af2013-03-13 19:06:27482 scoped_ptr<PageScaleAnimation> page_scale_animation_;
[email protected]cd57cc5a2012-10-12 22:43:41483
[email protected]c1bb5af2013-03-13 19:06:27484 // This is used for ticking animations slowly when hidden.
485 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
[email protected]cd57cc5a2012-10-12 22:43:41486
[email protected]c1bb5af2013-03-13 19:06:27487 scoped_ptr<FrameRateCounter> fps_counter_;
488 scoped_ptr<PaintTimeCounter> paint_time_counter_;
489 scoped_ptr<MemoryHistory> memory_history_;
490 scoped_ptr<DebugRectHistory> debug_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:41491
[email protected]d7626ffd2013-03-29 00:17:42492 // The maximum memory that would be used by the prioritized resource
493 // manager, if there were no limit on memory usage.
494 size_t max_memory_needed_bytes_;
495
[email protected]c1bb5af2013-03-13 19:06:27496 size_t last_sent_memory_visible_bytes_;
497 size_t last_sent_memory_visible_and_nearby_bytes_;
498 size_t last_sent_memory_use_bytes_;
[email protected]d3afa112012-12-08 06:24:28499
[email protected]878705be2013-04-15 22:44:02500 gfx::Rect viewport_damage_rect_;
[email protected]e0341352013-04-06 05:01:20501
[email protected]fb7425a2013-04-22 16:28:55502 base::TimeTicks current_frame_timeticks_;
503 base::Time current_frame_time_;
[email protected]829ad972013-01-28 23:36:10504
[email protected]c1bb5af2013-03-13 19:06:27505 scoped_ptr<AnimationRegistrar> animation_registrar_;
[email protected]de4afb5e2012-12-20 00:11:34506
[email protected]372bad5f2013-03-21 16:38:43507 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
508
[email protected]c1bb5af2013-03-13 19:06:27509 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
[email protected]cd57cc5a2012-10-12 22:43:41510};
511
[email protected]0023e8b2012-10-15 12:52:45512} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:41513
[email protected]556fd292013-03-18 08:03:04514#endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_