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