OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 LayerImplList will_draw_layers; | 151 LayerImplList will_draw_layers; |
152 bool contains_incomplete_tile; | 152 bool contains_incomplete_tile; |
153 bool has_no_damage; | 153 bool has_no_damage; |
154 | 154 |
155 // RenderPassSink implementation. | 155 // RenderPassSink implementation. |
156 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; | 156 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; |
157 }; | 157 }; |
158 | 158 |
159 virtual void BeginCommit(); | 159 virtual void BeginCommit(); |
160 virtual void CommitComplete(); | 160 virtual void CommitComplete(); |
161 virtual void Animate(base::TimeTicks monotonic_time, | 161 virtual void Animate(gfx::FrameTime monotonic_time, |
162 base::Time wall_clock_time); | 162 base::Time wall_clock_time); |
163 virtual void UpdateAnimationState(bool start_ready_animations); | 163 virtual void UpdateAnimationState(bool start_ready_animations); |
164 void MainThreadHasStoppedFlinging(); | 164 void MainThreadHasStoppedFlinging(); |
165 void UpdateBackgroundAnimateTicking(bool should_background_tick); | 165 void UpdateBackgroundAnimateTicking(bool should_background_tick); |
166 void SetViewportDamage(gfx::Rect damage_rect); | 166 void SetViewportDamage(gfx::Rect damage_rect); |
167 | 167 |
168 virtual void ManageTiles(); | 168 virtual void ManageTiles(); |
169 | 169 |
170 // Returns false if problems occured preparing the frame, and we should try | 170 // Returns false if problems occured preparing the frame, and we should try |
171 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers | 171 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers |
172 // must also be called, regardless of whether DrawLayers is called between the | 172 // must also be called, regardless of whether DrawLayers is called between the |
173 // two. | 173 // two. |
174 virtual bool PrepareToDraw(FrameData* frame, | 174 virtual bool PrepareToDraw(FrameData* frame, |
175 gfx::Rect device_viewport_damage_rect); | 175 gfx::Rect device_viewport_damage_rect); |
176 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time); | 176 virtual void DrawLayers(FrameData* frame, gfx::FrameTime frame_begin_time); |
177 // Must be called if and only if PrepareToDraw was called. | 177 // Must be called if and only if PrepareToDraw was called. |
178 void DidDrawAllLayers(const FrameData& frame); | 178 void DidDrawAllLayers(const FrameData& frame); |
179 | 179 |
180 const LayerTreeSettings& settings() const { return settings_; } | 180 const LayerTreeSettings& settings() const { return settings_; } |
181 | 181 |
182 // Evict all textures by enforcing a memory policy with an allocation of 0. | 182 // Evict all textures by enforcing a memory policy with an allocation of 0. |
183 void EvictTexturesForTesting(); | 183 void EvictTexturesForTesting(); |
184 | 184 |
185 // When blocking, this prevents client_->NotifyReadyToActivate() from being | 185 // When blocking, this prevents client_->NotifyReadyToActivate() from being |
186 // called. When disabled, it calls client_->NotifyReadyToActivate() | 186 // called. When disabled, it calls client_->NotifyReadyToActivate() |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 gfx::Vector2dF current_fling_velocity() const { | 375 gfx::Vector2dF current_fling_velocity() const { |
376 return current_fling_velocity_; | 376 return current_fling_velocity_; |
377 } | 377 } |
378 | 378 |
379 bool pinch_gesture_active() const { return pinch_gesture_active_; } | 379 bool pinch_gesture_active() const { return pinch_gesture_active_; } |
380 | 380 |
381 void SetTreePriority(TreePriority priority); | 381 void SetTreePriority(TreePriority priority); |
382 | 382 |
383 void ResetCurrentFrameTimeForNextFrame(); | 383 void ResetCurrentFrameTimeForNextFrame(); |
384 virtual base::TimeTicks CurrentFrameTimeTicks(); | 384 virtual gfx::FrameTime CurrentFrameTimeTicks(); |
385 base::Time CurrentFrameTime(); | 385 base::Time CurrentFrameTime(); |
386 | 386 |
387 virtual base::TimeTicks CurrentPhysicalTimeTicks() const; | 387 virtual gfx::FrameTime CurrentPhysicalFrameTime() const; |
388 | 388 |
389 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } | 389 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } |
390 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; | 390 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; |
391 scoped_ptr<base::Value> ActivationStateAsValue() const; | 391 scoped_ptr<base::Value> ActivationStateAsValue() const; |
392 | 392 |
393 bool page_scale_animation_active() const { return !!page_scale_animation_; } | 393 bool page_scale_animation_active() const { return !!page_scale_animation_; } |
394 | 394 |
395 virtual void CreateUIResource(UIResourceId uid, | 395 virtual void CreateUIResource(UIResourceId uid, |
396 const UIResourceBitmap& bitmap); | 396 const UIResourceBitmap& bitmap); |
397 // Deletes a UI resource. May safely be called more than once. | 397 // Deletes a UI resource. May safely be called more than once. |
(...skipping 11 matching lines...) Expand all Loading... |
409 | 409 |
410 protected: | 410 protected: |
411 LayerTreeHostImpl( | 411 LayerTreeHostImpl( |
412 const LayerTreeSettings& settings, | 412 const LayerTreeSettings& settings, |
413 LayerTreeHostImplClient* client, | 413 LayerTreeHostImplClient* client, |
414 Proxy* proxy, | 414 Proxy* proxy, |
415 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 415 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
416 SharedBitmapManager* manager); | 416 SharedBitmapManager* manager); |
417 | 417 |
418 // Virtual for testing. | 418 // Virtual for testing. |
419 virtual void AnimateLayers(base::TimeTicks monotonic_time, | 419 virtual void AnimateLayers(gfx::FrameTime monotonic_time, |
420 base::Time wall_clock_time); | 420 base::Time wall_clock_time); |
421 | 421 |
422 // Virtual for testing. | 422 // Virtual for testing. |
423 virtual base::TimeDelta LowFrequencyAnimationInterval() const; | 423 virtual base::TimeDelta LowFrequencyAnimationInterval() const; |
424 | 424 |
425 const AnimationRegistrar::AnimationControllerMap& | 425 const AnimationRegistrar::AnimationControllerMap& |
426 active_animation_controllers() const { | 426 active_animation_controllers() const { |
427 return animation_registrar_->active_animation_controllers(); | 427 return animation_registrar_->active_animation_controllers(); |
428 } | 428 } |
429 | 429 |
430 bool manage_tiles_needed() const { return tile_priorities_dirty_; } | 430 bool manage_tiles_needed() const { return tile_priorities_dirty_; } |
431 | 431 |
432 LayerTreeHostImplClient* client_; | 432 LayerTreeHostImplClient* client_; |
433 Proxy* proxy_; | 433 Proxy* proxy_; |
434 | 434 |
435 private: | 435 private: |
436 void CreateAndSetRenderer( | 436 void CreateAndSetRenderer( |
437 OutputSurface* output_surface, | 437 OutputSurface* output_surface, |
438 ResourceProvider* resource_provider, | 438 ResourceProvider* resource_provider, |
439 bool skip_gl_renderer); | 439 bool skip_gl_renderer); |
440 void CreateAndSetTileManager(ResourceProvider* resource_provider, | 440 void CreateAndSetTileManager(ResourceProvider* resource_provider, |
441 ContextProvider* context_provider, | 441 ContextProvider* context_provider, |
442 bool using_map_image); | 442 bool using_map_image); |
443 void ReleaseTreeResources(); | 443 void ReleaseTreeResources(); |
444 void EnforceZeroBudget(bool zero_budget); | 444 void EnforceZeroBudget(bool zero_budget); |
445 | 445 |
446 void AnimatePageScale(base::TimeTicks monotonic_time); | 446 void AnimatePageScale(gfx::FrameTime monotonic_time); |
447 void AnimateScrollbars(base::TimeTicks monotonic_time); | 447 void AnimateScrollbars(gfx::FrameTime monotonic_time); |
448 void AnimateTopControls(base::TimeTicks monotonic_time); | 448 void AnimateTopControls(gfx::FrameTime monotonic_time); |
449 | 449 |
450 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( | 450 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( |
451 LayerImpl* layer_impl, | 451 LayerImpl* layer_impl, |
452 float scale_from_viewport_to_screen_space, | 452 float scale_from_viewport_to_screen_space, |
453 gfx::PointF viewport_point, | 453 gfx::PointF viewport_point, |
454 gfx::Vector2dF viewport_delta); | 454 gfx::Vector2dF viewport_delta); |
455 | 455 |
456 void UpdateMaxScrollOffset(); | 456 void UpdateMaxScrollOffset(); |
457 void TrackDamageForAllSurfaces( | 457 void TrackDamageForAllSurfaces( |
458 LayerImpl* root_draw_layer, | 458 LayerImpl* root_draw_layer, |
459 const LayerImplList& render_surface_layer_list); | 459 const LayerImplList& render_surface_layer_list); |
460 | 460 |
461 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy); | 461 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy); |
462 | 462 |
463 // Returns false if the frame should not be displayed. This function should | 463 // Returns false if the frame should not be displayed. This function should |
464 // only be called from PrepareToDraw, as DidDrawAllLayers must be called | 464 // only be called from PrepareToDraw, as DidDrawAllLayers must be called |
465 // if this helper function is called. | 465 // if this helper function is called. |
466 bool CalculateRenderPasses(FrameData* frame); | 466 bool CalculateRenderPasses(FrameData* frame); |
467 | 467 |
468 void SendReleaseResourcesRecursive(LayerImpl* current); | 468 void SendReleaseResourcesRecursive(LayerImpl* current); |
469 bool EnsureRenderSurfaceLayerList(); | 469 bool EnsureRenderSurfaceLayerList(); |
470 void ClearCurrentlyScrollingLayer(); | 470 void ClearCurrentlyScrollingLayer(); |
471 | 471 |
472 bool HandleMouseOverScrollbar(LayerImpl* layer_impl, | 472 bool HandleMouseOverScrollbar(LayerImpl* layer_impl, |
473 gfx::PointF device_viewport_point); | 473 gfx::PointF device_viewport_point); |
474 | 474 |
475 void AnimateScrollbarsRecursive(LayerImpl* layer, | 475 void AnimateScrollbarsRecursive(LayerImpl* layer, |
476 base::TimeTicks time); | 476 gfx::FrameTime time); |
477 | 477 |
478 void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) const; | 478 void UpdateCurrentFrameTime(gfx::FrameTime *ticks, base::Time* now) const; |
479 | 479 |
480 LayerImpl* FindScrollLayerForDeviceViewportPoint( | 480 LayerImpl* FindScrollLayerForDeviceViewportPoint( |
481 gfx::PointF device_viewport_point, | 481 gfx::PointF device_viewport_point, |
482 InputHandler::ScrollInputType type, | 482 InputHandler::ScrollInputType type, |
483 LayerImpl* layer_hit_by_point, | 483 LayerImpl* layer_hit_by_point, |
484 bool* scroll_on_main_thread) const; | 484 bool* scroll_on_main_thread) const; |
485 float DeviceSpaceDistanceToLayer(gfx::PointF device_viewport_point, | 485 float DeviceSpaceDistanceToLayer(gfx::PointF device_viewport_point, |
486 LayerImpl* layer_impl); | 486 LayerImpl* layer_impl); |
487 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time); | 487 void StartScrollbarAnimationRecursive(LayerImpl* layer, |
| 488 gfx::FrameTime time); |
488 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy, | 489 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy, |
489 bool zero_budget); | 490 bool zero_budget); |
490 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy); | 491 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy); |
491 | 492 |
492 void DidInitializeVisibleTile(); | 493 void DidInitializeVisibleTile(); |
493 | 494 |
494 void MarkUIResourceNotEvicted(UIResourceId uid); | 495 void MarkUIResourceNotEvicted(UIResourceId uid); |
495 | 496 |
496 typedef base::hash_map<UIResourceId, UIResourceData> | 497 typedef base::hash_map<UIResourceId, UIResourceData> |
497 UIResourceMap; | 498 UIResourceMap; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 // (When these are specified, device_viewport_size_ remains used only for | 604 // (When these are specified, device_viewport_size_ remains used only for |
604 // scrollable size.) | 605 // scrollable size.) |
605 gfx::Transform external_transform_; | 606 gfx::Transform external_transform_; |
606 gfx::Rect external_viewport_; | 607 gfx::Rect external_viewport_; |
607 gfx::Rect external_clip_; | 608 gfx::Rect external_clip_; |
608 bool device_viewport_valid_for_tile_management_; | 609 bool device_viewport_valid_for_tile_management_; |
609 bool external_stencil_test_enabled_; | 610 bool external_stencil_test_enabled_; |
610 | 611 |
611 gfx::Rect viewport_damage_rect_; | 612 gfx::Rect viewport_damage_rect_; |
612 | 613 |
613 base::TimeTicks current_frame_timeticks_; | 614 gfx::FrameTime current_frame_timeticks_; |
614 base::Time current_frame_time_; | 615 base::Time current_frame_time_; |
615 | 616 |
616 scoped_ptr<AnimationRegistrar> animation_registrar_; | 617 scoped_ptr<AnimationRegistrar> animation_registrar_; |
617 | 618 |
618 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 619 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
619 | 620 |
620 bool need_to_update_visible_tiles_before_draw_; | 621 bool need_to_update_visible_tiles_before_draw_; |
621 | 622 |
622 // Optional callback to notify of new tree activations. | 623 // Optional callback to notify of new tree activations. |
623 base::Closure tree_activation_callback_; | 624 base::Closure tree_activation_callback_; |
624 | 625 |
625 SharedBitmapManager* shared_bitmap_manager_; | 626 SharedBitmapManager* shared_bitmap_manager_; |
626 | 627 |
627 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 628 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
628 }; | 629 }; |
629 | 630 |
630 } // namespace cc | 631 } // namespace cc |
631 | 632 |
632 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 633 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |