Chromium Code Reviews| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 134 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
| 135 public: | 135 public: |
| 136 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( | 136 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( |
| 137 LayerTreeHostImpl* layer_tree_host_impl, | 137 LayerTreeHostImpl* layer_tree_host_impl, |
| 138 scoped_refptr<DelayBasedTimeSource> time_source) { | 138 scoped_refptr<DelayBasedTimeSource> time_source) { |
| 139 return make_scoped_ptr( | 139 return make_scoped_ptr( |
| 140 new LayerTreeHostImplTimeSourceAdapter(layer_tree_host_impl, | 140 new LayerTreeHostImplTimeSourceAdapter(layer_tree_host_impl, |
| 141 time_source)); | 141 time_source)); |
| 142 } | 142 } |
| 143 virtual ~LayerTreeHostImplTimeSourceAdapter() { | 143 virtual ~LayerTreeHostImplTimeSourceAdapter() { |
| 144 time_source_->SetClient(NULL); | 144 time_source_->SetClient(nullptr); |
| 145 time_source_->SetActive(false); | 145 time_source_->SetActive(false); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual void OnTimerTick() override { | 148 virtual void OnTimerTick() override { |
| 149 // In single threaded mode we attempt to simulate changing the current | 149 // In single threaded mode we attempt to simulate changing the current |
| 150 // thread by maintaining a fake thread id. When we switch from one | 150 // thread by maintaining a fake thread id. When we switch from one |
| 151 // thread to another, we construct DebugScopedSetXXXThread objects that | 151 // thread to another, we construct DebugScopedSetXXXThread objects that |
| 152 // update the thread id. This lets DCHECKS that ensure we're on the | 152 // update the thread id. This lets DCHECKS that ensure we're on the |
| 153 // right thread to work correctly in single threaded mode. The problem | 153 // right thread to work correctly in single threaded mode. The problem |
| 154 // here is that the timer tasks are run via the message loop, and when | 154 // here is that the timer tasks are run via the message loop, and when |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 const LayerTreeSettings& settings, | 222 const LayerTreeSettings& settings, |
| 223 LayerTreeHostImplClient* client, | 223 LayerTreeHostImplClient* client, |
| 224 Proxy* proxy, | 224 Proxy* proxy, |
| 225 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 225 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 226 SharedBitmapManager* manager, | 226 SharedBitmapManager* manager, |
| 227 int id) | 227 int id) |
| 228 : BeginFrameSourceMixIn(), | 228 : BeginFrameSourceMixIn(), |
| 229 client_(client), | 229 client_(client), |
| 230 proxy_(proxy), | 230 proxy_(proxy), |
| 231 use_gpu_rasterization_(false), | 231 use_gpu_rasterization_(false), |
| 232 input_handler_client_(NULL), | 232 input_handler_client_(nullptr), |
| 233 did_lock_scrolling_layer_(false), | 233 did_lock_scrolling_layer_(false), |
| 234 should_bubble_scrolls_(false), | 234 should_bubble_scrolls_(false), |
| 235 wheel_scrolling_(false), | 235 wheel_scrolling_(false), |
| 236 scroll_affects_scroll_handler_(false), | 236 scroll_affects_scroll_handler_(false), |
| 237 scroll_layer_id_when_mouse_over_scrollbar_(0), | 237 scroll_layer_id_when_mouse_over_scrollbar_(0), |
| 238 tile_priorities_dirty_(false), | 238 tile_priorities_dirty_(false), |
| 239 root_layer_scroll_offset_delegate_(NULL), | 239 root_layer_scroll_offset_delegate_(nullptr), |
| 240 settings_(settings), | 240 settings_(settings), |
| 241 visible_(true), | 241 visible_(true), |
| 242 cached_managed_memory_policy_( | 242 cached_managed_memory_policy_( |
| 243 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 243 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
| 244 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 244 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 245 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | 245 ManagedMemoryPolicy::kDefaultNumResourcesLimit), |
| 246 pinch_gesture_active_(false), | 246 pinch_gesture_active_(false), |
| 247 pinch_gesture_end_should_clear_scrolling_layer_(false), | 247 pinch_gesture_end_should_clear_scrolling_layer_(false), |
| 248 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), | 248 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), |
| 249 paint_time_counter_(PaintTimeCounter::Create()), | 249 paint_time_counter_(PaintTimeCounter::Create()), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 } | 293 } |
| 294 | 294 |
| 295 LayerTreeHostImpl::~LayerTreeHostImpl() { | 295 LayerTreeHostImpl::~LayerTreeHostImpl() { |
| 296 DCHECK(proxy_->IsImplThread()); | 296 DCHECK(proxy_->IsImplThread()); |
| 297 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 297 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
| 298 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 298 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 299 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 299 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
| 300 | 300 |
| 301 if (input_handler_client_) { | 301 if (input_handler_client_) { |
| 302 input_handler_client_->WillShutdown(); | 302 input_handler_client_->WillShutdown(); |
| 303 input_handler_client_ = NULL; | 303 input_handler_client_ = nullptr; |
| 304 } | 304 } |
| 305 | 305 |
| 306 // The layer trees must be destroyed before the layer tree host. We've | 306 // The layer trees must be destroyed before the layer tree host. We've |
| 307 // made a contract with our animation controllers that the registrar | 307 // made a contract with our animation controllers that the registrar |
| 308 // will outlive them, and we must make good. | 308 // will outlive them, and we must make good. |
| 309 if (recycle_tree_) | 309 if (recycle_tree_) |
| 310 recycle_tree_->Shutdown(); | 310 recycle_tree_->Shutdown(); |
| 311 if (pending_tree_) | 311 if (pending_tree_) |
| 312 pending_tree_->Shutdown(); | 312 pending_tree_->Shutdown(); |
| 313 active_tree_->Shutdown(); | 313 active_tree_->Shutdown(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 // affect the result of CanDraw, make sure to call | 369 // affect the result of CanDraw, make sure to call |
| 370 // client_->OnCanDrawStateChanged in the proper places and update the | 370 // client_->OnCanDrawStateChanged in the proper places and update the |
| 371 // NotifyIfCanDrawChanged test. | 371 // NotifyIfCanDrawChanged test. |
| 372 | 372 |
| 373 if (!renderer_) { | 373 if (!renderer_) { |
| 374 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no renderer", | 374 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no renderer", |
| 375 TRACE_EVENT_SCOPE_THREAD); | 375 TRACE_EVENT_SCOPE_THREAD); |
| 376 return false; | 376 return false; |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Must have an OutputSurface if |renderer_| is not NULL. | 379 // Must have an OutputSurface if |renderer_| is not nullptr. |
| 380 DCHECK(output_surface_); | 380 DCHECK(output_surface_); |
| 381 | 381 |
| 382 // TODO(boliu): Make draws without root_layer work and move this below | 382 // TODO(boliu): Make draws without root_layer work and move this below |
| 383 // draw_and_swap_full_viewport_every_frame check. Tracked in crbug.com/264967. | 383 // draw_and_swap_full_viewport_every_frame check. Tracked in crbug.com/264967. |
| 384 if (!active_tree_->root_layer()) { | 384 if (!active_tree_->root_layer()) { |
| 385 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no root layer", | 385 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no root layer", |
| 386 TRACE_EVENT_SCOPE_THREAD); | 386 TRACE_EVENT_SCOPE_THREAD); |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| 389 | 389 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 return false; | 444 return false; |
| 445 | 445 |
| 446 gfx::PointF device_viewport_point = | 446 gfx::PointF device_viewport_point = |
| 447 gfx::ScalePoint(viewport_point, device_scale_factor_); | 447 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 448 | 448 |
| 449 LayerImpl* layer_impl = | 449 LayerImpl* layer_impl = |
| 450 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 450 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 451 | 451 |
| 452 bool scroll_on_main_thread = false; | 452 bool scroll_on_main_thread = false; |
| 453 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 453 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 454 device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL); | 454 device_viewport_point, type, layer_impl, &scroll_on_main_thread, nullptr); |
| 455 return CurrentlyScrollingLayer() == scrolling_layer_impl; | 455 return CurrentlyScrollingLayer() == scrolling_layer_impl; |
| 456 } | 456 } |
| 457 | 457 |
| 458 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( | 458 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( |
| 459 const gfx::Point& viewport_point) { | 459 const gfx::Point& viewport_point) { |
| 460 | 460 |
| 461 gfx::PointF device_viewport_point = | 461 gfx::PointF device_viewport_point = |
| 462 gfx::ScalePoint(viewport_point, device_scale_factor_); | 462 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 463 | 463 |
| 464 LayerImpl* layer_impl = | 464 LayerImpl* layer_impl = |
| 465 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 465 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 466 device_viewport_point); | 466 device_viewport_point); |
| 467 | 467 |
| 468 return layer_impl != NULL; | 468 return layer_impl != nullptr; |
| 469 } | 469 } |
| 470 | 470 |
| 471 scoped_ptr<SwapPromiseMonitor> | 471 scoped_ptr<SwapPromiseMonitor> |
| 472 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 472 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 473 ui::LatencyInfo* latency) { | 473 ui::LatencyInfo* latency) { |
| 474 return make_scoped_ptr( | 474 return make_scoped_ptr( |
| 475 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 475 new LatencyInfoSwapPromiseMonitor(latency, nullptr, this)); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( | 478 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( |
| 479 scoped_ptr<SwapPromise> swap_promise) { | 479 scoped_ptr<SwapPromise> swap_promise) { |
| 480 swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); | 480 swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 483 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
| 484 LayerImpl* root_draw_layer, | 484 LayerImpl* root_draw_layer, |
| 485 const LayerImplList& render_surface_layer_list) { | 485 const LayerImplList& render_surface_layer_list) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 | 709 |
| 710 // Create the render passes in dependency order. | 710 // Create the render passes in dependency order. |
| 711 for (int surface_index = frame->render_surface_layer_list->size() - 1; | 711 for (int surface_index = frame->render_surface_layer_list->size() - 1; |
| 712 surface_index >= 0; | 712 surface_index >= 0; |
| 713 --surface_index) { | 713 --surface_index) { |
| 714 LayerImpl* render_surface_layer = | 714 LayerImpl* render_surface_layer = |
| 715 (*frame->render_surface_layer_list)[surface_index]; | 715 (*frame->render_surface_layer_list)[surface_index]; |
| 716 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); | 716 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); |
| 717 | 717 |
| 718 bool should_draw_into_render_pass = | 718 bool should_draw_into_render_pass = |
| 719 render_surface_layer->parent() == NULL || | 719 render_surface_layer->parent() == nullptr || |
| 720 render_surface->contributes_to_drawn_surface() || | 720 render_surface->contributes_to_drawn_surface() || |
| 721 render_surface_layer->HasCopyRequest(); | 721 render_surface_layer->HasCopyRequest(); |
| 722 if (should_draw_into_render_pass) | 722 if (should_draw_into_render_pass) |
| 723 render_surface_layer->render_surface()->AppendRenderPasses(frame); | 723 render_surface_layer->render_surface()->AppendRenderPasses(frame); |
| 724 } | 724 } |
| 725 | 725 |
| 726 // When we are displaying the HUD, change the root damage rect to cover the | 726 // When we are displaying the HUD, change the root damage rect to cover the |
| 727 // entire root surface. This will disable partial-swap/scissor optimizations | 727 // entire root surface. This will disable partial-swap/scissor optimizations |
| 728 // that would prevent the HUD from updating, since the HUD does not cause | 728 // that would prevent the HUD from updating, since the HUD does not cause |
| 729 // damage itself, to prevent it from messing with damage visualizations. Since | 729 // damage itself, to prevent it from messing with damage visualizations. Since |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 | 957 |
| 958 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { | 958 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
| 959 viewport_damage_rect_.Union(damage_rect); | 959 viewport_damage_rect_.Union(damage_rect); |
| 960 } | 960 } |
| 961 | 961 |
| 962 static inline RenderPass* FindRenderPassById( | 962 static inline RenderPass* FindRenderPassById( |
| 963 RenderPassId render_pass_id, | 963 RenderPassId render_pass_id, |
| 964 const LayerTreeHostImpl::FrameData& frame) { | 964 const LayerTreeHostImpl::FrameData& frame) { |
| 965 RenderPassIdHashMap::const_iterator it = | 965 RenderPassIdHashMap::const_iterator it = |
| 966 frame.render_passes_by_id.find(render_pass_id); | 966 frame.render_passes_by_id.find(render_pass_id); |
| 967 return it != frame.render_passes_by_id.end() ? it->second : NULL; | 967 return it != frame.render_passes_by_id.end() ? it->second : nullptr; |
| 968 } | 968 } |
| 969 | 969 |
| 970 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id, | 970 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id, |
| 971 LayerTreeHostImpl::FrameData* frame) { | 971 LayerTreeHostImpl::FrameData* frame) { |
| 972 RenderPass* remove_render_pass = | 972 RenderPass* remove_render_pass = |
| 973 FindRenderPassById(remove_render_pass_id, *frame); | 973 FindRenderPassById(remove_render_pass_id, *frame); |
| 974 // The pass was already removed by another quad - probably the original, and | 974 // The pass was already removed by another quad - probably the original, and |
| 975 // we are the replica. | 975 // we are the replica. |
| 976 if (!remove_render_pass) | 976 if (!remove_render_pass) |
| 977 return; | 977 return; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 | 1244 |
| 1245 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1245 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 |
| 1246 if (!layer->HasValidTilePriorities()) | 1246 if (!layer->HasValidTilePriorities()) |
| 1247 continue; | 1247 continue; |
| 1248 | 1248 |
| 1249 PictureLayerImpl* twin_layer = layer->GetTwinLayer(); | 1249 PictureLayerImpl* twin_layer = layer->GetTwinLayer(); |
| 1250 | 1250 |
| 1251 // Ignore the twin layer when tile priorities are invalid. | 1251 // Ignore the twin layer when tile priorities are invalid. |
| 1252 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 | 1252 // TODO(vmpstr): Iterators should handle this instead. crbug.com/381704 |
| 1253 if (twin_layer && !twin_layer->HasValidTilePriorities()) | 1253 if (twin_layer && !twin_layer->HasValidTilePriorities()) |
| 1254 twin_layer = NULL; | 1254 twin_layer = nullptr; |
| 1255 | 1255 |
| 1256 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. | 1256 // If the current tree is ACTIVE_TREE, then always generate a layer_pair. |
| 1257 // If current tree is PENDING_TREE, then only generate a layer_pair if | 1257 // If current tree is PENDING_TREE, then only generate a layer_pair if |
| 1258 // there is no twin layer. | 1258 // there is no twin layer. |
| 1259 if (layer->GetTree() == ACTIVE_TREE) { | 1259 if (layer->GetTree() == ACTIVE_TREE) { |
| 1260 DCHECK(!twin_layer || twin_layer->GetTree() == PENDING_TREE); | 1260 DCHECK(!twin_layer || twin_layer->GetTree() == PENDING_TREE); |
| 1261 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | 1261 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); |
| 1262 } else if (!twin_layer) { | 1262 } else if (!twin_layer) { |
| 1263 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); | 1263 layer_pairs->push_back(PictureLayerImpl::Pair(nullptr, layer)); |
| 1264 } | 1264 } |
| 1265 } | 1265 } |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1268 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
| 1269 TreePriority tree_priority) { | 1269 TreePriority tree_priority) { |
| 1270 picture_layer_pairs_.clear(); | 1270 picture_layer_pairs_.clear(); |
| 1271 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1271 GetPictureLayerImplPairs(&picture_layer_pairs_); |
| 1272 queue->Build(picture_layer_pairs_, tree_priority); | 1272 queue->Build(picture_layer_pairs_, tree_priority); |
| 1273 } | 1273 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1540 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1540 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1541 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1541 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1542 resource_provider_.get()); | 1542 resource_provider_.get()); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 1545 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 1546 bool disable_picture_quad_image_filtering = | 1546 bool disable_picture_quad_image_filtering = |
| 1547 IsCurrentlyScrolling() || needs_animate_layers(); | 1547 IsCurrentlyScrolling() || needs_animate_layers(); |
| 1548 | 1548 |
| 1549 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1549 scoped_ptr<SoftwareRenderer> temp_software_renderer = |
| 1550 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); | 1550 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), nullpt r); |
|
danakj
2014/10/09 16:00:53
and here?
| |
| 1551 temp_software_renderer->DrawFrame(&frame->render_passes, | 1551 temp_software_renderer->DrawFrame(&frame->render_passes, |
| 1552 device_scale_factor_, | 1552 device_scale_factor_, |
| 1553 DeviceViewport(), | 1553 DeviceViewport(), |
| 1554 DeviceClip(), | 1554 DeviceClip(), |
| 1555 disable_picture_quad_image_filtering); | 1555 disable_picture_quad_image_filtering); |
| 1556 } else { | 1556 } else { |
| 1557 renderer_->DrawFrame(&frame->render_passes, | 1557 renderer_->DrawFrame(&frame->render_passes, |
| 1558 device_scale_factor_, | 1558 device_scale_factor_, |
| 1559 DeviceViewport(), | 1559 DeviceViewport(), |
| 1560 DeviceClip(), | 1560 DeviceClip(), |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 InnerViewportScrollLayer()->IsExternalFlingActive()) || | 1707 InnerViewportScrollLayer()->IsExternalFlingActive()) || |
| 1708 (OuterViewportScrollLayer() && | 1708 (OuterViewportScrollLayer() && |
| 1709 OuterViewportScrollLayer()->IsExternalFlingActive()); | 1709 OuterViewportScrollLayer()->IsExternalFlingActive()); |
| 1710 } | 1710 } |
| 1711 | 1711 |
| 1712 // Content layers can be either directly scrollable or contained in an outer | 1712 // Content layers can be either directly scrollable or contained in an outer |
| 1713 // scrolling layer which applies the scroll transform. Given a content layer, | 1713 // scrolling layer which applies the scroll transform. Given a content layer, |
| 1714 // this function returns the associated scroll layer if any. | 1714 // this function returns the associated scroll layer if any. |
| 1715 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { | 1715 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { |
| 1716 if (!layer_impl) | 1716 if (!layer_impl) |
| 1717 return NULL; | 1717 return nullptr; |
| 1718 | 1718 |
| 1719 if (layer_impl->scrollable()) | 1719 if (layer_impl->scrollable()) |
| 1720 return layer_impl; | 1720 return layer_impl; |
| 1721 | 1721 |
| 1722 if (layer_impl->DrawsContent() && | 1722 if (layer_impl->DrawsContent() && |
| 1723 layer_impl->parent() && | 1723 layer_impl->parent() && |
| 1724 layer_impl->parent()->scrollable()) | 1724 layer_impl->parent()->scrollable()) |
| 1725 return layer_impl->parent(); | 1725 return layer_impl->parent(); |
| 1726 | 1726 |
| 1727 return NULL; | 1727 return nullptr; |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 void LayerTreeHostImpl::CreatePendingTree() { | 1730 void LayerTreeHostImpl::CreatePendingTree() { |
| 1731 CHECK(!pending_tree_); | 1731 CHECK(!pending_tree_); |
| 1732 if (recycle_tree_) | 1732 if (recycle_tree_) |
| 1733 recycle_tree_.swap(pending_tree_); | 1733 recycle_tree_.swap(pending_tree_); |
| 1734 else | 1734 else |
| 1735 pending_tree_ = LayerTreeImpl::create(this); | 1735 pending_tree_ = LayerTreeImpl::create(this); |
| 1736 | 1736 |
| 1737 // Update the delta from the active tree, which may have | 1737 // Update the delta from the active tree, which may have |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1753 DidInitializeVisibleTile(); | 1753 DidInitializeVisibleTile(); |
| 1754 need_to_update_visible_tiles_before_draw_ = false; | 1754 need_to_update_visible_tiles_before_draw_ = false; |
| 1755 } | 1755 } |
| 1756 | 1756 |
| 1757 void LayerTreeHostImpl::ActivateSyncTree() { | 1757 void LayerTreeHostImpl::ActivateSyncTree() { |
| 1758 need_to_update_visible_tiles_before_draw_ = true; | 1758 need_to_update_visible_tiles_before_draw_ = true; |
| 1759 | 1759 |
| 1760 if (pending_tree_) { | 1760 if (pending_tree_) { |
| 1761 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1761 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1762 | 1762 |
| 1763 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1763 active_tree_->SetRootLayerScrollOffsetDelegate(nullptr); |
| 1764 active_tree_->PushPersistedState(pending_tree_.get()); | 1764 active_tree_->PushPersistedState(pending_tree_.get()); |
| 1765 // Process any requests in the UI resource queue. The request queue is | 1765 // Process any requests in the UI resource queue. The request queue is |
| 1766 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1766 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
| 1767 // before the swap. | 1767 // before the swap. |
| 1768 pending_tree_->ProcessUIResourceRequestQueue(); | 1768 pending_tree_->ProcessUIResourceRequestQueue(); |
| 1769 | 1769 |
| 1770 if (pending_tree_->needs_full_tree_sync()) { | 1770 if (pending_tree_->needs_full_tree_sync()) { |
| 1771 active_tree_->SetRootLayer( | 1771 active_tree_->SetRootLayer( |
| 1772 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), | 1772 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), |
| 1773 active_tree_->DetachLayerTree(), | 1773 active_tree_->DetachLayerTree(), |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2218 top_controls_manager_->top_controls_height(); | 2218 top_controls_manager_->top_controls_height(); |
| 2219 active_tree_->set_top_controls_delta(offset - current_top_offset); | 2219 active_tree_->set_top_controls_delta(offset - current_top_offset); |
| 2220 } | 2220 } |
| 2221 | 2221 |
| 2222 float LayerTreeHostImpl::ControlsTopOffset() const { | 2222 float LayerTreeHostImpl::ControlsTopOffset() const { |
| 2223 return active_tree_->total_top_controls_content_offset() - | 2223 return active_tree_->total_top_controls_content_offset() - |
| 2224 top_controls_manager_->top_controls_height(); | 2224 top_controls_manager_->top_controls_height(); |
| 2225 } | 2225 } |
| 2226 | 2226 |
| 2227 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2227 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2228 DCHECK(input_handler_client_ == NULL); | 2228 DCHECK(input_handler_client_ == nullptr); |
| 2229 input_handler_client_ = client; | 2229 input_handler_client_ = client; |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2232 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
| 2233 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2233 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
| 2234 return scroll_parent; | 2234 return scroll_parent; |
| 2235 return layer->parent(); | 2235 return layer->parent(); |
| 2236 } | 2236 } |
| 2237 | 2237 |
| 2238 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 2238 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
| 2239 const gfx::PointF& device_viewport_point, | 2239 const gfx::PointF& device_viewport_point, |
| 2240 InputHandler::ScrollInputType type, | 2240 InputHandler::ScrollInputType type, |
| 2241 LayerImpl* layer_impl, | 2241 LayerImpl* layer_impl, |
| 2242 bool* scroll_on_main_thread, | 2242 bool* scroll_on_main_thread, |
| 2243 bool* optional_has_ancestor_scroll_handler) const { | 2243 bool* optional_has_ancestor_scroll_handler) const { |
| 2244 DCHECK(scroll_on_main_thread); | 2244 DCHECK(scroll_on_main_thread); |
| 2245 | 2245 |
| 2246 // Walk up the hierarchy and look for a scrollable layer. | 2246 // Walk up the hierarchy and look for a scrollable layer. |
| 2247 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2247 LayerImpl* potentially_scrolling_layer_impl = nullptr; |
| 2248 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { | 2248 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { |
| 2249 // The content layer can also block attempts to scroll outside the main | 2249 // The content layer can also block attempts to scroll outside the main |
| 2250 // thread. | 2250 // thread. |
| 2251 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 2251 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
| 2252 if (status == ScrollOnMainThread) { | 2252 if (status == ScrollOnMainThread) { |
| 2253 *scroll_on_main_thread = true; | 2253 *scroll_on_main_thread = true; |
| 2254 return NULL; | 2254 return nullptr; |
| 2255 } | 2255 } |
| 2256 | 2256 |
| 2257 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2257 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2258 if (!scroll_layer_impl) | 2258 if (!scroll_layer_impl) |
| 2259 continue; | 2259 continue; |
| 2260 | 2260 |
| 2261 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 2261 status = scroll_layer_impl->TryScroll(device_viewport_point, type); |
| 2262 // If any layer wants to divert the scroll event to the main thread, abort. | 2262 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2263 if (status == ScrollOnMainThread) { | 2263 if (status == ScrollOnMainThread) { |
| 2264 *scroll_on_main_thread = true; | 2264 *scroll_on_main_thread = true; |
| 2265 return NULL; | 2265 return nullptr; |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 if (optional_has_ancestor_scroll_handler && | 2268 if (optional_has_ancestor_scroll_handler && |
| 2269 scroll_layer_impl->have_scroll_event_handlers()) | 2269 scroll_layer_impl->have_scroll_event_handlers()) |
| 2270 *optional_has_ancestor_scroll_handler = true; | 2270 *optional_has_ancestor_scroll_handler = true; |
| 2271 | 2271 |
| 2272 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 2272 if (status == ScrollStarted && !potentially_scrolling_layer_impl) |
| 2273 potentially_scrolling_layer_impl = scroll_layer_impl; | 2273 potentially_scrolling_layer_impl = scroll_layer_impl; |
| 2274 } | 2274 } |
| 2275 | 2275 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2687 } | 2687 } |
| 2688 | 2688 |
| 2689 void LayerTreeHostImpl::SetRootLayerScrollOffsetDelegate( | 2689 void LayerTreeHostImpl::SetRootLayerScrollOffsetDelegate( |
| 2690 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { | 2690 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { |
| 2691 root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; | 2691 root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; |
| 2692 active_tree_->SetRootLayerScrollOffsetDelegate( | 2692 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 2693 root_layer_scroll_offset_delegate_); | 2693 root_layer_scroll_offset_delegate_); |
| 2694 } | 2694 } |
| 2695 | 2695 |
| 2696 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { | 2696 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { |
| 2697 DCHECK(root_layer_scroll_offset_delegate_ != NULL); | 2697 DCHECK(root_layer_scroll_offset_delegate_ != nullptr); |
| 2698 client_->SetNeedsCommitOnImplThread(); | 2698 client_->SetNeedsCommitOnImplThread(); |
| 2699 active_tree_->set_needs_update_draw_properties(); | 2699 active_tree_->set_needs_update_draw_properties(); |
| 2700 } | 2700 } |
| 2701 | 2701 |
| 2702 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2702 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
| 2703 active_tree_->ClearCurrentlyScrollingLayer(); | 2703 active_tree_->ClearCurrentlyScrollingLayer(); |
| 2704 did_lock_scrolling_layer_ = false; | 2704 did_lock_scrolling_layer_ = false; |
| 2705 scroll_affects_scroll_handler_ = false; | 2705 scroll_affects_scroll_handler_ = false; |
| 2706 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2706 accumulated_root_overscroll_ = gfx::Vector2dF(); |
| 2707 } | 2707 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2760 | 2760 |
| 2761 if (scroll_layer_id_when_mouse_over_scrollbar_) { | 2761 if (scroll_layer_id_when_mouse_over_scrollbar_) { |
| 2762 LayerImpl* scroll_layer_impl = active_tree_->LayerById( | 2762 LayerImpl* scroll_layer_impl = active_tree_->LayerById( |
| 2763 scroll_layer_id_when_mouse_over_scrollbar_); | 2763 scroll_layer_id_when_mouse_over_scrollbar_); |
| 2764 | 2764 |
| 2765 // The check for a null scroll_layer_impl below was added to see if it will | 2765 // The check for a null scroll_layer_impl below was added to see if it will |
| 2766 // eliminate the crashes described in http://crbug.com/326635. | 2766 // eliminate the crashes described in http://crbug.com/326635. |
| 2767 // TODO(wjmaclean) Add a unit test if this fixes the crashes. | 2767 // TODO(wjmaclean) Add a unit test if this fixes the crashes. |
| 2768 ScrollbarAnimationController* animation_controller = | 2768 ScrollbarAnimationController* animation_controller = |
| 2769 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() | 2769 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() |
| 2770 : NULL; | 2770 : nullptr; |
| 2771 if (animation_controller) | 2771 if (animation_controller) |
| 2772 animation_controller->DidMouseMoveOffScrollbar(); | 2772 animation_controller->DidMouseMoveOffScrollbar(); |
| 2773 scroll_layer_id_when_mouse_over_scrollbar_ = 0; | 2773 scroll_layer_id_when_mouse_over_scrollbar_ = 0; |
| 2774 } | 2774 } |
| 2775 | 2775 |
| 2776 bool scroll_on_main_thread = false; | 2776 bool scroll_on_main_thread = false; |
| 2777 LayerImpl* scroll_layer_impl = | 2777 LayerImpl* scroll_layer_impl = |
| 2778 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2778 FindScrollLayerForDeviceViewportPoint(device_viewport_point, |
| 2779 InputHandler::Gesture, | 2779 InputHandler::Gesture, |
| 2780 layer_impl, | 2780 layer_impl, |
| 2781 &scroll_on_main_thread, | 2781 &scroll_on_main_thread, |
| 2782 NULL); | 2782 nullptr); |
| 2783 if (scroll_on_main_thread || !scroll_layer_impl) | 2783 if (scroll_on_main_thread || !scroll_layer_impl) |
| 2784 return; | 2784 return; |
| 2785 | 2785 |
| 2786 ScrollbarAnimationController* animation_controller = | 2786 ScrollbarAnimationController* animation_controller = |
| 2787 scroll_layer_impl->scrollbar_animation_controller(); | 2787 scroll_layer_impl->scrollbar_animation_controller(); |
| 2788 if (!animation_controller) | 2788 if (!animation_controller) |
| 2789 return; | 2789 return; |
| 2790 | 2790 |
| 2791 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? | 2791 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? |
| 2792 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 2792 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2839 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 2839 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
| 2840 const gfx::Point& anchor) { | 2840 const gfx::Point& anchor) { |
| 2841 if (!InnerViewportScrollLayer()) | 2841 if (!InnerViewportScrollLayer()) |
| 2842 return; | 2842 return; |
| 2843 | 2843 |
| 2844 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2844 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
| 2845 | 2845 |
| 2846 // For a moment the scroll offset ends up being outside of the max range. This | 2846 // For a moment the scroll offset ends up being outside of the max range. This |
| 2847 // confuses the delegate so we switch it off till after we're done processing | 2847 // confuses the delegate so we switch it off till after we're done processing |
| 2848 // the pinch update. | 2848 // the pinch update. |
| 2849 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 2849 active_tree_->SetRootLayerScrollOffsetDelegate(nullptr); |
| 2850 | 2850 |
| 2851 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2851 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| 2852 // position over the course of the magnify. | 2852 // position over the course of the magnify. |
| 2853 float page_scale_delta = active_tree_->page_scale_delta(); | 2853 float page_scale_delta = active_tree_->page_scale_delta(); |
| 2854 gfx::PointF previous_scale_anchor = | 2854 gfx::PointF previous_scale_anchor = |
| 2855 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2855 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| 2856 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2856 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); |
| 2857 page_scale_delta = active_tree_->page_scale_delta(); | 2857 page_scale_delta = active_tree_->page_scale_delta(); |
| 2858 gfx::PointF new_scale_anchor = | 2858 gfx::PointF new_scale_anchor = |
| 2859 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2859 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3138 // we're not in a frame (because this is during an input event or a delayed | 3138 // we're not in a frame (because this is during an input event or a delayed |
| 3139 // task), fall back to physical time. This should still be monotonic. | 3139 // task), fall back to physical time. This should still be monotonic. |
| 3140 if (current_begin_frame_args_.IsValid()) | 3140 if (current_begin_frame_args_.IsValid()) |
| 3141 return current_begin_frame_args_; | 3141 return current_begin_frame_args_; |
| 3142 return BeginFrameArgs::Create(gfx::FrameTime::Now(), | 3142 return BeginFrameArgs::Create(gfx::FrameTime::Now(), |
| 3143 base::TimeTicks(), | 3143 base::TimeTicks(), |
| 3144 BeginFrameArgs::DefaultInterval()); | 3144 BeginFrameArgs::DefaultInterval()); |
| 3145 } | 3145 } |
| 3146 | 3146 |
| 3147 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { | 3147 void LayerTreeHostImpl::AsValueInto(base::debug::TracedValue* value) const { |
| 3148 return AsValueWithFrameInto(NULL, value); | 3148 return AsValueWithFrameInto(nullptr, value); |
| 3149 } | 3149 } |
| 3150 | 3150 |
| 3151 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3151 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3152 LayerTreeHostImpl::AsValue() const { | 3152 LayerTreeHostImpl::AsValue() const { |
| 3153 return AsValueWithFrame(NULL); | 3153 return AsValueWithFrame(nullptr); |
| 3154 } | 3154 } |
| 3155 | 3155 |
| 3156 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3156 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 3157 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3157 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3158 scoped_refptr<base::debug::TracedValue> state = | 3158 scoped_refptr<base::debug::TracedValue> state = |
| 3159 new base::debug::TracedValue(); | 3159 new base::debug::TracedValue(); |
| 3160 AsValueWithFrameInto(frame, state.get()); | 3160 AsValueWithFrameInto(frame, state.get()); |
| 3161 return state; | 3161 return state; |
| 3162 } | 3162 } |
| 3163 | 3163 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3379 } | 3379 } |
| 3380 | 3380 |
| 3381 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3381 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3382 std::vector<PictureLayerImpl*>::iterator it = | 3382 std::vector<PictureLayerImpl*>::iterator it = |
| 3383 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3383 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3384 DCHECK(it != picture_layers_.end()); | 3384 DCHECK(it != picture_layers_.end()); |
| 3385 picture_layers_.erase(it); | 3385 picture_layers_.erase(it); |
| 3386 } | 3386 } |
| 3387 | 3387 |
| 3388 } // namespace cc | 3388 } // namespace cc |
| OLD | NEW |