| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 void LayerTreeHostImpl::CommitComplete() { | 302 void LayerTreeHostImpl::CommitComplete() { |
| 303 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 303 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
| 304 | 304 |
| 305 sync_tree()->set_needs_update_draw_properties(); | 305 sync_tree()->set_needs_update_draw_properties(); |
| 306 | 306 |
| 307 if (settings_.impl_side_painting) { | 307 if (settings_.impl_side_painting) { |
| 308 // Impl-side painting needs an update immediately post-commit to have the | 308 // Impl-side painting needs an update immediately post-commit to have the |
| 309 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 309 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
| 310 // more lazily when needed prior to drawing. | 310 // more lazily when needed prior to drawing. Because invalidations may |
| 311 sync_tree()->UpdateDrawProperties(); | 311 // be coming from the main thread, it's safe to do an update for lcd text |
| 312 // at this point and see if lcd text needs to be disabled on any layers. |
| 313 bool update_lcd_text = true; |
| 314 sync_tree()->UpdateDrawProperties(update_lcd_text); |
| 312 // Start working on newly created tiles immediately if needed. | 315 // Start working on newly created tiles immediately if needed. |
| 313 if (tile_manager_ && tile_priorities_dirty_) | 316 if (tile_manager_ && tile_priorities_dirty_) |
| 314 PrepareTiles(); | 317 PrepareTiles(); |
| 315 else | 318 else |
| 316 NotifyReadyToActivate(); | 319 NotifyReadyToActivate(); |
| 317 } else { | 320 } else { |
| 318 // If we're not in impl-side painting, the tree is immediately considered | 321 // If we're not in impl-side painting, the tree is immediately considered |
| 319 // active. | 322 // active. |
| 320 ActivateSyncTree(); | 323 ActivateSyncTree(); |
| 321 } | 324 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 return layer_impl != NULL; | 469 return layer_impl != NULL; |
| 467 } | 470 } |
| 468 | 471 |
| 469 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 472 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
| 470 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 473 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
| 471 return scroll_parent; | 474 return scroll_parent; |
| 472 return layer->parent(); | 475 return layer->parent(); |
| 473 } | 476 } |
| 474 | 477 |
| 475 static ScrollBlocksOn EffectiveScrollBlocksOn(LayerImpl* layer) { | 478 static ScrollBlocksOn EffectiveScrollBlocksOn(LayerImpl* layer) { |
| 476 ScrollBlocksOn blocks = ScrollBlocksOnNone; | 479 ScrollBlocksOn blocks = SCROLL_BLOCKS_ON_NONE; |
| 477 for (; layer; layer = NextScrollLayer(layer)) { | 480 for (; layer; layer = NextScrollLayer(layer)) { |
| 478 blocks |= layer->scroll_blocks_on(); | 481 blocks |= layer->scroll_blocks_on(); |
| 479 } | 482 } |
| 480 return blocks; | 483 return blocks; |
| 481 } | 484 } |
| 482 | 485 |
| 483 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( | 486 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| 484 const gfx::Point& viewport_point) { | 487 const gfx::Point& viewport_point) { |
| 485 gfx::PointF device_viewport_point = | 488 gfx::PointF device_viewport_point = |
| 486 gfx::ScalePoint(viewport_point, device_scale_factor_); | 489 gfx::ScalePoint(viewport_point, device_scale_factor_); |
| 487 | 490 |
| 488 // First check if scrolling at this point is required to block on any | 491 // First check if scrolling at this point is required to block on any |
| 489 // touch event handlers. Note that we must start at the innermost layer | 492 // touch event handlers. Note that we must start at the innermost layer |
| 490 // (as opposed to only the layer found to contain a touch handler region | 493 // (as opposed to only the layer found to contain a touch handler region |
| 491 // below) to ensure all relevant scroll-blocks-on values are applied. | 494 // below) to ensure all relevant scroll-blocks-on values are applied. |
| 492 LayerImpl* layer_impl = | 495 LayerImpl* layer_impl = |
| 493 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 496 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 494 ScrollBlocksOn blocking = EffectiveScrollBlocksOn(layer_impl); | 497 ScrollBlocksOn blocking = EffectiveScrollBlocksOn(layer_impl); |
| 495 if (!(blocking & ScrollBlocksOnStartTouch)) | 498 if (!(blocking & SCROLL_BLOCKS_ON_START_TOUCH)) |
| 496 return false; | 499 return false; |
| 497 | 500 |
| 498 // Now determine if there are actually any handlers at that point. | 501 // Now determine if there are actually any handlers at that point. |
| 499 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 502 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 500 layer_impl = active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 503 layer_impl = active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 501 device_viewport_point); | 504 device_viewport_point); |
| 502 return layer_impl != NULL; | 505 return layer_impl != NULL; |
| 503 } | 506 } |
| 504 | 507 |
| 505 scoped_ptr<SwapPromiseMonitor> | 508 scoped_ptr<SwapPromiseMonitor> |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 TRACE_EVENT1("cc", | 1042 TRACE_EVENT1("cc", |
| 1040 "LayerTreeHostImpl::PrepareToDraw", | 1043 "LayerTreeHostImpl::PrepareToDraw", |
| 1041 "SourceFrameNumber", | 1044 "SourceFrameNumber", |
| 1042 active_tree_->source_frame_number()); | 1045 active_tree_->source_frame_number()); |
| 1043 if (input_handler_client_) | 1046 if (input_handler_client_) |
| 1044 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); | 1047 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); |
| 1045 | 1048 |
| 1046 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1049 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1047 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1050 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
| 1048 | 1051 |
| 1049 bool ok = active_tree_->UpdateDrawProperties(); | 1052 bool update_lcd_text = false; |
| 1053 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text); |
| 1050 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1054 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
| 1051 | 1055 |
| 1052 // This will cause NotifyTileStateChanged() to be called for any visible tiles | 1056 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
| 1053 // that completed, which will add damage to the frame for them so they appear | 1057 // that completed, which will add damage to the frame for them so they appear |
| 1054 // as part of the current frame being drawn. | 1058 // as part of the current frame being drawn. |
| 1055 if (settings().impl_side_painting) | 1059 if (settings().impl_side_painting) |
| 1056 tile_manager_->UpdateVisibleTiles(global_tile_state_); | 1060 tile_manager_->UpdateVisibleTiles(global_tile_state_); |
| 1057 | 1061 |
| 1058 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1062 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
| 1059 frame->render_passes.clear(); | 1063 frame->render_passes.clear(); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 } | 1616 } |
| 1613 | 1617 |
| 1614 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1618 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
| 1615 ResetRequiresHighResToDraw(); | 1619 ResetRequiresHighResToDraw(); |
| 1616 if (frame.has_no_damage) { | 1620 if (frame.has_no_damage) { |
| 1617 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1621 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
| 1618 return false; | 1622 return false; |
| 1619 } | 1623 } |
| 1620 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1624 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
| 1621 active_tree()->FinishSwapPromises(&metadata); | 1625 active_tree()->FinishSwapPromises(&metadata); |
| 1622 for (size_t i = 0; i < metadata.latency_info.size(); i++) { | 1626 for (auto& latency : metadata.latency_info) { |
| 1623 TRACE_EVENT_FLOW_STEP0( | 1627 TRACE_EVENT_FLOW_STEP0( |
| 1624 "input,benchmark", | 1628 "input,benchmark", |
| 1625 "LatencyInfo.Flow", | 1629 "LatencyInfo.Flow", |
| 1626 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1630 TRACE_ID_DONT_MANGLE(latency.trace_id), |
| 1627 "SwapBuffers"); | 1631 "SwapBuffers"); |
| 1632 // Only add the latency component once for renderer swap, not the browser |
| 1633 // swap. |
| 1634 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| 1635 0, nullptr)) { |
| 1636 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| 1637 0, 0); |
| 1638 } |
| 1628 } | 1639 } |
| 1629 renderer_->SwapBuffers(metadata); | 1640 renderer_->SwapBuffers(metadata); |
| 1630 return true; | 1641 return true; |
| 1631 } | 1642 } |
| 1632 | 1643 |
| 1633 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1644 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1634 // Sample the frame time now. This time will be used for updating animations | 1645 // Sample the frame time now. This time will be used for updating animations |
| 1635 // when we draw. | 1646 // when we draw. |
| 1636 UpdateCurrentBeginFrameArgs(args); | 1647 UpdateCurrentBeginFrameArgs(args); |
| 1637 // Cache the begin impl frame interval | 1648 // Cache the begin impl frame interval |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 | 2299 |
| 2289 ScrollBlocksOn block_mode = EffectiveScrollBlocksOn(layer_impl); | 2300 ScrollBlocksOn block_mode = EffectiveScrollBlocksOn(layer_impl); |
| 2290 | 2301 |
| 2291 // Walk up the hierarchy and look for a scrollable layer. | 2302 // Walk up the hierarchy and look for a scrollable layer. |
| 2292 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2303 LayerImpl* potentially_scrolling_layer_impl = NULL; |
| 2293 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { | 2304 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { |
| 2294 // The content layer can also block attempts to scroll outside the main | 2305 // The content layer can also block attempts to scroll outside the main |
| 2295 // thread. | 2306 // thread. |
| 2296 ScrollStatus status = | 2307 ScrollStatus status = |
| 2297 layer_impl->TryScroll(device_viewport_point, type, block_mode); | 2308 layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2298 if (status == ScrollOnMainThread) { | 2309 if (status == SCROLL_ON_MAIN_THREAD) { |
| 2299 *scroll_on_main_thread = true; | 2310 *scroll_on_main_thread = true; |
| 2300 return NULL; | 2311 return NULL; |
| 2301 } | 2312 } |
| 2302 | 2313 |
| 2303 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2314 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2304 if (!scroll_layer_impl) | 2315 if (!scroll_layer_impl) |
| 2305 continue; | 2316 continue; |
| 2306 | 2317 |
| 2307 status = | 2318 status = |
| 2308 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); | 2319 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2309 // If any layer wants to divert the scroll event to the main thread, abort. | 2320 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2310 if (status == ScrollOnMainThread) { | 2321 if (status == SCROLL_ON_MAIN_THREAD) { |
| 2311 *scroll_on_main_thread = true; | 2322 *scroll_on_main_thread = true; |
| 2312 return NULL; | 2323 return NULL; |
| 2313 } | 2324 } |
| 2314 | 2325 |
| 2315 if (optional_has_ancestor_scroll_handler && | 2326 if (optional_has_ancestor_scroll_handler && |
| 2316 scroll_layer_impl->have_scroll_event_handlers()) | 2327 scroll_layer_impl->have_scroll_event_handlers()) |
| 2317 *optional_has_ancestor_scroll_handler = true; | 2328 *optional_has_ancestor_scroll_handler = true; |
| 2318 | 2329 |
| 2319 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 2330 if (status == SCROLL_STARTED && !potentially_scrolling_layer_impl) |
| 2320 potentially_scrolling_layer_impl = scroll_layer_impl; | 2331 potentially_scrolling_layer_impl = scroll_layer_impl; |
| 2321 } | 2332 } |
| 2322 | 2333 |
| 2323 // Falling back to the root scroll layer ensures generation of root overscroll | 2334 // Falling back to the root scroll layer ensures generation of root overscroll |
| 2324 // notifications while preventing scroll updates from being unintentionally | 2335 // notifications while preventing scroll updates from being unintentionally |
| 2325 // forwarded to the main thread. | 2336 // forwarded to the main thread. |
| 2326 if (!potentially_scrolling_layer_impl) | 2337 if (!potentially_scrolling_layer_impl) |
| 2327 potentially_scrolling_layer_impl = OuterViewportScrollLayer() | 2338 potentially_scrolling_layer_impl = OuterViewportScrollLayer() |
| 2328 ? OuterViewportScrollLayer() | 2339 ? OuterViewportScrollLayer() |
| 2329 : InnerViewportScrollLayer(); | 2340 : InnerViewportScrollLayer(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2356 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2367 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
| 2357 device_scale_factor_); | 2368 device_scale_factor_); |
| 2358 LayerImpl* layer_impl = | 2369 LayerImpl* layer_impl = |
| 2359 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 2370 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2360 | 2371 |
| 2361 if (layer_impl) { | 2372 if (layer_impl) { |
| 2362 LayerImpl* scroll_layer_impl = | 2373 LayerImpl* scroll_layer_impl = |
| 2363 active_tree_->FindFirstScrollingLayerThatIsHitByPoint( | 2374 active_tree_->FindFirstScrollingLayerThatIsHitByPoint( |
| 2364 device_viewport_point); | 2375 device_viewport_point); |
| 2365 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) | 2376 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) |
| 2366 return ScrollUnknown; | 2377 return SCROLL_UNKNOWN; |
| 2367 } | 2378 } |
| 2368 | 2379 |
| 2369 bool scroll_on_main_thread = false; | 2380 bool scroll_on_main_thread = false; |
| 2370 LayerImpl* scrolling_layer_impl = | 2381 LayerImpl* scrolling_layer_impl = |
| 2371 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2382 FindScrollLayerForDeviceViewportPoint(device_viewport_point, |
| 2372 type, | 2383 type, |
| 2373 layer_impl, | 2384 layer_impl, |
| 2374 &scroll_on_main_thread, | 2385 &scroll_on_main_thread, |
| 2375 &scroll_affects_scroll_handler_); | 2386 &scroll_affects_scroll_handler_); |
| 2376 | 2387 |
| 2377 if (scroll_on_main_thread) { | 2388 if (scroll_on_main_thread) { |
| 2378 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 2389 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 2379 return ScrollOnMainThread; | 2390 return SCROLL_ON_MAIN_THREAD; |
| 2380 } | 2391 } |
| 2381 | 2392 |
| 2382 if (scrolling_layer_impl) { | 2393 if (scrolling_layer_impl) { |
| 2383 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); | 2394 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); |
| 2384 should_bubble_scrolls_ = (type != NonBubblingGesture); | 2395 should_bubble_scrolls_ = (type != NON_BUBBLING_GESTURE); |
| 2385 wheel_scrolling_ = (type == Wheel); | 2396 wheel_scrolling_ = (type == WHEEL); |
| 2386 client_->RenewTreePriority(); | 2397 client_->RenewTreePriority(); |
| 2387 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 2398 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 2388 return ScrollStarted; | 2399 return SCROLL_STARTED; |
| 2389 } | 2400 } |
| 2390 return ScrollIgnored; | 2401 return SCROLL_IGNORED; |
| 2391 } | 2402 } |
| 2392 | 2403 |
| 2393 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 2404 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
| 2394 const gfx::Point& viewport_point, | 2405 const gfx::Point& viewport_point, |
| 2395 const gfx::Vector2dF& scroll_delta) { | 2406 const gfx::Vector2dF& scroll_delta) { |
| 2396 if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { | 2407 if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { |
| 2397 Animation* animation = | 2408 Animation* animation = |
| 2398 layer_impl->layer_animation_controller()->GetAnimation( | 2409 layer_impl->layer_animation_controller()->GetAnimation( |
| 2399 Animation::ScrollOffset); | 2410 Animation::SCROLL_OFFSET); |
| 2400 if (!animation) | 2411 if (!animation) |
| 2401 return ScrollIgnored; | 2412 return SCROLL_IGNORED; |
| 2402 | 2413 |
| 2403 ScrollOffsetAnimationCurve* curve = | 2414 ScrollOffsetAnimationCurve* curve = |
| 2404 animation->curve()->ToScrollOffsetAnimationCurve(); | 2415 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 2405 | 2416 |
| 2406 gfx::ScrollOffset new_target = | 2417 gfx::ScrollOffset new_target = |
| 2407 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); | 2418 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); |
| 2408 new_target.SetToMax(gfx::ScrollOffset()); | 2419 new_target.SetToMax(gfx::ScrollOffset()); |
| 2409 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 2420 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
| 2410 | 2421 |
| 2411 curve->UpdateTarget( | 2422 curve->UpdateTarget( |
| 2412 animation->TrimTimeToCurrentIteration( | 2423 animation->TrimTimeToCurrentIteration( |
| 2413 CurrentBeginFrameArgs().frame_time).InSecondsF(), | 2424 CurrentBeginFrameArgs().frame_time).InSecondsF(), |
| 2414 new_target); | 2425 new_target); |
| 2415 | 2426 |
| 2416 return ScrollStarted; | 2427 return SCROLL_STARTED; |
| 2417 } | 2428 } |
| 2418 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling | 2429 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling |
| 2419 // behavior as ScrollBy to determine which layer to animate, but we do not | 2430 // behavior as ScrollBy to determine which layer to animate, but we do not |
| 2420 // do the Android-specific things in ScrollBy like showing top controls. | 2431 // do the Android-specific things in ScrollBy like showing top controls. |
| 2421 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); | 2432 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, WHEEL); |
| 2422 if (scroll_status == ScrollStarted) { | 2433 if (scroll_status == SCROLL_STARTED) { |
| 2423 gfx::Vector2dF pending_delta = scroll_delta; | 2434 gfx::Vector2dF pending_delta = scroll_delta; |
| 2424 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; | 2435 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; |
| 2425 layer_impl = layer_impl->parent()) { | 2436 layer_impl = layer_impl->parent()) { |
| 2426 if (!layer_impl->scrollable()) | 2437 if (!layer_impl->scrollable()) |
| 2427 continue; | 2438 continue; |
| 2428 | 2439 |
| 2429 gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); | 2440 gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); |
| 2430 gfx::ScrollOffset target_offset = | 2441 gfx::ScrollOffset target_offset = |
| 2431 ScrollOffsetWithDelta(current_offset, pending_delta); | 2442 ScrollOffsetWithDelta(current_offset, pending_delta); |
| 2432 target_offset.SetToMax(gfx::ScrollOffset()); | 2443 target_offset.SetToMax(gfx::ScrollOffset()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2443 continue; | 2454 continue; |
| 2444 } | 2455 } |
| 2445 | 2456 |
| 2446 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2457 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2447 | 2458 |
| 2448 scoped_ptr<ScrollOffsetAnimationCurve> curve = | 2459 scoped_ptr<ScrollOffsetAnimationCurve> curve = |
| 2449 ScrollOffsetAnimationCurve::Create(target_offset, | 2460 ScrollOffsetAnimationCurve::Create(target_offset, |
| 2450 EaseInOutTimingFunction::Create()); | 2461 EaseInOutTimingFunction::Create()); |
| 2451 curve->SetInitialValue(current_offset); | 2462 curve->SetInitialValue(current_offset); |
| 2452 | 2463 |
| 2453 scoped_ptr<Animation> animation = | 2464 scoped_ptr<Animation> animation = Animation::Create( |
| 2454 Animation::Create(curve.Pass(), | 2465 curve.Pass(), AnimationIdProvider::NextAnimationId(), |
| 2455 AnimationIdProvider::NextAnimationId(), | 2466 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET); |
| 2456 AnimationIdProvider::NextGroupId(), | |
| 2457 Animation::ScrollOffset); | |
| 2458 animation->set_is_impl_only(true); | 2467 animation->set_is_impl_only(true); |
| 2459 | 2468 |
| 2460 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); | 2469 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); |
| 2461 | 2470 |
| 2462 SetNeedsAnimate(); | 2471 SetNeedsAnimate(); |
| 2463 return ScrollStarted; | 2472 return SCROLL_STARTED; |
| 2464 } | 2473 } |
| 2465 } | 2474 } |
| 2466 ScrollEnd(); | 2475 ScrollEnd(); |
| 2467 return scroll_status; | 2476 return scroll_status; |
| 2468 } | 2477 } |
| 2469 | 2478 |
| 2470 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 2479 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |
| 2471 LayerImpl* layer_impl, | 2480 LayerImpl* layer_impl, |
| 2472 float scale_from_viewport_to_screen_space, | 2481 float scale_from_viewport_to_screen_space, |
| 2473 const gfx::PointF& viewport_point, | 2482 const gfx::PointF& viewport_point, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2804 } | 2813 } |
| 2805 | 2814 |
| 2806 void LayerTreeHostImpl::ScrollEnd() { | 2815 void LayerTreeHostImpl::ScrollEnd() { |
| 2807 if (top_controls_manager_) | 2816 if (top_controls_manager_) |
| 2808 top_controls_manager_->ScrollEnd(); | 2817 top_controls_manager_->ScrollEnd(); |
| 2809 ClearCurrentlyScrollingLayer(); | 2818 ClearCurrentlyScrollingLayer(); |
| 2810 } | 2819 } |
| 2811 | 2820 |
| 2812 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2821 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
| 2813 if (!active_tree_->CurrentlyScrollingLayer()) | 2822 if (!active_tree_->CurrentlyScrollingLayer()) |
| 2814 return ScrollIgnored; | 2823 return SCROLL_IGNORED; |
| 2815 | 2824 |
| 2816 if (settings_.ignore_root_layer_flings && | 2825 if (settings_.ignore_root_layer_flings && |
| 2817 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || | 2826 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || |
| 2818 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { | 2827 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { |
| 2819 ClearCurrentlyScrollingLayer(); | 2828 ClearCurrentlyScrollingLayer(); |
| 2820 return ScrollIgnored; | 2829 return SCROLL_IGNORED; |
| 2821 } | 2830 } |
| 2822 | 2831 |
| 2823 if (!wheel_scrolling_) { | 2832 if (!wheel_scrolling_) { |
| 2824 // Allow the fling to lock to the first layer that moves after the initial | 2833 // Allow the fling to lock to the first layer that moves after the initial |
| 2825 // fling |ScrollBy()| event. | 2834 // fling |ScrollBy()| event. |
| 2826 did_lock_scrolling_layer_ = false; | 2835 did_lock_scrolling_layer_ = false; |
| 2827 should_bubble_scrolls_ = false; | 2836 should_bubble_scrolls_ = false; |
| 2828 } | 2837 } |
| 2829 | 2838 |
| 2830 return ScrollStarted; | 2839 return SCROLL_STARTED; |
| 2831 } | 2840 } |
| 2832 | 2841 |
| 2833 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 2842 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |
| 2834 const gfx::PointF& device_viewport_point, | 2843 const gfx::PointF& device_viewport_point, |
| 2835 LayerImpl* layer_impl) { | 2844 LayerImpl* layer_impl) { |
| 2836 if (!layer_impl) | 2845 if (!layer_impl) |
| 2837 return std::numeric_limits<float>::max(); | 2846 return std::numeric_limits<float>::max(); |
| 2838 | 2847 |
| 2839 gfx::Rect layer_impl_bounds( | 2848 gfx::Rect layer_impl_bounds( |
| 2840 layer_impl->content_bounds()); | 2849 layer_impl->content_bounds()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2864 // TODO(wjmaclean) Add a unit test if this fixes the crashes. | 2873 // TODO(wjmaclean) Add a unit test if this fixes the crashes. |
| 2865 ScrollbarAnimationController* animation_controller = | 2874 ScrollbarAnimationController* animation_controller = |
| 2866 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() | 2875 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() |
| 2867 : NULL; | 2876 : NULL; |
| 2868 if (animation_controller) | 2877 if (animation_controller) |
| 2869 animation_controller->DidMouseMoveOffScrollbar(); | 2878 animation_controller->DidMouseMoveOffScrollbar(); |
| 2870 scroll_layer_id_when_mouse_over_scrollbar_ = 0; | 2879 scroll_layer_id_when_mouse_over_scrollbar_ = 0; |
| 2871 } | 2880 } |
| 2872 | 2881 |
| 2873 bool scroll_on_main_thread = false; | 2882 bool scroll_on_main_thread = false; |
| 2874 LayerImpl* scroll_layer_impl = | 2883 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 2875 FindScrollLayerForDeviceViewportPoint(device_viewport_point, | 2884 device_viewport_point, InputHandler::GESTURE, layer_impl, |
| 2876 InputHandler::Gesture, | 2885 &scroll_on_main_thread, NULL); |
| 2877 layer_impl, | |
| 2878 &scroll_on_main_thread, | |
| 2879 NULL); | |
| 2880 if (scroll_on_main_thread || !scroll_layer_impl) | 2886 if (scroll_on_main_thread || !scroll_layer_impl) |
| 2881 return; | 2887 return; |
| 2882 | 2888 |
| 2883 ScrollbarAnimationController* animation_controller = | 2889 ScrollbarAnimationController* animation_controller = |
| 2884 scroll_layer_impl->scrollbar_animation_controller(); | 2890 scroll_layer_impl->scrollbar_animation_controller(); |
| 2885 if (!animation_controller) | 2891 if (!animation_controller) |
| 2886 return; | 2892 return; |
| 2887 | 2893 |
| 2888 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? | 2894 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? |
| 2889 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 2895 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 switch (bitmap.GetFormat()) { | 3372 switch (bitmap.GetFormat()) { |
| 3367 case UIResourceBitmap::RGBA8: | 3373 case UIResourceBitmap::RGBA8: |
| 3368 break; | 3374 break; |
| 3369 case UIResourceBitmap::ALPHA_8: | 3375 case UIResourceBitmap::ALPHA_8: |
| 3370 format = ALPHA_8; | 3376 format = ALPHA_8; |
| 3371 break; | 3377 break; |
| 3372 case UIResourceBitmap::ETC1: | 3378 case UIResourceBitmap::ETC1: |
| 3373 format = ETC1; | 3379 format = ETC1; |
| 3374 break; | 3380 break; |
| 3375 } | 3381 } |
| 3376 id = | 3382 id = resource_provider_->CreateResource( |
| 3377 resource_provider_->CreateResource(bitmap.GetSize(), | 3383 bitmap.GetSize(), wrap_mode, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 3378 wrap_mode, | 3384 format); |
| 3379 ResourceProvider::TextureHintImmutable, | |
| 3380 format); | |
| 3381 | 3385 |
| 3382 UIResourceData data; | 3386 UIResourceData data; |
| 3383 data.resource_id = id; | 3387 data.resource_id = id; |
| 3384 data.size = bitmap.GetSize(); | 3388 data.size = bitmap.GetSize(); |
| 3385 data.opaque = bitmap.GetOpaque(); | 3389 data.opaque = bitmap.GetOpaque(); |
| 3386 | 3390 |
| 3387 ui_resource_map_[uid] = data; | 3391 ui_resource_map_[uid] = data; |
| 3388 | 3392 |
| 3389 AutoLockUIResourceBitmap bitmap_lock(bitmap); | 3393 AutoLockUIResourceBitmap bitmap_lock(bitmap); |
| 3390 resource_provider_->SetPixels(id, | 3394 resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), |
| 3391 bitmap_lock.GetPixels(), | 3395 bitmap.GetSize()); |
| 3392 gfx::Rect(bitmap.GetSize()), | |
| 3393 gfx::Rect(bitmap.GetSize()), | |
| 3394 gfx::Vector2d(0, 0)); | |
| 3395 MarkUIResourceNotEvicted(uid); | 3396 MarkUIResourceNotEvicted(uid); |
| 3396 } | 3397 } |
| 3397 | 3398 |
| 3398 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 3399 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 3399 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | 3400 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 3400 if (id) { | 3401 if (id) { |
| 3401 resource_provider_->DeleteResource(id); | 3402 resource_provider_->DeleteResource(id); |
| 3402 ui_resource_map_.erase(uid); | 3403 ui_resource_map_.erase(uid); |
| 3403 } | 3404 } |
| 3404 MarkUIResourceNotEvicted(uid); | 3405 MarkUIResourceNotEvicted(uid); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3468 (*it)->OnSetNeedsRedrawOnImpl(); | 3469 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3469 } | 3470 } |
| 3470 | 3471 |
| 3471 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3472 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
| 3472 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3473 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3473 for (; it != swap_promise_monitor_.end(); it++) | 3474 for (; it != swap_promise_monitor_.end(); it++) |
| 3474 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3475 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
| 3475 } | 3476 } |
| 3476 | 3477 |
| 3477 } // namespace cc | 3478 } // namespace cc |
| OLD | NEW |