blob: 051e2848d820dc7396abf3f65f4cbf547379969d [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]3052b10f2013-03-18 07:41:2117#include "cc/input/input_handler.h"
18#include "cc/input/top_controls_manager_client.h"
[email protected]cc3cfaa2013-03-18 09:05:5219#include "cc/layers/render_pass_sink.h"
[email protected]7f0d825f2013-03-18 07:24:3020#include "cc/output/output_surface_client.h"
21#include "cc/output/renderer.h"
[email protected]89e8267a2013-03-18 07:50:5622#include "cc/quads/render_pass.h"
[email protected]e12dd0e2013-03-18 08:24:4023#include "cc/resources/tile_manager.h"
[email protected]b9dcf43a2013-01-09 00:15:2924#include "skia/ext/refptr.h"
[email protected]ddf9df82012-10-16 06:52:4625#include "third_party/skia/include/core/SkColor.h"
[email protected]b9dcf43a2013-01-09 00:15:2926#include "third_party/skia/include/core/SkPicture.h"
[email protected]167ed9d52012-10-31 20:47:5827#include "ui/gfx/rect.h"
[email protected]cd57cc5a2012-10-12 22:43:4128
29namespace cc {
30
[email protected]96baf3e2012-10-22 23:09:5531class CompletionEvent;
[email protected]bf189f62012-12-18 03:42:1132class CompositorFrameMetadata;
[email protected]96baf3e2012-10-22 23:09:5533class DebugRectHistory;
34class FrameRateCounter;
[email protected]96baf3e2012-10-22 23:09:5535class LayerImpl;
36class LayerTreeHostImplTimeSourceAdapter;
[email protected]8bef40572012-12-11 21:38:0837class LayerTreeImpl;
[email protected]96baf3e2012-10-22 23:09:5538class PageScaleAnimation;
[email protected]0edbfbe9f2013-01-17 03:33:0339class PaintTimeCounter;
[email protected]1191d9d2013-02-02 06:00:3340class MemoryHistory;
[email protected]372bad5f2013-03-21 16:38:4341class RenderingStatsInstrumentation;
[email protected]96baf3e2012-10-22 23:09:5542class RenderPassDrawQuad;
43class ResourceProvider;
[email protected]3ba4cae2013-01-16 03:58:3844class TopControlsManager;
[email protected]cd57cc5a2012-10-12 22:43:4145struct RendererCapabilities;
[email protected]cd57cc5a2012-10-12 22:43:4146
[email protected]96baf3e2012-10-22 23:09:5547// LayerTreeHost->Proxy callback interface.
48class LayerTreeHostImplClient {
[email protected]c1bb5af2013-03-13 19:06:2749 public:
50 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
51 virtual void OnSwapBuffersCompleteOnImplThread() = 0;
52 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
53 base::TimeDelta interval) = 0;
[email protected]7ed47512013-03-26 22:28:4554 virtual void DidVSync(base::TimeTicks frame_time) = 0;
[email protected]c1bb5af2013-03-13 19:06:2755 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
56 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) = 0;
57 virtual void SetNeedsRedrawOnImplThread() = 0;
[email protected]86126792013-03-16 20:07:5458 virtual void DidInitializeVisibleTileOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:2759 virtual void SetNeedsCommitOnImplThread() = 0;
60 virtual void SetNeedsManageTilesOnImplThread() = 0;
61 virtual void PostAnimationEventsToMainThreadOnImplThread(
62 scoped_ptr<AnimationEventsVector> events,
63 base::Time wall_clock_time) = 0;
64 // Returns true if resources were deleted by this call.
65 virtual bool ReduceContentsTextureMemoryOnImplThread(
66 size_t limit_bytes,
67 int priority_cutoff) = 0;
68 virtual void ReduceWastedContentsTextureMemoryOnImplThread() = 0;
69 virtual void SendManagedMemoryStats() = 0;
70 virtual bool IsInsideDraw() = 0;
71 virtual void RenewTreePriority() = 0;
[email protected]0fc818e2013-03-18 06:45:2072 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
[email protected]bf691c22013-03-26 21:15:0673
74 protected:
75 virtual ~LayerTreeHostImplClient() {}
[email protected]cd57cc5a2012-10-12 22:43:4176};
77
[email protected]c1bb5af2013-03-13 19:06:2778// LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
79// state.
[email protected]52347c842012-11-02 21:06:2080class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
81 public RendererClient,
[email protected]8947cbe2012-11-28 05:27:4382 public TileManagerClient,
[email protected]3ba4cae2013-01-16 03:58:3883 public OutputSurfaceClient,
84 public TopControlsManagerClient {
[email protected]e216fef02013-03-20 22:56:1085 public:
[email protected]c1bb5af2013-03-13 19:06:2786 typedef std::vector<LayerImpl*> LayerList;
[email protected]cd57cc5a2012-10-12 22:43:4187
[email protected]c1bb5af2013-03-13 19:06:2788 static scoped_ptr<LayerTreeHostImpl> Create(
89 const LayerTreeSettings& settings,
90 LayerTreeHostImplClient* client,
[email protected]372bad5f2013-03-21 16:38:4391 Proxy* proxy,
92 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:2793 virtual ~LayerTreeHostImpl();
[email protected]cd57cc5a2012-10-12 22:43:4194
[email protected]c1bb5af2013-03-13 19:06:2795 // InputHandlerClient implementation
96 virtual InputHandlerClient::ScrollStatus ScrollBegin(
97 gfx::Point viewport_point,
98 InputHandlerClient::ScrollInputType type) OVERRIDE;
99 virtual bool ScrollBy(gfx::Point viewport_point,
100 gfx::Vector2dF scroll_delta) OVERRIDE;
[email protected]be782f52013-03-23 21:36:14101 virtual bool ScrollVerticallyByPage(
102 gfx::Point viewport_point,
103 WebKit::WebScrollbar::ScrollDirection direction) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27104 virtual void ScrollEnd() OVERRIDE;
105 virtual void PinchGestureBegin() OVERRIDE;
106 virtual void PinchGestureUpdate(float magnify_delta,
107 gfx::Point anchor) OVERRIDE;
108 virtual void PinchGestureEnd() OVERRIDE;
109 virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
110 bool anchor_point,
111 float page_scale,
112 base::TimeTicks start_time,
113 base::TimeDelta duration) OVERRIDE;
114 virtual void ScheduleAnimation() OVERRIDE;
115 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41116
[email protected]c1bb5af2013-03-13 19:06:27117 // TopControlsManagerClient implementation.
118 virtual void setActiveTreeNeedsUpdateDrawProperties() OVERRIDE;
119 virtual void setNeedsRedraw() OVERRIDE;
120 virtual bool haveRootScrollLayer() const OVERRIDE;
[email protected]3ba4cae2013-01-16 03:58:38121
[email protected]0fc818e2013-03-18 06:45:20122 void StartScrollbarAnimation(base::TimeTicks now);
123
[email protected]c1bb5af2013-03-13 19:06:27124 struct CC_EXPORT FrameData : public RenderPassSink {
125 FrameData();
[email protected]ca2902e92013-03-28 01:45:35126 virtual ~FrameData();
[email protected]cd57cc5a2012-10-12 22:43:41127
[email protected]c1bb5af2013-03-13 19:06:27128 std::vector<gfx::Rect> occluding_screen_space_rects;
129 std::vector<gfx::Rect> non_occluding_screen_space_rects;
130 RenderPassList render_passes;
131 RenderPassIdHashMap render_passes_by_id;
132 const LayerList* render_surface_layer_list;
133 LayerList will_draw_layers;
134 bool contains_incomplete_tile;
[email protected]cd57cc5a2012-10-12 22:43:41135
[email protected]c1bb5af2013-03-13 19:06:27136 // RenderPassSink implementation.
137 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
138 };
[email protected]cd57cc5a2012-10-12 22:43:41139
[email protected]c1bb5af2013-03-13 19:06:27140 virtual void BeginCommit();
141 virtual void CommitComplete();
142 virtual void Animate(base::TimeTicks monotonic_time,
143 base::Time wall_clock_time);
[email protected]cd57cc5a2012-10-12 22:43:41144
[email protected]c1bb5af2013-03-13 19:06:27145 void ManageTiles();
[email protected]f8456612013-03-19 20:56:09146 void SetAnticipatedDrawTime(base::TimeTicks time);
[email protected]8947cbe2012-11-28 05:27:43147
[email protected]c1bb5af2013-03-13 19:06:27148 // Returns false if problems occured preparing the frame, and we should try
[email protected]ed511b8d2013-03-25 03:29:29149 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
[email protected]c1bb5af2013-03-13 19:06:27150 // must also be called, regardless of whether DrawLayers is called between the
151 // two.
152 virtual bool PrepareToDraw(FrameData* frame);
[email protected]f0c2a242013-03-15 19:34:52153 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
[email protected]c1bb5af2013-03-13 19:06:27154 // Must be called if and only if PrepareToDraw was called.
155 void DidDrawAllLayers(const FrameData& frame);
[email protected]cd57cc5a2012-10-12 22:43:41156
[email protected]c1bb5af2013-03-13 19:06:27157 const LayerTreeSettings& settings() const { return settings_; }
[email protected]cd57cc5a2012-10-12 22:43:41158
[email protected]ffb2720f2013-03-15 19:18:37159 // Returns the currently visible viewport size in DIP. This value excludes
160 // the URL bar and non-overlay scrollbars.
161 gfx::SizeF VisibleViewportSize() const;
162
[email protected]c1bb5af2013-03-13 19:06:27163 // RendererClient implementation
164 private:
165 virtual gfx::Size DeviceViewportSize() const OVERRIDE;
166 virtual const LayerTreeSettings& Settings() const OVERRIDE;
167 public:
168 virtual void DidLoseOutputSurface() OVERRIDE;
169 virtual void OnSwapBuffersComplete() OVERRIDE;
170 virtual void SetFullRootLayerDamage() OVERRIDE;
171 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
172 OVERRIDE;
173 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
174 OVERRIDE;
175 virtual bool HasImplThread() const OVERRIDE;
176 virtual bool ShouldClearRootRenderPass() const OVERRIDE;
177 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE;
[email protected]8947cbe2012-11-28 05:27:43178
[email protected]c1bb5af2013-03-13 19:06:27179 // TileManagerClient implementation.
180 virtual void ScheduleManageTiles() OVERRIDE;
[email protected]86126792013-03-16 20:07:54181 virtual void DidInitializeVisibleTile() OVERRIDE;
[email protected]cd57cc5a2012-10-12 22:43:41182
[email protected]c1bb5af2013-03-13 19:06:27183 // OutputSurfaceClient implementation.
184 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
185 base::TimeDelta interval) OVERRIDE;
[email protected]7ed47512013-03-26 22:28:45186 virtual void DidVSync(base::TimeTicks frame_time) OVERRIDE;
[email protected]c1bb5af2013-03-13 19:06:27187 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
188 OVERRIDE;
[email protected]3b31c6ac2012-12-06 21:27:29189
[email protected]c1bb5af2013-03-13 19:06:27190 // Called from LayerTreeImpl.
191 void OnCanDrawStateChangedForTree();
[email protected]cd57cc5a2012-10-12 22:43:41192
[email protected]c1bb5af2013-03-13 19:06:27193 // Implementation
194 bool CanDraw();
195 OutputSurface* output_surface() const { return output_surface_.get(); }
[email protected]cd57cc5a2012-10-12 22:43:41196
[email protected]c1bb5af2013-03-13 19:06:27197 std::string LayerTreeAsText() const;
198 std::string LayerTreeAsJson() const;
[email protected]cd57cc5a2012-10-12 22:43:41199
[email protected]c1bb5af2013-03-13 19:06:27200 void FinishAllRendering();
201 int SourceAnimationFrameNumber() const;
[email protected]cd57cc5a2012-10-12 22:43:41202
[email protected]c1bb5af2013-03-13 19:06:27203 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
204 bool IsContextLost();
205 TileManager* tile_manager() { return tile_manager_.get(); }
206 Renderer* renderer() { return renderer_.get(); }
207 const RendererCapabilities& GetRendererCapabilities() const;
[email protected]cd57cc5a2012-10-12 22:43:41208
[email protected]a7252f12013-03-15 04:57:34209 virtual bool SwapBuffers();
[email protected]7ed47512013-03-26 22:28:45210 void EnableVSyncNotification(bool enable);
[email protected]cd57cc5a2012-10-12 22:43:41211
[email protected]c1bb5af2013-03-13 19:06:27212 void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
[email protected]cd57cc5a2012-10-12 22:43:41213
[email protected]c1bb5af2013-03-13 19:06:27214 LayerTreeImpl* active_tree() { return active_tree_.get(); }
215 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
216 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
217 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
218 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
219 void CreatePendingTree();
220 void CheckForCompletedTileUploads();
221 virtual bool ActivatePendingTreeIfNeeded();
[email protected]cd57cc5a2012-10-12 22:43:41222
[email protected]c1bb5af2013-03-13 19:06:27223 // Shortcuts to layers on the active tree.
224 LayerImpl* RootLayer() const;
225 LayerImpl* RootScrollLayer() const;
226 LayerImpl* CurrentlyScrollingLayer() const;
[email protected]cd57cc5a2012-10-12 22:43:41227
[email protected]c1bb5af2013-03-13 19:06:27228 virtual void SetVisible(bool visible);
229 bool visible() const { return visible_; }
[email protected]cd57cc5a2012-10-12 22:43:41230
[email protected]d7eb8c72013-03-23 22:57:13231 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
232
[email protected]c1bb5af2013-03-13 19:06:27233 size_t memory_allocation_limit_bytes() const {
[email protected]46b8acc2013-03-19 22:38:35234 return managed_memory_policy_.bytes_limit_when_visible;
[email protected]c1bb5af2013-03-13 19:06:27235 }
[email protected]cd57cc5a2012-10-12 22:43:41236
[email protected]c1bb5af2013-03-13 19:06:27237 void SetViewportSize(gfx::Size layout_viewport_size,
238 gfx::Size device_viewport_size);
239 gfx::Size layout_viewport_size() const { return layout_viewport_size_; }
240 gfx::Size device_viewport_size() const { return device_viewport_size_; }
[email protected]cd57cc5a2012-10-12 22:43:41241
[email protected]d9083762013-03-24 01:36:40242 void SetOverdrawBottomHeight(float overdraw_bottom_height);
243 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
244
[email protected]c1bb5af2013-03-13 19:06:27245 void SetDeviceScaleFactor(float device_scale_factor);
246 float device_scale_factor() const { return device_scale_factor_; }
[email protected]cd57cc5a2012-10-12 22:43:41247
[email protected]c1bb5af2013-03-13 19:06:27248 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
[email protected]cd57cc5a2012-10-12 22:43:41249
[email protected]c1bb5af2013-03-13 19:06:27250 void StartPageScaleAnimation(gfx::Vector2d target_offset,
251 bool use_anchor,
252 float scale,
253 base::TimeDelta duration);
[email protected]cd57cc5a2012-10-12 22:43:41254
[email protected]c1bb5af2013-03-13 19:06:27255 bool needs_animate_layers() const {
256 return !animation_registrar_->active_animation_controllers().empty();
257 }
[email protected]cd57cc5a2012-10-12 22:43:41258
[email protected]c1bb5af2013-03-13 19:06:27259 void SendManagedMemoryStats(
260 size_t memory_visible_bytes,
261 size_t memory_visible_and_nearby_bytes,
[email protected]ed511b8d2013-03-25 03:29:29262 size_t memory_use_bytes);
[email protected]c1bb5af2013-03-13 19:06:27263
264 FrameRateCounter* fps_counter() {
265 return fps_counter_.get();
266 }
267 PaintTimeCounter* paint_time_counter() {
268 return paint_time_counter_.get();
269 }
270 MemoryHistory* memory_history() {
271 return memory_history_.get();
272 }
273 DebugRectHistory* debug_rect_history() {
274 return debug_rect_history_.get();
275 }
276 ResourceProvider* resource_provider() {
277 return resource_provider_.get();
278 }
279 TopControlsManager* top_controls_manager() {
280 return top_controls_manager_.get();
281 }
[email protected]ff762fb2012-12-12 19:18:37282
[email protected]c1bb5af2013-03-13 19:06:27283 Proxy* proxy() const { return proxy_; }
[email protected]cd57cc5a2012-10-12 22:43:41284
[email protected]c1bb5af2013-03-13 19:06:27285 AnimationRegistrar* animation_registrar() const {
286 return animation_registrar_.get();
287 }
[email protected]de4afb5e2012-12-20 00:11:34288
[email protected]c1bb5af2013-03-13 19:06:27289 void SetDebugState(const LayerTreeDebugState& debug_state);
290 const LayerTreeDebugState& debug_state() const { return debug_state_; }
[email protected]f511afb2012-11-30 01:55:20291
[email protected]c1bb5af2013-03-13 19:06:27292 class CC_EXPORT CullRenderPassesWithCachedTextures {
293 public:
294 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
295 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41296
[email protected]c1bb5af2013-03-13 19:06:27297 // Iterates from the root first, in order to remove the surfaces closest
298 // to the root with cached textures, and all surfaces that draw into
299 // them.
300 size_t RenderPassListBegin(const RenderPassList& list) const {
301 return list.size() - 1;
302 }
303 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
304 size_t RenderPassListNext(size_t it) const { return it - 1; }
[email protected]cd57cc5a2012-10-12 22:43:41305
[email protected]bf691c22013-03-26 21:15:06306 explicit CullRenderPassesWithCachedTextures(Renderer* renderer)
[email protected]c1bb5af2013-03-13 19:06:27307 : renderer_(renderer) {}
308 private:
[email protected]bf691c22013-03-26 21:15:06309 Renderer* renderer_;
[email protected]c1bb5af2013-03-13 19:06:27310 };
[email protected]cd57cc5a2012-10-12 22:43:41311
[email protected]c1bb5af2013-03-13 19:06:27312 class CC_EXPORT CullRenderPassesWithNoQuads {
313 public:
314 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
315 const FrameData& frame) const;
[email protected]cd57cc5a2012-10-12 22:43:41316
[email protected]c1bb5af2013-03-13 19:06:27317 // Iterates in draw order, so that when a surface is removed, and its
318 // target becomes empty, then its target can be removed also.
319 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
320 size_t RenderPassListEnd(const RenderPassList& list) const {
321 return list.size();
322 }
323 size_t RenderPassListNext(size_t it) const { return it + 1; }
324 };
[email protected]cd57cc5a2012-10-12 22:43:41325
[email protected]c1bb5af2013-03-13 19:06:27326 template <typename RenderPassCuller>
327 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41328
[email protected]c1bb5af2013-03-13 19:06:27329 skia::RefPtr<SkPicture> CapturePicture();
[email protected]b9dcf43a2013-01-09 00:15:29330
[email protected]c1bb5af2013-03-13 19:06:27331 bool pinch_gesture_active() const { return pinch_gesture_active_; }
[email protected]166db5c82013-01-09 23:54:31332
[email protected]c1bb5af2013-03-13 19:06:27333 void SetTreePriority(TreePriority priority);
[email protected]362f1e8b2013-01-21 16:54:30334
[email protected]c1bb5af2013-03-13 19:06:27335 void BeginNextFrame();
336 base::TimeTicks CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10337
[email protected]c1bb5af2013-03-13 19:06:27338 scoped_ptr<base::Value> AsValue() const;
339 scoped_ptr<base::Value> ActivationStateAsValue() const;
340 scoped_ptr<base::Value> FrameStateAsValue() const;
[email protected]131a0c22013-02-12 18:31:08341
[email protected]c1bb5af2013-03-13 19:06:27342 bool page_scale_animation_active() const { return !!page_scale_animation_; }
[email protected]498ddd02013-02-28 23:59:25343
[email protected]c1bb5af2013-03-13 19:06:27344 protected:
[email protected]372bad5f2013-03-21 16:38:43345 LayerTreeHostImpl(
346 const LayerTreeSettings& settings,
347 LayerTreeHostImplClient* client,
348 Proxy* proxy,
349 RenderingStatsInstrumentation* rendering_stats_instrumentation);
[email protected]c1bb5af2013-03-13 19:06:27350 void ActivatePendingTree();
[email protected]cd57cc5a2012-10-12 22:43:41351
[email protected]c1bb5af2013-03-13 19:06:27352 // Virtual for testing.
353 virtual void AnimateLayers(base::TimeTicks monotonic_time,
354 base::Time wall_clock_time);
355 virtual void UpdateAnimationState();
[email protected]cd57cc5a2012-10-12 22:43:41356
[email protected]c1bb5af2013-03-13 19:06:27357 // Virtual for testing.
358 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
[email protected]cd57cc5a2012-10-12 22:43:41359
[email protected]c1bb5af2013-03-13 19:06:27360 const AnimationRegistrar::AnimationControllerMap&
361 active_animation_controllers() const {
362 return animation_registrar_->active_animation_controllers();
363 }
[email protected]de4afb5e2012-12-20 00:11:34364
[email protected]c1bb5af2013-03-13 19:06:27365 LayerTreeHostImplClient* client_;
366 Proxy* proxy_;
[email protected]cd57cc5a2012-10-12 22:43:41367
[email protected]c1bb5af2013-03-13 19:06:27368 private:
369 void AnimatePageScale(base::TimeTicks monotonic_time);
370 void AnimateScrollbars(base::TimeTicks monotonic_time);
[email protected]ffb2720f2013-03-15 19:18:37371 void AnimateTopControls(base::TimeTicks monotonic_time);
[email protected]2d692992012-12-19 01:19:32372
[email protected]c1bb5af2013-03-13 19:06:27373 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
[email protected]ed511b8d2013-03-25 03:29:29374 LayerImpl* layer_impl,
375 float scale_from_viewport_to_screen_space,
376 gfx::PointF viewport_point,
377 gfx::Vector2dF viewport_delta);
[email protected]615c78a2013-01-24 23:44:16378
[email protected]c1bb5af2013-03-13 19:06:27379 void UpdateMaxScrollOffset();
380 void TrackDamageForAllSurfaces(LayerImpl* root_draw_layer,
381 const LayerList& render_surface_layer_list);
[email protected]cd57cc5a2012-10-12 22:43:41382
[email protected]c1bb5af2013-03-13 19:06:27383 // Returns false if the frame should not be displayed. This function should
[email protected]ed511b8d2013-03-25 03:29:29384 // only be called from PrepareToDraw, as DidDrawAllLayers must be called
[email protected]c1bb5af2013-03-13 19:06:27385 // if this helper function is called.
386 bool CalculateRenderPasses(FrameData* frame);
387 void SetBackgroundTickingEnabled(bool enabled);
[email protected]cd57cc5a2012-10-12 22:43:41388
[email protected]c1bb5af2013-03-13 19:06:27389 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current);
390 void ClearRenderSurfaces();
391 bool EnsureRenderSurfaceLayerList();
392 void ClearCurrentlyScrollingLayer();
[email protected]cd57cc5a2012-10-12 22:43:41393
[email protected]c1bb5af2013-03-13 19:06:27394 void AnimateScrollbarsRecursive(LayerImpl* layer,
395 base::TimeTicks time);
[email protected]cd57cc5a2012-10-12 22:43:41396
[email protected]c1bb5af2013-03-13 19:06:27397 void DumpRenderSurfaces(std::string* str,
398 int indent,
399 const LayerImpl* layer) const;
[email protected]cd57cc5a2012-10-12 22:43:41400
[email protected]c1bb5af2013-03-13 19:06:27401 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer);
[email protected]b9dcf43a2013-01-09 00:15:29402
[email protected]0fc818e2013-03-18 06:45:20403 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
404
[email protected]c1bb5af2013-03-13 19:06:27405 scoped_ptr<OutputSurface> output_surface_;
406 scoped_ptr<ResourceProvider> resource_provider_;
407 scoped_ptr<Renderer> renderer_;
408 scoped_ptr<TileManager> tile_manager_;
[email protected]3b31c6ac2012-12-06 21:27:29409
[email protected]c1bb5af2013-03-13 19:06:27410 // Tree currently being drawn.
411 scoped_ptr<LayerTreeImpl> active_tree_;
[email protected]3b31c6ac2012-12-06 21:27:29412
[email protected]c1bb5af2013-03-13 19:06:27413 // In impl-side painting mode, tree with possibly incomplete rasterized
414 // content. May be promoted to active by ActivatePendingTreeIfNeeded().
415 scoped_ptr<LayerTreeImpl> pending_tree_;
[email protected]48871fc2013-01-23 07:36:51416
[email protected]c1bb5af2013-03-13 19:06:27417 // In impl-side painting mode, inert tree with layers that can be recycled
418 // by the next sync from the main thread.
419 scoped_ptr<LayerTreeImpl> recycle_tree_;
[email protected]48871fc2013-01-23 07:36:51420
[email protected]c1bb5af2013-03-13 19:06:27421 bool did_lock_scrolling_layer_;
422 bool should_bubble_scrolls_;
423 bool wheel_scrolling_;
424 LayerTreeSettings settings_;
425 LayerTreeDebugState debug_state_;
426 gfx::Size layout_viewport_size_;
427 gfx::Size device_viewport_size_;
[email protected]d9083762013-03-24 01:36:40428 float overdraw_bottom_height_;
[email protected]c1bb5af2013-03-13 19:06:27429 float device_scale_factor_;
430 bool visible_;
431 ManagedMemoryPolicy managed_memory_policy_;
[email protected]cd57cc5a2012-10-12 22:43:41432
[email protected]c1bb5af2013-03-13 19:06:27433 bool pinch_gesture_active_;
434 gfx::Point previous_pinch_anchor_;
[email protected]cd57cc5a2012-10-12 22:43:41435
[email protected]c1bb5af2013-03-13 19:06:27436 // This is set by AnimateLayers() and used by UpdateAnimationState()
437 // when sending animation events to the main thread.
438 base::Time last_animation_time_;
[email protected]6ad55bb22013-02-08 21:34:33439
[email protected]c1bb5af2013-03-13 19:06:27440 scoped_ptr<TopControlsManager> top_controls_manager_;
[email protected]3ba4cae2013-01-16 03:58:38441
[email protected]c1bb5af2013-03-13 19:06:27442 scoped_ptr<PageScaleAnimation> page_scale_animation_;
[email protected]cd57cc5a2012-10-12 22:43:41443
[email protected]c1bb5af2013-03-13 19:06:27444 // This is used for ticking animations slowly when hidden.
445 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
[email protected]cd57cc5a2012-10-12 22:43:41446
[email protected]c1bb5af2013-03-13 19:06:27447 scoped_ptr<FrameRateCounter> fps_counter_;
448 scoped_ptr<PaintTimeCounter> paint_time_counter_;
449 scoped_ptr<MemoryHistory> memory_history_;
450 scoped_ptr<DebugRectHistory> debug_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:41451
[email protected]c1bb5af2013-03-13 19:06:27452 size_t last_sent_memory_visible_bytes_;
453 size_t last_sent_memory_visible_and_nearby_bytes_;
454 size_t last_sent_memory_use_bytes_;
[email protected]d3afa112012-12-08 06:24:28455
[email protected]c1bb5af2013-03-13 19:06:27456 base::TimeTicks current_frame_time_;
[email protected]829ad972013-01-28 23:36:10457
[email protected]c1bb5af2013-03-13 19:06:27458 scoped_ptr<AnimationRegistrar> animation_registrar_;
[email protected]de4afb5e2012-12-20 00:11:34459
[email protected]372bad5f2013-03-21 16:38:43460 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
461
[email protected]c1bb5af2013-03-13 19:06:27462 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
[email protected]cd57cc5a2012-10-12 22:43:41463};
464
[email protected]0023e8b2012-10-15 12:52:45465} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:41466
[email protected]556fd292013-03-18 08:03:04467#endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_