blob: 72b06b5055918730783f281c74afc741c5bb4e44 [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]7ed47512013-03-26 22:28:4557 virtual void DidVSync(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]ef915f532013-04-22 20:56:3277 virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time) = 0;
[email protected]2a61ad52013-05-13 14:01:2978 virtual void DidActivatePendingTree() = 0;
[email protected]bf691c22013-03-26 21:15:0679
80 protected:
81 virtual ~LayerTreeHostImplClient() {}
[email protected]cd57cc5a2012-10-12 22:43:4182};
83
[email protected]c1bb5af2013-03-13 19:06:2784// LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
85// state.
[email protected]200a9c062013-05-20 04:34:3786class CC_EXPORT LayerTreeHostImpl
87 : public InputHandler,
88 public RendererClient,
89 public TileManagerClient,
90 public OutputSurfaceClient,
91 public TopControlsManagerClient,
92 public base::SupportsWeakPtr<LayerTreeHostImpl> {
[email protected]e216fef02013-03-20 22:56:1093 public:
[email protected]c1bb5af2013-03-13 19:06:2794 static scoped_ptr<LayerTreeHostImpl> Create(
95 const LayerTreeSettings& settings,
96 LayerTreeHostImplClient* client,
[email protected]372bad5f2013-03-21 16:38:4397 Proxy* proxy,
98 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:2799 virtual ~LayerTreeHostImpl();
[email protected]cd57cc5a2012-10-12 22:43:41100
[email protected]5ff3c9782013-04-29 17:35:12101 // InputHandler implementation
[email protected]200a9c062013-05-20 04:34:37102 virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
[email protected]5ff3c9782013-04-29 17:35:12103 virtual InputHandler::ScrollStatus ScrollBegin(
[email protected]c1bb5af2013-03-13 19:06:27104 gfx::Point viewport_point,
[email protected]5ff3c9782013-04-29 17:35:12105 InputHandler::ScrollInputType type) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27106 virtual bool ScrollBy(gfx::Point viewport_point,
107 gfx::Vector2dF scroll_delta) OVERRIDE;
[email protected]be782f52013-03-23 21:36:14108 virtual bool ScrollVerticallyByPage(
109 gfx::Point viewport_point,
110 WebKit::WebScrollbar::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]ef915f532013-04-22 20:56:32128 virtual void DidReceiveLastInputEventForVSync(
129 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]cd57cc5a2012-10-12 22:43:41202
[email protected]c1bb5af2013-03-13 19:06:27203 // OutputSurfaceClient implementation.
[email protected]1cd9f5552013-04-26 04:22:03204 virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27205 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
206 base::TimeDelta interval) OVERRIDE;
[email protected]7ed47512013-03-26 22:28:45207 virtual void DidVSync(base::TimeTicks frame_time) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27208 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
209 OVERRIDE;
[email protected]3b31c6ac2012-12-06 21:27:29210
[email protected]c1bb5af2013-03-13 19:06:27211 // Called from LayerTreeImpl.
212 void OnCanDrawStateChangedForTree();
[email protected]cd57cc5a2012-10-12 22:43:41213
[email protected]c1bb5af2013-03-13 19:06:27214 // Implementation
215 bool CanDraw();
216 OutputSurface* output_surface() const { return output_surface_.get(); }
[email protected]cd57cc5a2012-10-12 22:43:41217
[email protected]c1bb5af2013-03-13 19:06:27218 std::string LayerTreeAsText() const;
219 std::string LayerTreeAsJson() const;
[email protected]cd57cc5a2012-10-12 22:43:41220
[email protected]c1bb5af2013-03-13 19:06:27221 void FinishAllRendering();
222 int SourceAnimationFrameNumber() const;
[email protected]cd57cc5a2012-10-12 22:43:41223
[email protected]c1bb5af2013-03-13 19:06:27224 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
225 bool IsContextLost();
226 TileManager* tile_manager() { return tile_manager_.get(); }
227 Renderer* renderer() { return renderer_.get(); }
228 const RendererCapabilities& GetRendererCapabilities() const;
[email protected]cd57cc5a2012-10-12 22:43:41229
[email protected]e0341352013-04-06 05:01:20230 virtual bool SwapBuffers(const FrameData& frame);
[email protected]7ed47512013-03-26 22:28:45231 void EnableVSyncNotification(bool enable);
[email protected]cd57cc5a2012-10-12 22:43:41232
[email protected]c1bb5af2013-03-13 19:06:27233 void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
[email protected]cd57cc5a2012-10-12 22:43:41234
[email protected]c1bb5af2013-03-13 19:06:27235 LayerTreeImpl* active_tree() { return active_tree_.get(); }
236 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
237 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
238 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
239 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
240 void CreatePendingTree();
241 void CheckForCompletedTileUploads();
242 virtual bool ActivatePendingTreeIfNeeded();
[email protected]cd57cc5a2012-10-12 22:43:41243
[email protected]c1bb5af2013-03-13 19:06:27244 // Shortcuts to layers on the active tree.
245 LayerImpl* RootLayer() const;
246 LayerImpl* RootScrollLayer() const;
247 LayerImpl* CurrentlyScrollingLayer() const;
[email protected]cd57cc5a2012-10-12 22:43:41248
[email protected]c1bb5af2013-03-13 19:06:27249 virtual void SetVisible(bool visible);
250 bool visible() const { return visible_; }
[email protected]cd57cc5a2012-10-12 22:43:41251
[email protected]d7eb8c72013-03-23 22:57:13252 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
[email protected]59adb112013-04-09 04:48:44253 void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); }
[email protected]d7eb8c72013-03-23 22:57:13254
[email protected]206a3922013-05-17 06:34:12255 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
256
[email protected]c1bb5af2013-03-13 19:06:27257 size_t memory_allocation_limit_bytes() const {
[email protected]46b8acc2013-03-19 22:38:35258 return managed_memory_policy_.bytes_limit_when_visible;
[email protected]c1bb5af2013-03-13 19:06:27259 }
[email protected]cd57cc5a2012-10-12 22:43:41260
[email protected]18ce59702013-04-09 04:58:40261 void SetViewportSize(gfx::Size device_viewport_size);
[email protected]c1bb5af2013-03-13 19:06:27262 gfx::Size device_viewport_size() const { return device_viewport_size_; }
[email protected]cd57cc5a2012-10-12 22:43:41263
[email protected]d9083762013-03-24 01:36:40264 void SetOverdrawBottomHeight(float overdraw_bottom_height);
265 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
266
[email protected]c1bb5af2013-03-13 19:06:27267 void SetDeviceScaleFactor(float device_scale_factor);
268 float device_scale_factor() const { return device_scale_factor_; }
[email protected]cd57cc5a2012-10-12 22:43:41269
[email protected]c1bb5af2013-03-13 19:06:27270 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
[email protected]cd57cc5a2012-10-12 22:43:41271
[email protected]c1bb5af2013-03-13 19:06:27272 bool needs_animate_layers() const {
273 return !animation_registrar_->active_animation_controllers().empty();
274 }
[email protected]cd57cc5a2012-10-12 22:43:41275
[email protected]c1bb5af2013-03-13 19:06:27276 void SendManagedMemoryStats(
277 size_t memory_visible_bytes,
278 size_t memory_visible_and_nearby_bytes,
[email protected]ed511b8d2013-03-25 03:29:29279 size_t memory_use_bytes);
[email protected]c1bb5af2013-03-13 19:06:27280
[email protected]d7626ffd2013-03-29 00:17:42281 void set_max_memory_needed_bytes(size_t bytes) {
282 max_memory_needed_bytes_ = bytes;
283 }
284
[email protected]c1bb5af2013-03-13 19:06:27285 FrameRateCounter* fps_counter() {
286 return fps_counter_.get();
287 }
288 PaintTimeCounter* paint_time_counter() {
289 return paint_time_counter_.get();
290 }
291 MemoryHistory* memory_history() {
292 return memory_history_.get();
293 }
294 DebugRectHistory* debug_rect_history() {
295 return debug_rect_history_.get();
296 }
297 ResourceProvider* resource_provider() {
298 return resource_provider_.get();
299 }
300 TopControlsManager* top_controls_manager() {
301 return top_controls_manager_.get();
302 }
[email protected]ff762fb2012-12-12 19:18:37303
[email protected]c1bb5af2013-03-13 19:06:27304 Proxy* proxy() const { return proxy_; }
[email protected]cd57cc5a2012-10-12 22:43:41305
[email protected]c1bb5af2013-03-13 19:06:27306 AnimationRegistrar* animation_registrar() const {
307 return animation_registrar_.get();
308 }
[email protected]de4afb5e2012-12-20 00:11:34309
[email protected]c1bb5af2013-03-13 19:06:27310 void SetDebugState(const LayerTreeDebugState& debug_state);
311 const LayerTreeDebugState& debug_state() const { return debug_state_; }
[email protected]f511afb2012-11-30 01:55:20312
[email protected]c1bb5af2013-03-13 19:06:27313 class CC_EXPORT CullRenderPassesWithCachedTextures {
314 public:
315 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
316 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41317
[email protected]c1bb5af2013-03-13 19:06:27318 // Iterates from the root first, in order to remove the surfaces closest
319 // to the root with cached textures, and all surfaces that draw into
320 // them.
321 size_t RenderPassListBegin(const RenderPassList& list) const {
322 return list.size() - 1;
323 }
324 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
325 size_t RenderPassListNext(size_t it) const { return it - 1; }
[email protected]cd57cc5a2012-10-12 22:43:41326
[email protected]bf691c22013-03-26 21:15:06327 explicit CullRenderPassesWithCachedTextures(Renderer* renderer)
[email protected]c1bb5af2013-03-13 19:06:27328 : renderer_(renderer) {}
329 private:
[email protected]bf691c22013-03-26 21:15:06330 Renderer* renderer_;
[email protected]c1bb5af2013-03-13 19:06:27331 };
[email protected]cd57cc5a2012-10-12 22:43:41332
[email protected]c1bb5af2013-03-13 19:06:27333 class CC_EXPORT CullRenderPassesWithNoQuads {
334 public:
335 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
336 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41337
[email protected]c1bb5af2013-03-13 19:06:27338 // Iterates in draw order, so that when a surface is removed, and its
339 // target becomes empty, then its target can be removed also.
340 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
341 size_t RenderPassListEnd(const RenderPassList& list) const {
342 return list.size();
343 }
344 size_t RenderPassListNext(size_t it) const { return it + 1; }
345 };
[email protected]cd57cc5a2012-10-12 22:43:41346
[email protected]c1bb5af2013-03-13 19:06:27347 template <typename RenderPassCuller>
348 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41349
[email protected]c1bb5af2013-03-13 19:06:27350 skia::RefPtr<SkPicture> CapturePicture();
[email protected]b9dcf43a2013-01-09 00:15:29351
[email protected]a2b5ded2013-05-20 21:32:53352 gfx::Vector2dF accumulated_root_overscroll() const {
353 return accumulated_root_overscroll_;
354 }
355 gfx::Vector2dF current_fling_velocity() const {
356 return current_fling_velocity_;
357 }
358
[email protected]c1bb5af2013-03-13 19:06:27359 bool pinch_gesture_active() const { return pinch_gesture_active_; }
[email protected]166db5c82013-01-09 23:54:31360
[email protected]c1bb5af2013-03-13 19:06:27361 void SetTreePriority(TreePriority priority);
[email protected]362f1e8b2013-01-21 16:54:30362
[email protected]8347d692013-05-17 23:22:38363 void ResetCurrentFrameTimeForNextFrame();
[email protected]fb7425a2013-04-22 16:28:55364 base::TimeTicks CurrentFrameTimeTicks();
365 base::Time CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10366
[email protected]c1bb5af2013-03-13 19:06:27367 scoped_ptr<base::Value> AsValue() const;
368 scoped_ptr<base::Value> ActivationStateAsValue() const;
[email protected]131a0c22013-02-12 18:31:08369
[email protected]c1bb5af2013-03-13 19:06:27370 bool page_scale_animation_active() const { return !!page_scale_animation_; }
[email protected]498ddd02013-02-28 23:59:25371
[email protected]c1bb5af2013-03-13 19:06:27372 protected:
[email protected]372bad5f2013-03-21 16:38:43373 LayerTreeHostImpl(
374 const LayerTreeSettings& settings,
375 LayerTreeHostImplClient* client,
376 Proxy* proxy,
377 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:27378 void ActivatePendingTree();
[email protected]cd57cc5a2012-10-12 22:43:41379
[email protected]c1bb5af2013-03-13 19:06:27380 // Virtual for testing.
381 virtual void AnimateLayers(base::TimeTicks monotonic_time,
382 base::Time wall_clock_time);
[email protected]cd57cc5a2012-10-12 22:43:41383
[email protected]c1bb5af2013-03-13 19:06:27384 // Virtual for testing.
385 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
[email protected]cd57cc5a2012-10-12 22:43:41386
[email protected]c1bb5af2013-03-13 19:06:27387 const AnimationRegistrar::AnimationControllerMap&
388 active_animation_controllers() const {
389 return animation_registrar_->active_animation_controllers();
390 }
[email protected]de4afb5e2012-12-20 00:11:34391
[email protected]c1bb5af2013-03-13 19:06:27392 LayerTreeHostImplClient* client_;
393 Proxy* proxy_;
[email protected]cd57cc5a2012-10-12 22:43:41394
[email protected]c1bb5af2013-03-13 19:06:27395 private:
396 void AnimatePageScale(base::TimeTicks monotonic_time);
397 void AnimateScrollbars(base::TimeTicks monotonic_time);
[email protected]ffb2720f2013-03-15 19:18:37398 void AnimateTopControls(base::TimeTicks monotonic_time);
[email protected]2d692992012-12-19 01:19:32399
[email protected]c1bb5af2013-03-13 19:06:27400 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
[email protected]ed511b8d2013-03-25 03:29:29401 LayerImpl* layer_impl,
402 float scale_from_viewport_to_screen_space,
403 gfx::PointF viewport_point,
404 gfx::Vector2dF viewport_delta);
[email protected]615c78a2013-01-24 23:44:16405
[email protected]c1bb5af2013-03-13 19:06:27406 void UpdateMaxScrollOffset();
[email protected]50761e92013-03-29 20:51:28407 void TrackDamageForAllSurfaces(
408 LayerImpl* root_draw_layer,
409 const LayerImplList& render_surface_layer_list);
[email protected]cd57cc5a2012-10-12 22:43:41410
[email protected]8be1a9bf2013-05-01 03:45:19411 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
412
[email protected]c1bb5af2013-03-13 19:06:27413 // Returns false if the frame should not be displayed. This function should
[email protected]ed511b8d2013-03-25 03:29:29414 // only be called from PrepareToDraw, as DidDrawAllLayers must be called
[email protected]c1bb5af2013-03-13 19:06:27415 // if this helper function is called.
416 bool CalculateRenderPasses(FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41417
[email protected]c1bb5af2013-03-13 19:06:27418 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current);
419 void ClearRenderSurfaces();
420 bool EnsureRenderSurfaceLayerList();
421 void ClearCurrentlyScrollingLayer();
[email protected]cd57cc5a2012-10-12 22:43:41422
[email protected]c1bb5af2013-03-13 19:06:27423 void AnimateScrollbarsRecursive(LayerImpl* layer,
424 base::TimeTicks time);
[email protected]cd57cc5a2012-10-12 22:43:41425
[email protected]c1bb5af2013-03-13 19:06:27426 void DumpRenderSurfaces(std::string* str,
427 int indent,
428 const LayerImpl* layer) const;
[email protected]cd57cc5a2012-10-12 22:43:41429
[email protected]c1bb5af2013-03-13 19:06:27430 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer);
[email protected]b9dcf43a2013-01-09 00:15:29431
[email protected]0fc818e2013-03-18 06:45:20432 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
433
[email protected]c1bb5af2013-03-13 19:06:27434 scoped_ptr<OutputSurface> output_surface_;
435 scoped_ptr<ResourceProvider> resource_provider_;
436 scoped_ptr<Renderer> renderer_;
437 scoped_ptr<TileManager> tile_manager_;
[email protected]3b31c6ac2012-12-06 21:27:29438
[email protected]c1bb5af2013-03-13 19:06:27439 // Tree currently being drawn.
440 scoped_ptr<LayerTreeImpl> active_tree_;
[email protected]3b31c6ac2012-12-06 21:27:29441
[email protected]c1bb5af2013-03-13 19:06:27442 // In impl-side painting mode, tree with possibly incomplete rasterized
443 // content. May be promoted to active by ActivatePendingTreeIfNeeded().
444 scoped_ptr<LayerTreeImpl> pending_tree_;
[email protected]48871fc2013-01-23 07:36:51445
[email protected]c1bb5af2013-03-13 19:06:27446 // In impl-side painting mode, inert tree with layers that can be recycled
447 // by the next sync from the main thread.
448 scoped_ptr<LayerTreeImpl> recycle_tree_;
[email protected]48871fc2013-01-23 07:36:51449
[email protected]200a9c062013-05-20 04:34:37450 InputHandlerClient* input_handler_client_;
[email protected]c1bb5af2013-03-13 19:06:27451 bool did_lock_scrolling_layer_;
452 bool should_bubble_scrolls_;
453 bool wheel_scrolling_;
[email protected]1960a712013-04-30 17:06:47454 // The optional delegate for the root layer scroll offset.
455 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
[email protected]c1bb5af2013-03-13 19:06:27456 LayerTreeSettings settings_;
457 LayerTreeDebugState debug_state_;
[email protected]c1bb5af2013-03-13 19:06:27458 gfx::Size device_viewport_size_;
[email protected]d9083762013-03-24 01:36:40459 float overdraw_bottom_height_;
[email protected]c1bb5af2013-03-13 19:06:27460 float device_scale_factor_;
461 bool visible_;
462 ManagedMemoryPolicy managed_memory_policy_;
[email protected]cd57cc5a2012-10-12 22:43:41463
[email protected]a2b5ded2013-05-20 21:32:53464 gfx::Vector2dF accumulated_root_overscroll_;
[email protected]6e921bd2013-04-29 21:10:20465 gfx::Vector2dF current_fling_velocity_;
466
[email protected]c1bb5af2013-03-13 19:06:27467 bool pinch_gesture_active_;
468 gfx::Point previous_pinch_anchor_;
[email protected]cd57cc5a2012-10-12 22:43:41469
[email protected]c1bb5af2013-03-13 19:06:27470 // This is set by AnimateLayers() and used by UpdateAnimationState()
471 // when sending animation events to the main thread.
472 base::Time last_animation_time_;
[email protected]6ad55bb22013-02-08 21:34:33473
[email protected]c1bb5af2013-03-13 19:06:27474 scoped_ptr<TopControlsManager> top_controls_manager_;
[email protected]3ba4cae2013-01-16 03:58:38475
[email protected]c1bb5af2013-03-13 19:06:27476 scoped_ptr<PageScaleAnimation> page_scale_animation_;
[email protected]cd57cc5a2012-10-12 22:43:41477
[email protected]c1bb5af2013-03-13 19:06:27478 // This is used for ticking animations slowly when hidden.
479 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
[email protected]cd57cc5a2012-10-12 22:43:41480
[email protected]c1bb5af2013-03-13 19:06:27481 scoped_ptr<FrameRateCounter> fps_counter_;
482 scoped_ptr<PaintTimeCounter> paint_time_counter_;
483 scoped_ptr<MemoryHistory> memory_history_;
484 scoped_ptr<DebugRectHistory> debug_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:41485
[email protected]d7626ffd2013-03-29 00:17:42486 // The maximum memory that would be used by the prioritized resource
487 // manager, if there were no limit on memory usage.
488 size_t max_memory_needed_bytes_;
489
[email protected]c1bb5af2013-03-13 19:06:27490 size_t last_sent_memory_visible_bytes_;
491 size_t last_sent_memory_visible_and_nearby_bytes_;
492 size_t last_sent_memory_use_bytes_;
[email protected]d3afa112012-12-08 06:24:28493
[email protected]878705be2013-04-15 22:44:02494 gfx::Rect viewport_damage_rect_;
[email protected]e0341352013-04-06 05:01:20495
[email protected]fb7425a2013-04-22 16:28:55496 base::TimeTicks current_frame_timeticks_;
497 base::Time current_frame_time_;
[email protected]829ad972013-01-28 23:36:10498
[email protected]c1bb5af2013-03-13 19:06:27499 scoped_ptr<AnimationRegistrar> animation_registrar_;
[email protected]de4afb5e2012-12-20 00:11:34500
[email protected]372bad5f2013-03-21 16:38:43501 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
502
[email protected]c1bb5af2013-03-13 19:06:27503 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
[email protected]cd57cc5a2012-10-12 22:43:41504};
505
[email protected]0023e8b2012-10-15 12:52:45506} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:41507
[email protected]556fd292013-03-18 08:03:04508#endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_