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