blob: df3f23ffd8d9449c8c90ec8b739aee85f1833f75 [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"
19#include "cc/input/top_controls_manager_client.h"
[email protected]50761e92013-03-29 20:51:2820#include "cc/layers/layer_lists.h"
[email protected]cc3cfaa2013-03-18 09:05:5221#include "cc/layers/render_pass_sink.h"
[email protected]7f0d825f2013-03-18 07:24:3022#include "cc/output/output_surface_client.h"
23#include "cc/output/renderer.h"
[email protected]89e8267a2013-03-18 07:50:5624#include "cc/quads/render_pass.h"
[email protected]e12dd0e2013-03-18 08:24:4025#include "cc/resources/tile_manager.h"
[email protected]b9dcf43a2013-01-09 00:15:2926#include "skia/ext/refptr.h"
[email protected]ddf9df82012-10-16 06:52:4627#include "third_party/skia/include/core/SkColor.h"
[email protected]b9dcf43a2013-01-09 00:15:2928#include "third_party/skia/include/core/SkPicture.h"
[email protected]167ed9d52012-10-31 20:47:5829#include "ui/gfx/rect.h"
[email protected]cd57cc5a2012-10-12 22:43:4130
31namespace cc {
32
[email protected]96baf3e2012-10-22 23:09:5533class CompletionEvent;
[email protected]bf189f62012-12-18 03:42:1134class CompositorFrameMetadata;
[email protected]96baf3e2012-10-22 23:09:5535class DebugRectHistory;
36class FrameRateCounter;
[email protected]96baf3e2012-10-22 23:09:5537class LayerImpl;
38class LayerTreeHostImplTimeSourceAdapter;
[email protected]8bef40572012-12-11 21:38:0839class LayerTreeImpl;
[email protected]96baf3e2012-10-22 23:09:5540class PageScaleAnimation;
[email protected]0edbfbe9f2013-01-17 03:33:0341class PaintTimeCounter;
[email protected]1191d9d2013-02-02 06:00:3342class MemoryHistory;
[email protected]372bad5f2013-03-21 16:38:4343class RenderingStatsInstrumentation;
[email protected]96baf3e2012-10-22 23:09:5544class RenderPassDrawQuad;
45class ResourceProvider;
[email protected]3ba4cae2013-01-16 03:58:3846class TopControlsManager;
[email protected]cd57cc5a2012-10-12 22:43:4147struct RendererCapabilities;
[email protected]cd57cc5a2012-10-12 22:43:4148
[email protected]96baf3e2012-10-22 23:09:5549// LayerTreeHost->Proxy callback interface.
50class LayerTreeHostImplClient {
[email protected]c1bb5af2013-03-13 19:06:2751 public:
52 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
53 virtual void OnSwapBuffersCompleteOnImplThread() = 0;
54 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
55 base::TimeDelta interval) = 0;
[email protected]7ed47512013-03-26 22:28:4556 virtual void DidVSync(base::TimeTicks frame_time) = 0;
[email protected]c1bb5af2013-03-13 19:06:2757 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
58 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) = 0;
59 virtual void SetNeedsRedrawOnImplThread() = 0;
[email protected]1cd9f5552013-04-26 04:22:0360 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect damage_rect) = 0;
[email protected]86126792013-03-16 20:07:5461 virtual void DidInitializeVisibleTileOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:2762 virtual void SetNeedsCommitOnImplThread() = 0;
63 virtual void SetNeedsManageTilesOnImplThread() = 0;
64 virtual void PostAnimationEventsToMainThreadOnImplThread(
65 scoped_ptr<AnimationEventsVector> events,
66 base::Time wall_clock_time) = 0;
67 // Returns true if resources were deleted by this call.
68 virtual bool ReduceContentsTextureMemoryOnImplThread(
69 size_t limit_bytes,
70 int priority_cutoff) = 0;
71 virtual void ReduceWastedContentsTextureMemoryOnImplThread() = 0;
72 virtual void SendManagedMemoryStats() = 0;
73 virtual bool IsInsideDraw() = 0;
74 virtual void RenewTreePriority() = 0;
[email protected]0fc818e2013-03-18 06:45:2075 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
[email protected]ef915f532013-04-22 20:56:3276 virtual void DidReceiveLastInputEventForVSync(base::TimeTicks frame_time) = 0;
[email protected]bf691c22013-03-26 21:15:0677
78 protected:
79 virtual ~LayerTreeHostImplClient() {}
[email protected]cd57cc5a2012-10-12 22:43:4180};
81
[email protected]c1bb5af2013-03-13 19:06:2782// LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
83// state.
[email protected]52347c842012-11-02 21:06:2084class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
85 public RendererClient,
[email protected]8947cbe2012-11-28 05:27:4386 public TileManagerClient,
[email protected]3ba4cae2013-01-16 03:58:3887 public OutputSurfaceClient,
88 public TopControlsManagerClient {
[email protected]e216fef02013-03-20 22:56:1089 public:
[email protected]c1bb5af2013-03-13 19:06:2790 static scoped_ptr<LayerTreeHostImpl> Create(
91 const LayerTreeSettings& settings,
92 LayerTreeHostImplClient* client,
[email protected]372bad5f2013-03-21 16:38:4393 Proxy* proxy,
94 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:2795 virtual ~LayerTreeHostImpl();
[email protected]cd57cc5a2012-10-12 22:43:4196
[email protected]c1bb5af2013-03-13 19:06:2797 // InputHandlerClient implementation
98 virtual InputHandlerClient::ScrollStatus ScrollBegin(
99 gfx::Point viewport_point,
100 InputHandlerClient::ScrollInputType type) OVERRIDE;
101 virtual bool ScrollBy(gfx::Point viewport_point,
102 gfx::Vector2dF scroll_delta) OVERRIDE;
[email protected]be782f52013-03-23 21:36:14103 virtual bool ScrollVerticallyByPage(
104 gfx::Point viewport_point,
105 WebKit::WebScrollbar::ScrollDirection direction) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27106 virtual void ScrollEnd() OVERRIDE;
[email protected]7c45d8152013-04-23 18:27:21107 virtual InputHandlerClient::ScrollStatus FlingScrollBegin() OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27108 virtual void PinchGestureBegin() OVERRIDE;
109 virtual void PinchGestureUpdate(float magnify_delta,
110 gfx::Point anchor) OVERRIDE;
111 virtual void PinchGestureEnd() OVERRIDE;
112 virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
113 bool anchor_point,
114 float page_scale,
115 base::TimeTicks start_time,
116 base::TimeDelta duration) OVERRIDE;
117 virtual void ScheduleAnimation() OVERRIDE;
118 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
[email protected]ef915f532013-04-22 20:56:32119 virtual void DidReceiveLastInputEventForVSync(
120 base::TimeTicks frame_time) OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41121
[email protected]c1bb5af2013-03-13 19:06:27122 // TopControlsManagerClient implementation.
[email protected]59adb112013-04-09 04:48:44123 virtual void DidChangeTopControlsPosition() OVERRIDE;
124 virtual bool HaveRootScrollLayer() const OVERRIDE;
[email protected]3ba4cae2013-01-16 03:58:38125
[email protected]0fc818e2013-03-18 06:45:20126 void StartScrollbarAnimation(base::TimeTicks now);
127
[email protected]c1bb5af2013-03-13 19:06:27128 struct CC_EXPORT FrameData : public RenderPassSink {
129 FrameData();
[email protected]ca2902e92013-03-28 01:45:35130 virtual ~FrameData();
[email protected]cd57cc5a2012-10-12 22:43:41131
[email protected]c1bb5af2013-03-13 19:06:27132 std::vector<gfx::Rect> occluding_screen_space_rects;
133 std::vector<gfx::Rect> non_occluding_screen_space_rects;
134 RenderPassList render_passes;
135 RenderPassIdHashMap render_passes_by_id;
[email protected]50761e92013-03-29 20:51:28136 const LayerImplList* render_surface_layer_list;
137 LayerImplList will_draw_layers;
[email protected]c1bb5af2013-03-13 19:06:27138 bool contains_incomplete_tile;
[email protected]e0341352013-04-06 05:01:20139 bool has_no_damage;
[email protected]e4c3c87a2013-04-22 02:28:40140 LatencyInfo latency_info;
[email protected]cd57cc5a2012-10-12 22:43:41141
[email protected]c1bb5af2013-03-13 19:06:27142 // RenderPassSink implementation.
143 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
144 };
[email protected]cd57cc5a2012-10-12 22:43:41145
[email protected]c1bb5af2013-03-13 19:06:27146 virtual void BeginCommit();
147 virtual void CommitComplete();
148 virtual void Animate(base::TimeTicks monotonic_time,
149 base::Time wall_clock_time);
[email protected]3d9f7432013-04-06 00:35:18150 virtual void UpdateAnimationState(bool start_ready_animations);
151 void UpdateBackgroundAnimateTicking(bool should_background_tick);
[email protected]b9d4a362013-04-23 05:36:27152 void SetViewportDamage(gfx::Rect damage_rect);
[email protected]cd57cc5a2012-10-12 22:43:41153
[email protected]c1bb5af2013-03-13 19:06:27154 void ManageTiles();
[email protected]f8456612013-03-19 20:56:09155 void SetAnticipatedDrawTime(base::TimeTicks time);
[email protected]8947cbe2012-11-28 05:27:43156
[email protected]c1bb5af2013-03-13 19:06:27157 // Returns false if problems occured preparing the frame, and we should try
[email protected]ed511b8d2013-03-25 03:29:29158 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
[email protected]c1bb5af2013-03-13 19:06:27159 // must also be called, regardless of whether DrawLayers is called between the
160 // two.
[email protected]e0341352013-04-06 05:01:20161 virtual bool PrepareToDraw(FrameData* frame,
162 gfx::Rect device_viewport_damage_rect);
[email protected]f0c2a242013-03-15 19:34:52163 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
[email protected]c1bb5af2013-03-13 19:06:27164 // Must be called if and only if PrepareToDraw was called.
165 void DidDrawAllLayers(const FrameData& frame);
[email protected]cd57cc5a2012-10-12 22:43:41166
[email protected]c1bb5af2013-03-13 19:06:27167 const LayerTreeSettings& settings() const { return settings_; }
[email protected]cd57cc5a2012-10-12 22:43:41168
[email protected]ffb2720f2013-03-15 19:18:37169 // Returns the currently visible viewport size in DIP. This value excludes
170 // the URL bar and non-overlay scrollbars.
171 gfx::SizeF VisibleViewportSize() const;
172
[email protected]c1bb5af2013-03-13 19:06:27173 // RendererClient implementation
174 private:
175 virtual gfx::Size DeviceViewportSize() const OVERRIDE;
176 virtual const LayerTreeSettings& Settings() const OVERRIDE;
177 public:
178 virtual void DidLoseOutputSurface() OVERRIDE;
179 virtual void OnSwapBuffersComplete() OVERRIDE;
180 virtual void SetFullRootLayerDamage() OVERRIDE;
181 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
182 OVERRIDE;
183 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
184 OVERRIDE;
185 virtual bool HasImplThread() const OVERRIDE;
186 virtual bool ShouldClearRootRenderPass() const OVERRIDE;
187 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE;
[email protected]73673592013-04-03 22:14:32188 virtual bool AllowPartialSwap() const OVERRIDE;
[email protected]8947cbe2012-11-28 05:27:43189
[email protected]c1bb5af2013-03-13 19:06:27190 // TileManagerClient implementation.
191 virtual void ScheduleManageTiles() OVERRIDE;
[email protected]86126792013-03-16 20:07:54192 virtual void DidInitializeVisibleTile() OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41193
[email protected]c1bb5af2013-03-13 19:06:27194 // OutputSurfaceClient implementation.
[email protected]1cd9f5552013-04-26 04:22:03195 virtual void SetNeedsRedrawRect(gfx::Rect rect) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27196 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
197 base::TimeDelta interval) OVERRIDE;
[email protected]7ed47512013-03-26 22:28:45198 virtual void DidVSync(base::TimeTicks frame_time) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27199 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
200 OVERRIDE;
[email protected]3b31c6ac2012-12-06 21:27:29201
[email protected]c1bb5af2013-03-13 19:06:27202 // Called from LayerTreeImpl.
203 void OnCanDrawStateChangedForTree();
[email protected]cd57cc5a2012-10-12 22:43:41204
[email protected]c1bb5af2013-03-13 19:06:27205 // Implementation
206 bool CanDraw();
207 OutputSurface* output_surface() const { return output_surface_.get(); }
[email protected]cd57cc5a2012-10-12 22:43:41208
[email protected]c1bb5af2013-03-13 19:06:27209 std::string LayerTreeAsText() const;
210 std::string LayerTreeAsJson() const;
[email protected]cd57cc5a2012-10-12 22:43:41211
[email protected]c1bb5af2013-03-13 19:06:27212 void FinishAllRendering();
213 int SourceAnimationFrameNumber() const;
[email protected]cd57cc5a2012-10-12 22:43:41214
[email protected]c1bb5af2013-03-13 19:06:27215 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
216 bool IsContextLost();
217 TileManager* tile_manager() { return tile_manager_.get(); }
218 Renderer* renderer() { return renderer_.get(); }
219 const RendererCapabilities& GetRendererCapabilities() const;
[email protected]cd57cc5a2012-10-12 22:43:41220
[email protected]e0341352013-04-06 05:01:20221 virtual bool SwapBuffers(const FrameData& frame);
[email protected]7ed47512013-03-26 22:28:45222 void EnableVSyncNotification(bool enable);
[email protected]cd57cc5a2012-10-12 22:43:41223
[email protected]c1bb5af2013-03-13 19:06:27224 void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
[email protected]cd57cc5a2012-10-12 22:43:41225
[email protected]c1bb5af2013-03-13 19:06:27226 LayerTreeImpl* active_tree() { return active_tree_.get(); }
227 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
228 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
229 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
230 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
231 void CreatePendingTree();
232 void CheckForCompletedTileUploads();
233 virtual bool ActivatePendingTreeIfNeeded();
[email protected]cd57cc5a2012-10-12 22:43:41234
[email protected]c1bb5af2013-03-13 19:06:27235 // Shortcuts to layers on the active tree.
236 LayerImpl* RootLayer() const;
237 LayerImpl* RootScrollLayer() const;
238 LayerImpl* CurrentlyScrollingLayer() const;
[email protected]cd57cc5a2012-10-12 22:43:41239
[email protected]c1bb5af2013-03-13 19:06:27240 virtual void SetVisible(bool visible);
241 bool visible() const { return visible_; }
[email protected]cd57cc5a2012-10-12 22:43:41242
[email protected]d7eb8c72013-03-23 22:57:13243 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
[email protected]59adb112013-04-09 04:48:44244 void SetNeedsRedraw() { client_->SetNeedsRedrawOnImplThread(); }
[email protected]d7eb8c72013-03-23 22:57:13245
[email protected]c1bb5af2013-03-13 19:06:27246 size_t memory_allocation_limit_bytes() const {
[email protected]46b8acc2013-03-19 22:38:35247 return managed_memory_policy_.bytes_limit_when_visible;
[email protected]c1bb5af2013-03-13 19:06:27248 }
[email protected]cd57cc5a2012-10-12 22:43:41249
[email protected]18ce59702013-04-09 04:58:40250 void SetViewportSize(gfx::Size device_viewport_size);
[email protected]c1bb5af2013-03-13 19:06:27251 gfx::Size device_viewport_size() const { return device_viewport_size_; }
[email protected]cd57cc5a2012-10-12 22:43:41252
[email protected]d9083762013-03-24 01:36:40253 void SetOverdrawBottomHeight(float overdraw_bottom_height);
254 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
255
[email protected]c1bb5af2013-03-13 19:06:27256 void SetDeviceScaleFactor(float device_scale_factor);
257 float device_scale_factor() const { return device_scale_factor_; }
[email protected]cd57cc5a2012-10-12 22:43:41258
[email protected]c1bb5af2013-03-13 19:06:27259 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
[email protected]cd57cc5a2012-10-12 22:43:41260
[email protected]c1bb5af2013-03-13 19:06:27261 bool needs_animate_layers() const {
262 return !animation_registrar_->active_animation_controllers().empty();
263 }
[email protected]cd57cc5a2012-10-12 22:43:41264
[email protected]c1bb5af2013-03-13 19:06:27265 void SendManagedMemoryStats(
266 size_t memory_visible_bytes,
267 size_t memory_visible_and_nearby_bytes,
[email protected]ed511b8d2013-03-25 03:29:29268 size_t memory_use_bytes);
[email protected]c1bb5af2013-03-13 19:06:27269
[email protected]d7626ffd2013-03-29 00:17:42270 void set_max_memory_needed_bytes(size_t bytes) {
271 max_memory_needed_bytes_ = bytes;
272 }
273
[email protected]c1bb5af2013-03-13 19:06:27274 FrameRateCounter* fps_counter() {
275 return fps_counter_.get();
276 }
277 PaintTimeCounter* paint_time_counter() {
278 return paint_time_counter_.get();
279 }
280 MemoryHistory* memory_history() {
281 return memory_history_.get();
282 }
283 DebugRectHistory* debug_rect_history() {
284 return debug_rect_history_.get();
285 }
286 ResourceProvider* resource_provider() {
287 return resource_provider_.get();
288 }
289 TopControlsManager* top_controls_manager() {
290 return top_controls_manager_.get();
291 }
[email protected]ff762fb2012-12-12 19:18:37292
[email protected]c1bb5af2013-03-13 19:06:27293 Proxy* proxy() const { return proxy_; }
[email protected]cd57cc5a2012-10-12 22:43:41294
[email protected]c1bb5af2013-03-13 19:06:27295 AnimationRegistrar* animation_registrar() const {
296 return animation_registrar_.get();
297 }
[email protected]de4afb5e2012-12-20 00:11:34298
[email protected]c1bb5af2013-03-13 19:06:27299 void SetDebugState(const LayerTreeDebugState& debug_state);
300 const LayerTreeDebugState& debug_state() const { return debug_state_; }
[email protected]f511afb2012-11-30 01:55:20301
[email protected]c1bb5af2013-03-13 19:06:27302 class CC_EXPORT CullRenderPassesWithCachedTextures {
303 public:
304 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
305 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41306
[email protected]c1bb5af2013-03-13 19:06:27307 // Iterates from the root first, in order to remove the surfaces closest
308 // to the root with cached textures, and all surfaces that draw into
309 // them.
310 size_t RenderPassListBegin(const RenderPassList& list) const {
311 return list.size() - 1;
312 }
313 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
314 size_t RenderPassListNext(size_t it) const { return it - 1; }
[email protected]cd57cc5a2012-10-12 22:43:41315
[email protected]bf691c22013-03-26 21:15:06316 explicit CullRenderPassesWithCachedTextures(Renderer* renderer)
[email protected]c1bb5af2013-03-13 19:06:27317 : renderer_(renderer) {}
318 private:
[email protected]bf691c22013-03-26 21:15:06319 Renderer* renderer_;
[email protected]c1bb5af2013-03-13 19:06:27320 };
[email protected]cd57cc5a2012-10-12 22:43:41321
[email protected]c1bb5af2013-03-13 19:06:27322 class CC_EXPORT CullRenderPassesWithNoQuads {
323 public:
324 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
325 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41326
[email protected]c1bb5af2013-03-13 19:06:27327 // Iterates in draw order, so that when a surface is removed, and its
328 // target becomes empty, then its target can be removed also.
329 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
330 size_t RenderPassListEnd(const RenderPassList& list) const {
331 return list.size();
332 }
333 size_t RenderPassListNext(size_t it) const { return it + 1; }
334 };
[email protected]cd57cc5a2012-10-12 22:43:41335
[email protected]c1bb5af2013-03-13 19:06:27336 template <typename RenderPassCuller>
337 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41338
[email protected]c1bb5af2013-03-13 19:06:27339 skia::RefPtr<SkPicture> CapturePicture();
[email protected]b9dcf43a2013-01-09 00:15:29340
[email protected]c1bb5af2013-03-13 19:06:27341 bool pinch_gesture_active() const { return pinch_gesture_active_; }
[email protected]166db5c82013-01-09 23:54:31342
[email protected]c1bb5af2013-03-13 19:06:27343 void SetTreePriority(TreePriority priority);
[email protected]362f1e8b2013-01-21 16:54:30344
[email protected]c1bb5af2013-03-13 19:06:27345 void BeginNextFrame();
[email protected]fb7425a2013-04-22 16:28:55346 base::TimeTicks CurrentFrameTimeTicks();
347 base::Time CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10348
[email protected]c1bb5af2013-03-13 19:06:27349 scoped_ptr<base::Value> AsValue() const;
350 scoped_ptr<base::Value> ActivationStateAsValue() const;
351 scoped_ptr<base::Value> FrameStateAsValue() const;
[email protected]131a0c22013-02-12 18:31:08352
[email protected]c1bb5af2013-03-13 19:06:27353 bool page_scale_animation_active() const { return !!page_scale_animation_; }
[email protected]498ddd02013-02-28 23:59:25354
[email protected]c1bb5af2013-03-13 19:06:27355 protected:
[email protected]372bad5f2013-03-21 16:38:43356 LayerTreeHostImpl(
357 const LayerTreeSettings& settings,
358 LayerTreeHostImplClient* client,
359 Proxy* proxy,
360 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:27361 void ActivatePendingTree();
[email protected]cd57cc5a2012-10-12 22:43:41362
[email protected]c1bb5af2013-03-13 19:06:27363 // Virtual for testing.
364 virtual void AnimateLayers(base::TimeTicks monotonic_time,
365 base::Time wall_clock_time);
[email protected]cd57cc5a2012-10-12 22:43:41366
[email protected]c1bb5af2013-03-13 19:06:27367 // Virtual for testing.
368 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
[email protected]cd57cc5a2012-10-12 22:43:41369
[email protected]c1bb5af2013-03-13 19:06:27370 const AnimationRegistrar::AnimationControllerMap&
371 active_animation_controllers() const {
372 return animation_registrar_->active_animation_controllers();
373 }
[email protected]de4afb5e2012-12-20 00:11:34374
[email protected]c1bb5af2013-03-13 19:06:27375 LayerTreeHostImplClient* client_;
376 Proxy* proxy_;
[email protected]cd57cc5a2012-10-12 22:43:41377
[email protected]c1bb5af2013-03-13 19:06:27378 private:
379 void AnimatePageScale(base::TimeTicks monotonic_time);
380 void AnimateScrollbars(base::TimeTicks monotonic_time);
[email protected]ffb2720f2013-03-15 19:18:37381 void AnimateTopControls(base::TimeTicks monotonic_time);
[email protected]2d692992012-12-19 01:19:32382
[email protected]c1bb5af2013-03-13 19:06:27383 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
[email protected]ed511b8d2013-03-25 03:29:29384 LayerImpl* layer_impl,
385 float scale_from_viewport_to_screen_space,
386 gfx::PointF viewport_point,
387 gfx::Vector2dF viewport_delta);
[email protected]615c78a2013-01-24 23:44:16388
[email protected]c1bb5af2013-03-13 19:06:27389 void UpdateMaxScrollOffset();
[email protected]50761e92013-03-29 20:51:28390 void TrackDamageForAllSurfaces(
391 LayerImpl* root_draw_layer,
392 const LayerImplList& render_surface_layer_list);
[email protected]cd57cc5a2012-10-12 22:43:41393
[email protected]c1bb5af2013-03-13 19:06:27394 // Returns false if the frame should not be displayed. This function should
[email protected]ed511b8d2013-03-25 03:29:29395 // only be called from PrepareToDraw, as DidDrawAllLayers must be called
[email protected]c1bb5af2013-03-13 19:06:27396 // if this helper function is called.
397 bool CalculateRenderPasses(FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41398
[email protected]c1bb5af2013-03-13 19:06:27399 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current);
400 void ClearRenderSurfaces();
401 bool EnsureRenderSurfaceLayerList();
402 void ClearCurrentlyScrollingLayer();
[email protected]cd57cc5a2012-10-12 22:43:41403
[email protected]c1bb5af2013-03-13 19:06:27404 void AnimateScrollbarsRecursive(LayerImpl* layer,
405 base::TimeTicks time);
[email protected]cd57cc5a2012-10-12 22:43:41406
[email protected]c1bb5af2013-03-13 19:06:27407 void DumpRenderSurfaces(std::string* str,
408 int indent,
409 const LayerImpl* layer) const;
[email protected]cd57cc5a2012-10-12 22:43:41410
[email protected]c1bb5af2013-03-13 19:06:27411 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer);
[email protected]b9dcf43a2013-01-09 00:15:29412
[email protected]0fc818e2013-03-18 06:45:20413 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
414
[email protected]c1bb5af2013-03-13 19:06:27415 scoped_ptr<OutputSurface> output_surface_;
416 scoped_ptr<ResourceProvider> resource_provider_;
417 scoped_ptr<Renderer> renderer_;
418 scoped_ptr<TileManager> tile_manager_;
[email protected]3b31c6ac2012-12-06 21:27:29419
[email protected]c1bb5af2013-03-13 19:06:27420 // Tree currently being drawn.
421 scoped_ptr<LayerTreeImpl> active_tree_;
[email protected]3b31c6ac2012-12-06 21:27:29422
[email protected]c1bb5af2013-03-13 19:06:27423 // In impl-side painting mode, tree with possibly incomplete rasterized
424 // content. May be promoted to active by ActivatePendingTreeIfNeeded().
425 scoped_ptr<LayerTreeImpl> pending_tree_;
[email protected]48871fc2013-01-23 07:36:51426
[email protected]c1bb5af2013-03-13 19:06:27427 // In impl-side painting mode, inert tree with layers that can be recycled
428 // by the next sync from the main thread.
429 scoped_ptr<LayerTreeImpl> recycle_tree_;
[email protected]48871fc2013-01-23 07:36:51430
[email protected]c1bb5af2013-03-13 19:06:27431 bool did_lock_scrolling_layer_;
432 bool should_bubble_scrolls_;
433 bool wheel_scrolling_;
434 LayerTreeSettings settings_;
435 LayerTreeDebugState debug_state_;
[email protected]c1bb5af2013-03-13 19:06:27436 gfx::Size device_viewport_size_;
[email protected]d9083762013-03-24 01:36:40437 float overdraw_bottom_height_;
[email protected]c1bb5af2013-03-13 19:06:27438 float device_scale_factor_;
439 bool visible_;
440 ManagedMemoryPolicy managed_memory_policy_;
[email protected]cd57cc5a2012-10-12 22:43:41441
[email protected]c1bb5af2013-03-13 19:06:27442 bool pinch_gesture_active_;
443 gfx::Point previous_pinch_anchor_;
[email protected]cd57cc5a2012-10-12 22:43:41444
[email protected]c1bb5af2013-03-13 19:06:27445 // This is set by AnimateLayers() and used by UpdateAnimationState()
446 // when sending animation events to the main thread.
447 base::Time last_animation_time_;
[email protected]6ad55bb22013-02-08 21:34:33448
[email protected]c1bb5af2013-03-13 19:06:27449 scoped_ptr<TopControlsManager> top_controls_manager_;
[email protected]3ba4cae2013-01-16 03:58:38450
[email protected]c1bb5af2013-03-13 19:06:27451 scoped_ptr<PageScaleAnimation> page_scale_animation_;
[email protected]cd57cc5a2012-10-12 22:43:41452
[email protected]c1bb5af2013-03-13 19:06:27453 // This is used for ticking animations slowly when hidden.
454 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
[email protected]cd57cc5a2012-10-12 22:43:41455
[email protected]c1bb5af2013-03-13 19:06:27456 scoped_ptr<FrameRateCounter> fps_counter_;
457 scoped_ptr<PaintTimeCounter> paint_time_counter_;
458 scoped_ptr<MemoryHistory> memory_history_;
459 scoped_ptr<DebugRectHistory> debug_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:41460
[email protected]d7626ffd2013-03-29 00:17:42461 // The maximum memory that would be used by the prioritized resource
462 // manager, if there were no limit on memory usage.
463 size_t max_memory_needed_bytes_;
464
[email protected]c1bb5af2013-03-13 19:06:27465 size_t last_sent_memory_visible_bytes_;
466 size_t last_sent_memory_visible_and_nearby_bytes_;
467 size_t last_sent_memory_use_bytes_;
[email protected]d3afa112012-12-08 06:24:28468
[email protected]878705be2013-04-15 22:44:02469 gfx::Rect viewport_damage_rect_;
[email protected]e0341352013-04-06 05:01:20470
[email protected]fb7425a2013-04-22 16:28:55471 base::TimeTicks current_frame_timeticks_;
472 base::Time current_frame_time_;
[email protected]829ad972013-01-28 23:36:10473
[email protected]c1bb5af2013-03-13 19:06:27474 scoped_ptr<AnimationRegistrar> animation_registrar_;
[email protected]de4afb5e2012-12-20 00:11:34475
[email protected]372bad5f2013-03-21 16:38:43476 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
477
[email protected]c1bb5af2013-03-13 19:06:27478 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
[email protected]cd57cc5a2012-10-12 22:43:41479};
480
[email protected]0023e8b2012-10-15 12:52:45481} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:41482
[email protected]556fd292013-03-18 08:03:04483#endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_