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 // Get the current_offset_.y() value for a sanity-check on scrolling | |
enne (OOO)
2015/03/24 17:53:21
This comment seems unnecessary.
wjmaclean
2015/03/24 18:21:40
Don't we want to indicate why we're interested in
| |
1333 // benchmark metrics. Specifically, we want to make sure | |
1334 // BasicMouseWheelSmoothScrollGesture has proper scroll curves. | |
1335 if (y_offset_did_change && layer_tree_impl()->IsActiveTree()) { | |
1336 TRACE_COUNTER_ID1("gpu", "scroll_offset_y", this->id(), | |
enne (OOO)
2015/03/24 17:53:21
This should be a cc trace, I think?
Should we onl
wjmaclean
2015/03/24 18:21:40
Done.
| |
1337 current_offset.y()); | |
1338 } | |
1331 } | 1339 } |
1332 if (scrollbar_needs_animation) { | 1340 if (scrollbar_needs_animation) { |
1333 layer_tree_impl()->set_needs_update_draw_properties(); | 1341 layer_tree_impl()->set_needs_update_draw_properties(); |
1334 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars | 1342 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars |
1335 // should activate for every scroll on the main frame, not just the | 1343 // should activate for every scroll on the main frame, not just the |
1336 // scrolls that move the pinch virtual viewport (i.e. trigger from | 1344 // scrolls that move the pinch virtual viewport (i.e. trigger from |
1337 // either inner or outer viewport). | 1345 // either inner or outer viewport). |
1338 if (scrollbar_animation_controller_) { | 1346 if (scrollbar_animation_controller_) { |
1339 // Non-overlay scrollbars shouldn't trigger animations. | 1347 // Non-overlay scrollbars shouldn't trigger animations. |
1340 if (scrollbar_layer->is_overlay_scrollbar()) | 1348 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 = | 1626 gfx::Transform scaled_draw_transform = |
1619 draw_properties_.target_space_transform; | 1627 draw_properties_.target_space_transform; |
1620 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); | 1628 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); |
1621 gfx::Size scaled_content_bounds = | 1629 gfx::Size scaled_content_bounds = |
1622 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); | 1630 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); |
1623 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, | 1631 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, |
1624 gfx::Rect(scaled_content_bounds)); | 1632 gfx::Rect(scaled_content_bounds)); |
1625 } | 1633 } |
1626 | 1634 |
1627 } // namespace cc | 1635 } // namespace cc |
OLD | NEW |