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 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "cc/layers/scrollbar_layer.h" | 30 #include "cc/layers/scrollbar_layer.h" |
31 #include "cc/resources/prioritized_resource_manager.h" | 31 #include "cc/resources/prioritized_resource_manager.h" |
32 #include "cc/trees/layer_tree_host_client.h" | 32 #include "cc/trees/layer_tree_host_client.h" |
33 #include "cc/trees/layer_tree_host_common.h" | 33 #include "cc/trees/layer_tree_host_common.h" |
34 #include "cc/trees/layer_tree_host_impl.h" | 34 #include "cc/trees/layer_tree_host_impl.h" |
35 #include "cc/trees/layer_tree_impl.h" | 35 #include "cc/trees/layer_tree_impl.h" |
36 #include "cc/trees/occlusion_tracker.h" | 36 #include "cc/trees/occlusion_tracker.h" |
37 #include "cc/trees/single_thread_proxy.h" | 37 #include "cc/trees/single_thread_proxy.h" |
38 #include "cc/trees/thread_proxy.h" | 38 #include "cc/trees/thread_proxy.h" |
39 #include "cc/trees/tree_synchronizer.h" | 39 #include "cc/trees/tree_synchronizer.h" |
| 40 #include "ui/gfx/size_conversions.h" |
40 | 41 |
41 namespace { | 42 namespace { |
42 static int s_num_layer_tree_instances; | 43 static int s_num_layer_tree_instances; |
43 } | 44 } |
44 | 45 |
45 namespace cc { | 46 namespace cc { |
46 | 47 |
47 RendererCapabilities::RendererCapabilities() | 48 RendererCapabilities::RendererCapabilities() |
48 : best_texture_format(0), | 49 : best_texture_format(0), |
49 using_partial_swap(false), | 50 using_partial_swap(false), |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 page_scale_delta = sync_tree->page_scale_delta(); | 336 page_scale_delta = sync_tree->page_scale_delta(); |
336 sent_page_scale_delta = sync_tree->sent_page_scale_delta(); | 337 sent_page_scale_delta = sync_tree->sent_page_scale_delta(); |
337 sync_tree->set_sent_page_scale_delta(1.f); | 338 sync_tree->set_sent_page_scale_delta(1.f); |
338 } | 339 } |
339 | 340 |
340 sync_tree->SetPageScaleFactorAndLimits(page_scale_factor_, | 341 sync_tree->SetPageScaleFactorAndLimits(page_scale_factor_, |
341 min_page_scale_factor_, | 342 min_page_scale_factor_, |
342 max_page_scale_factor_); | 343 max_page_scale_factor_); |
343 sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); | 344 sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); |
344 | 345 |
345 host_impl->SetViewportSize(layout_viewport_size_, device_viewport_size_); | 346 host_impl->SetViewportSize(device_viewport_size_); |
346 host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_); | 347 host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_); |
347 host_impl->SetDeviceScaleFactor(device_scale_factor_); | 348 host_impl->SetDeviceScaleFactor(device_scale_factor_); |
348 host_impl->SetDebugState(debug_state_); | 349 host_impl->SetDebugState(debug_state_); |
349 if (pending_page_scale_animation_) { | 350 if (pending_page_scale_animation_) { |
350 host_impl->StartPageScaleAnimation( | 351 host_impl->StartPageScaleAnimation( |
351 pending_page_scale_animation_->target_offset, | 352 pending_page_scale_animation_->target_offset, |
352 pending_page_scale_animation_->use_anchor, | 353 pending_page_scale_animation_->use_anchor, |
353 pending_page_scale_animation_->scale, | 354 pending_page_scale_animation_->scale, |
354 base::TimeTicks::Now(), | 355 base::TimeTicks::Now(), |
355 pending_page_scale_animation_->duration); | 356 pending_page_scale_animation_->duration); |
(...skipping 17 matching lines...) Expand all Loading... |
373 | 374 |
374 if (!settings_.impl_side_painting) { | 375 if (!settings_.impl_side_painting) { |
375 // If we're not in impl-side painting, the tree is immediately | 376 // If we're not in impl-side painting, the tree is immediately |
376 // considered active. | 377 // considered active. |
377 sync_tree->DidBecomeActive(); | 378 sync_tree->DidBecomeActive(); |
378 } | 379 } |
379 | 380 |
380 commit_number_++; | 381 commit_number_++; |
381 } | 382 } |
382 | 383 |
| 384 gfx::Size LayerTreeHost::PinchZoomScrollbarSize( |
| 385 WebKit::WebScrollbar::Orientation orientation) const { |
| 386 gfx::Size viewport_size = gfx::ToCeiledSize( |
| 387 gfx::ScaleSize(device_viewport_size(), 1.f / device_scale_factor())); |
| 388 gfx::Size size; |
| 389 int track_width = PinchZoomScrollbarGeometry::kTrackWidth; |
| 390 if (orientation == WebKit::WebScrollbar::Horizontal) |
| 391 size = gfx::Size(viewport_size.width() - track_width, track_width); |
| 392 else |
| 393 size = gfx::Size(track_width, viewport_size.height() - track_width); |
| 394 return size; |
| 395 } |
| 396 |
383 void LayerTreeHost::SetPinchZoomScrollbarsBoundsAndPosition() { | 397 void LayerTreeHost::SetPinchZoomScrollbarsBoundsAndPosition() { |
384 if (!pinch_zoom_scrollbar_horizontal_ || !pinch_zoom_scrollbar_vertical_) | 398 if (!pinch_zoom_scrollbar_horizontal_ || !pinch_zoom_scrollbar_vertical_) |
385 return; | 399 return; |
386 | 400 |
387 gfx::Size size = layout_viewport_size(); | 401 gfx::Size horizontal_size = |
388 int track_width = PinchZoomScrollbarGeometry::kTrackWidth; | 402 PinchZoomScrollbarSize(WebKit::WebScrollbar::Horizontal); |
| 403 gfx::Size vertical_size = |
| 404 PinchZoomScrollbarSize(WebKit::WebScrollbar::Vertical); |
389 | 405 |
390 pinch_zoom_scrollbar_horizontal_->SetBounds( | 406 pinch_zoom_scrollbar_horizontal_->SetBounds(horizontal_size); |
391 gfx::Size(size.width() - track_width, track_width)); | |
392 pinch_zoom_scrollbar_horizontal_->SetPosition( | 407 pinch_zoom_scrollbar_horizontal_->SetPosition( |
393 gfx::PointF(0, size.height() - track_width)); | 408 gfx::PointF(0, vertical_size.height())); |
394 | 409 pinch_zoom_scrollbar_vertical_->SetBounds(vertical_size); |
395 pinch_zoom_scrollbar_vertical_->SetBounds( | |
396 gfx::Size(track_width, size.height() - track_width)); | |
397 pinch_zoom_scrollbar_vertical_->SetPosition( | 410 pinch_zoom_scrollbar_vertical_->SetPosition( |
398 gfx::PointF(size.width() - track_width, 0)); | 411 gfx::PointF(horizontal_size.width(), 0)); |
399 } | 412 } |
400 | 413 |
401 static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar( | 414 static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar( |
402 WebKit::WebScrollbar::Orientation orientation, | 415 WebKit::WebScrollbar::Orientation orientation, |
403 LayerTreeHost* owner) { | 416 LayerTreeHost* owner) { |
404 scoped_refptr<ScrollbarLayer> scrollbar_layer = ScrollbarLayer::Create( | 417 scoped_refptr<ScrollbarLayer> scrollbar_layer = ScrollbarLayer::Create( |
405 make_scoped_ptr(new PinchZoomScrollbar(orientation, owner)). | 418 make_scoped_ptr(new PinchZoomScrollbar(orientation, owner)). |
406 PassAs<WebKit::WebScrollbar>(), | 419 PassAs<WebKit::WebScrollbar>(), |
407 scoped_ptr<ScrollbarThemePainter>(new PinchZoomScrollbarPainter).Pass(), | 420 scoped_ptr<ScrollbarThemePainter>(new PinchZoomScrollbarPainter).Pass(), |
408 scoped_ptr<WebKit::WebScrollbarThemeGeometry>( | 421 scoped_ptr<WebKit::WebScrollbarThemeGeometry>( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return; | 629 return; |
617 | 630 |
618 debug_state_ = new_debug_state; | 631 debug_state_ = new_debug_state; |
619 | 632 |
620 rendering_stats_instrumentation_->set_record_rendering_stats( | 633 rendering_stats_instrumentation_->set_record_rendering_stats( |
621 debug_state_.RecordRenderingStats()); | 634 debug_state_.RecordRenderingStats()); |
622 | 635 |
623 SetNeedsCommit(); | 636 SetNeedsCommit(); |
624 } | 637 } |
625 | 638 |
626 void LayerTreeHost::SetViewportSize(gfx::Size layout_viewport_size, | 639 void LayerTreeHost::SetViewportSize(gfx::Size device_viewport_size) { |
627 gfx::Size device_viewport_size) { | 640 if (device_viewport_size == device_viewport_size_) |
628 if (layout_viewport_size == layout_viewport_size_ && | |
629 device_viewport_size == device_viewport_size_) | |
630 return; | 641 return; |
631 | 642 |
632 layout_viewport_size_ = layout_viewport_size; | |
633 device_viewport_size_ = device_viewport_size; | 643 device_viewport_size_ = device_viewport_size; |
634 | 644 |
635 SetPinchZoomScrollbarsBoundsAndPosition(); | 645 SetPinchZoomScrollbarsBoundsAndPosition(); |
636 SetNeedsCommit(); | 646 SetNeedsCommit(); |
637 } | 647 } |
638 | 648 |
639 void LayerTreeHost::SetOverdrawBottomHeight(float overdraw_bottom_height) { | 649 void LayerTreeHost::SetOverdrawBottomHeight(float overdraw_bottom_height) { |
640 if (overdraw_bottom_height_ == overdraw_bottom_height) | 650 if (overdraw_bottom_height_ == overdraw_bottom_height) |
641 return; | 651 return; |
642 | 652 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 return true; | 715 return true; |
706 } | 716 } |
707 | 717 |
708 void LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue, | 718 void LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue, |
709 size_t memory_allocation_limit_bytes) { | 719 size_t memory_allocation_limit_bytes) { |
710 DCHECK(renderer_initialized_); | 720 DCHECK(renderer_initialized_); |
711 | 721 |
712 if (!root_layer()) | 722 if (!root_layer()) |
713 return; | 723 return; |
714 | 724 |
715 if (layout_viewport_size().IsEmpty()) | 725 if (device_viewport_size().IsEmpty()) |
716 return; | 726 return; |
717 | 727 |
718 if (memory_allocation_limit_bytes) { | 728 if (memory_allocation_limit_bytes) { |
719 contents_texture_manager_->SetMaxMemoryLimitBytes( | 729 contents_texture_manager_->SetMaxMemoryLimitBytes( |
720 memory_allocation_limit_bytes); | 730 memory_allocation_limit_bytes); |
721 } | 731 } |
722 | 732 |
723 UpdateLayers(root_layer(), queue); | 733 UpdateLayers(root_layer(), queue); |
724 } | 734 } |
725 | 735 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 bool start_ready_animations = true; | 1080 bool start_ready_animations = true; |
1071 (*iter).second->UpdateState(start_ready_animations, NULL); | 1081 (*iter).second->UpdateState(start_ready_animations, NULL); |
1072 } | 1082 } |
1073 } | 1083 } |
1074 | 1084 |
1075 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1085 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1076 return proxy_->CapturePicture(); | 1086 return proxy_->CapturePicture(); |
1077 } | 1087 } |
1078 | 1088 |
1079 } // namespace cc | 1089 } // namespace cc |
OLD | NEW |