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/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 if (scrollbar_layer->orientation() == HORIZONTAL) { | 1315 if (scrollbar_layer->orientation() == HORIZONTAL) { |
1316 float visible_ratio = clip_rect.width() / scroll_rect.width(); | 1316 float visible_ratio = clip_rect.width() / scroll_rect.width(); |
1317 scrollbar_needs_animation |= | 1317 scrollbar_needs_animation |= |
1318 scrollbar_layer->SetCurrentPos(current_offset.x()); | 1318 scrollbar_layer->SetCurrentPos(current_offset.x()); |
1319 scrollbar_needs_animation |= | 1319 scrollbar_needs_animation |= |
1320 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); | 1320 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); |
1321 scrollbar_needs_animation |= | 1321 scrollbar_needs_animation |= |
1322 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1322 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
1323 } else { | 1323 } else { |
1324 float visible_ratio = clip_rect.height() / scroll_rect.height(); | 1324 float visible_ratio = clip_rect.height() / scroll_rect.height(); |
1325 scrollbar_needs_animation |= | 1325 bool y_offset_did_change = |
1326 scrollbar_layer->SetCurrentPos(current_offset.y()); | 1326 scrollbar_layer->SetCurrentPos(current_offset.y()); |
| 1327 scrollbar_needs_animation |= y_offset_did_change; |
1327 scrollbar_needs_animation |= | 1328 scrollbar_needs_animation |= |
1328 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | 1329 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); |
1329 scrollbar_needs_animation |= | 1330 scrollbar_needs_animation |= |
1330 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1331 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
| 1332 if (y_offset_did_change && layer_tree_impl()->IsActiveTree() && |
| 1333 this == layer_tree_impl()->InnerViewportScrollLayer()) { |
| 1334 TRACE_COUNTER_ID1("cc", "scroll_offset_y", this->id(), |
| 1335 current_offset.y()); |
| 1336 } |
1331 } | 1337 } |
1332 if (scrollbar_needs_animation) { | 1338 if (scrollbar_needs_animation) { |
1333 layer_tree_impl()->set_needs_update_draw_properties(); | 1339 layer_tree_impl()->set_needs_update_draw_properties(); |
1334 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars | 1340 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars |
1335 // should activate for every scroll on the main frame, not just the | 1341 // should activate for every scroll on the main frame, not just the |
1336 // scrolls that move the pinch virtual viewport (i.e. trigger from | 1342 // scrolls that move the pinch virtual viewport (i.e. trigger from |
1337 // either inner or outer viewport). | 1343 // either inner or outer viewport). |
1338 if (scrollbar_animation_controller_) { | 1344 if (scrollbar_animation_controller_) { |
1339 // Non-overlay scrollbars shouldn't trigger animations. | 1345 // Non-overlay scrollbars shouldn't trigger animations. |
1340 if (scrollbar_layer->is_overlay_scrollbar()) | 1346 if (scrollbar_layer->is_overlay_scrollbar()) |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 gfx::Transform scaled_draw_transform = | 1624 gfx::Transform scaled_draw_transform = |
1619 draw_properties_.target_space_transform; | 1625 draw_properties_.target_space_transform; |
1620 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); | 1626 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); |
1621 gfx::Size scaled_content_bounds = | 1627 gfx::Size scaled_content_bounds = |
1622 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); | 1628 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); |
1623 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, | 1629 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, |
1624 gfx::Rect(scaled_content_bounds)); | 1630 gfx::Rect(scaled_content_bounds)); |
1625 } | 1631 } |
1626 | 1632 |
1627 } // namespace cc | 1633 } // namespace cc |
OLD | NEW |