OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 DCHECK(layer_tree_impl()->IsActiveTree()); | 351 DCHECK(layer_tree_impl()->IsActiveTree()); |
352 | 352 |
353 if (sent_scroll_delta_ == sent_scroll_delta) | 353 if (sent_scroll_delta_ == sent_scroll_delta) |
354 return; | 354 return; |
355 | 355 |
356 sent_scroll_delta_ = sent_scroll_delta; | 356 sent_scroll_delta_ = sent_scroll_delta; |
357 } | 357 } |
358 | 358 |
359 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { | 359 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { |
360 DCHECK(scrollable()); | 360 DCHECK(scrollable()); |
361 gfx::Vector2dF scroll_hidden; | |
362 if (!user_scrollable_horizontal_) { | |
363 scroll_hidden.set_x(scroll.x()); | |
364 scroll.set_x(0.f); | |
365 } | |
366 if (!user_scrollable_vertical_) { | |
367 scroll_hidden.set_y(scroll.y()); | |
368 scroll.set_y(0.f); | |
369 } | |
370 | |
371 gfx::Vector2dF min_delta = -scroll_offset_; | 361 gfx::Vector2dF min_delta = -scroll_offset_; |
372 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; | 362 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; |
373 // Clamp new_delta so that position + delta stays within scroll bounds. | 363 // Clamp new_delta so that position + delta stays within scroll bounds. |
374 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 364 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); |
375 new_delta.SetToMax(min_delta); | 365 new_delta.SetToMax(min_delta); |
376 new_delta.SetToMin(max_delta); | 366 new_delta.SetToMin(max_delta); |
377 gfx::Vector2dF unscrolled = | 367 gfx::Vector2dF unscrolled = |
378 ScrollDelta() + scroll + scroll_hidden - new_delta; | 368 ScrollDelta() + scroll - new_delta; |
379 SetScrollDelta(new_delta); | 369 SetScrollDelta(new_delta); |
380 return unscrolled; | 370 return unscrolled; |
381 } | 371 } |
382 | 372 |
383 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { | 373 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { |
384 // Pending tree never has sent scroll deltas | 374 // Pending tree never has sent scroll deltas |
385 DCHECK(layer_tree_impl()->IsActiveTree()); | 375 DCHECK(layer_tree_impl()->IsActiveTree()); |
386 | 376 |
387 // Apply sent scroll deltas to scroll position / scroll delta as if the | 377 // Apply sent scroll deltas to scroll position / scroll delta as if the |
388 // main thread had applied them and then committed those values. | 378 // main thread had applied them and then committed those values. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return InputHandler::ScrollIgnored; | 459 return InputHandler::ScrollIgnored; |
470 } | 460 } |
471 | 461 |
472 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { | 462 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { |
473 TRACE_EVENT0("cc", | 463 TRACE_EVENT0("cc", |
474 "LayerImpl::tryScroll: Ignored. Technically scrollable," | 464 "LayerImpl::tryScroll: Ignored. Technically scrollable," |
475 " but has no affordance in either direction."); | 465 " but has no affordance in either direction."); |
476 return InputHandler::ScrollIgnored; | 466 return InputHandler::ScrollIgnored; |
477 } | 467 } |
478 | 468 |
479 if (!user_scrollable_horizontal_ && !user_scrollable_vertical_) { | |
480 TRACE_EVENT0("cc", | |
481 "LayerImpl::TryScroll: Ignored. User gesture is not allowed" | |
482 " to scroll this layer."); | |
483 return InputHandler::ScrollIgnored; | |
484 } | |
485 | |
486 return InputHandler::ScrollStarted; | 469 return InputHandler::ScrollStarted; |
487 } | 470 } |
488 | 471 |
489 bool LayerImpl::DrawCheckerboardForMissingTiles() const { | 472 bool LayerImpl::DrawCheckerboardForMissingTiles() const { |
490 return draw_checkerboard_for_missing_tiles_ && | 473 return draw_checkerboard_for_missing_tiles_ && |
491 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; | 474 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; |
492 } | 475 } |
493 | 476 |
494 gfx::Rect LayerImpl::LayerRectToContentRect( | 477 gfx::Rect LayerImpl::LayerRectToContentRect( |
495 const gfx::RectF& layer_rect) const { | 478 const gfx::RectF& layer_rect) const { |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1396 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1414 AsValueInto(state.get()); | 1397 AsValueInto(state.get()); |
1415 return state.PassAs<base::Value>(); | 1398 return state.PassAs<base::Value>(); |
1416 } | 1399 } |
1417 | 1400 |
1418 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1401 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1419 benchmark->RunOnLayer(this); | 1402 benchmark->RunOnLayer(this); |
1420 } | 1403 } |
1421 | 1404 |
1422 } // namespace cc | 1405 } // namespace cc |
OLD | NEW |