Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: ash/common/wm/overview/window_grid.cc

Issue 2184543005: [ash-md] Improves smoothness with many windows in overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/common/wm/overview/window_grid.h" 5 #include "ash/common/wm/overview/window_grid.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 #include "ash/common/wm/overview/window_selector_delegate.h" 23 #include "ash/common/wm/overview/window_selector_delegate.h"
24 #include "ash/common/wm/overview/window_selector_item.h" 24 #include "ash/common/wm/overview/window_selector_item.h"
25 #include "ash/common/wm/window_state.h" 25 #include "ash/common/wm/window_state.h"
26 #include "ash/common/wm/wm_screen_util.h" 26 #include "ash/common/wm/wm_screen_util.h"
27 #include "ash/common/wm_lookup.h" 27 #include "ash/common/wm_lookup.h"
28 #include "ash/common/wm_root_window_controller.h" 28 #include "ash/common/wm_root_window_controller.h"
29 #include "ash/common/wm_window.h" 29 #include "ash/common/wm_window.h"
30 #include "base/command_line.h" 30 #include "base/command_line.h"
31 #include "base/i18n/string_search.h" 31 #include "base/i18n/string_search.h"
32 #include "base/memory/scoped_vector.h" 32 #include "base/memory/scoped_vector.h"
33 #include "base/strings/string_number_conversions.h"
33 #include "third_party/skia/include/core/SkColor.h" 34 #include "third_party/skia/include/core/SkColor.h"
34 #include "third_party/skia/include/pathops/SkPathOps.h" 35 #include "third_party/skia/include/pathops/SkPathOps.h"
35 #include "ui/compositor/layer_animation_observer.h" 36 #include "ui/compositor/layer_animation_observer.h"
36 #include "ui/compositor/scoped_layer_animation_settings.h" 37 #include "ui/compositor/scoped_layer_animation_settings.h"
37 #include "ui/gfx/animation/tween.h" 38 #include "ui/gfx/animation/tween.h"
38 #include "ui/gfx/canvas.h" 39 #include "ui/gfx/canvas.h"
39 #include "ui/gfx/geometry/safe_integer_conversions.h" 40 #include "ui/gfx/geometry/safe_integer_conversions.h"
40 #include "ui/gfx/geometry/vector2d.h" 41 #include "ui/gfx/geometry/vector2d.h"
41 #include "ui/gfx/scoped_canvas.h" 42 #include "ui/gfx/scoped_canvas.h"
42 #include "ui/views/background.h" 43 #include "ui/views/background.h"
(...skipping 22 matching lines...) Expand all
65 66
66 // Conceptually the window overview is a table or grid of cells having this 67 // Conceptually the window overview is a table or grid of cells having this
67 // fixed aspect ratio. The number of columns is determined by maximizing the 68 // fixed aspect ratio. The number of columns is determined by maximizing the
68 // area of them based on the number of window_list. 69 // area of them based on the number of window_list.
69 const float kCardAspectRatio = 4.0f / 3.0f; 70 const float kCardAspectRatio = 4.0f / 3.0f;
70 71
71 // The minimum number of cards along the major axis (i.e. horizontally on a 72 // The minimum number of cards along the major axis (i.e. horizontally on a
72 // landscape orientation). 73 // landscape orientation).
73 const int kMinCardsMajor = 3; 74 const int kMinCardsMajor = 3;
74 75
76 // Hiding window headers can be resource intensive. Only hide the headers when
77 // the number of windows in this grid is less or equal than this number.
78 const int kMaxWindowsCountToHideHeader = 10;
79
75 const int kOverviewSelectorTransitionMilliseconds = 250; 80 const int kOverviewSelectorTransitionMilliseconds = 250;
76 81
77 // The color and opacity of the screen shield in overview. 82 // The color and opacity of the screen shield in overview.
78 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); 83 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0);
79 const float kShieldOpacity = 0.7f; 84 const float kShieldOpacity = 0.7f;
80 85
81 // The color and opacity of the overview selector. 86 // The color and opacity of the overview selector.
82 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); 87 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0);
83 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255); 88 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255);
84 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255); 89 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 void WindowGrid::PrepareForOverview() { 449 void WindowGrid::PrepareForOverview() {
445 if (ash::MaterialDesignController::IsOverviewMaterial()) 450 if (ash::MaterialDesignController::IsOverviewMaterial())
446 InitShieldWidget(); 451 InitShieldWidget();
447 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) 452 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter)
448 (*iter)->PrepareForOverview(); 453 (*iter)->PrepareForOverview();
449 } 454 }
450 455
451 void WindowGrid::PositionWindowsMD(bool animate) { 456 void WindowGrid::PositionWindowsMD(bool animate) {
452 if (window_list_.empty()) 457 if (window_list_.empty())
453 return; 458 return;
459
460 const int kUnlimited = -1;
461 const size_t windows_count = window_list_.size();
462 const base::CommandLine* command_line =
463 base::CommandLine::ForCurrentProcess();
464 int windows_to_use_masks = kMaxWindowsCountToHideHeader;
465 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseMaskInOverview) &&
466 (!base::StringToInt(command_line->GetSwitchValueASCII(
467 switches::kAshMaxWindowsToUseMaskInOverview),
468 &windows_to_use_masks) ||
469 windows_to_use_masks <= kUnlimited)) {
470 windows_to_use_masks = kMaxWindowsCountToHideHeader;
471 }
472 int windows_to_use_shapes = kUnlimited;
473 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseShapeInOverview) &&
474 (!base::StringToInt(command_line->GetSwitchValueASCII(
475 switches::kAshMaxWindowsToUseShapeInOverview),
476 &windows_to_use_shapes) ||
477 windows_to_use_shapes <= kUnlimited)) {
478 windows_to_use_shapes = kUnlimited;
479 }
480 WindowSelectorItem::set_use_mask(windows_to_use_masks <= kUnlimited ||
481 static_cast<int>(windows_count) <=
482 windows_to_use_masks);
483 WindowSelectorItem::set_use_shape(windows_to_use_shapes <= kUnlimited ||
484 static_cast<int>(windows_count) <=
485 windows_to_use_shapes);
486
454 gfx::Rect total_bounds = 487 gfx::Rect total_bounds =
455 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent( 488 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent(
456 root_window_->GetChildByShellWindowId( 489 root_window_->GetChildByShellWindowId(
457 kShellWindowId_DefaultContainer))); 490 kShellWindowId_DefaultContainer)));
458 // Windows occupy vertically centered area with additional vertical insets. 491 // Windows occupy vertically centered area with additional vertical insets.
459 int horizontal_inset = 492 int horizontal_inset =
460 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(), 493 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(),
461 kOverviewInsetRatio * total_bounds.height())); 494 kOverviewInsetRatio * total_bounds.height()));
462 int vertical_inset = 495 int vertical_inset =
463 horizontal_inset + 496 horizontal_inset +
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // |right_bound| was reverted. Perform one last pass to position the |rects|. 585 // |right_bound| was reverted. Perform one last pass to position the |rects|.
553 if (make_last_adjustment) { 586 if (make_last_adjustment) {
554 gfx::Rect overview_bounds(total_bounds); 587 gfx::Rect overview_bounds(total_bounds);
555 overview_bounds.set_width(right_bound - total_bounds.x()); 588 overview_bounds.set_width(right_bound - total_bounds.x());
556 FitWindowRectsInBounds(overview_bounds, 589 FitWindowRectsInBounds(overview_bounds,
557 std::min(kMaxHeight + 2 * kWindowMarginMD, height), 590 std::min(kMaxHeight + 2 * kWindowMarginMD, height),
558 &rects, &max_bottom, &min_right, &max_right); 591 &rects, &max_bottom, &min_right, &max_right);
559 } 592 }
560 // Position the windows centering the left-aligned rows vertically. 593 // Position the windows centering the left-aligned rows vertically.
561 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2); 594 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2);
562 for (size_t i = 0; i < window_list_.size(); ++i) { 595 for (size_t i = 0; i < windows_count; ++i) {
563 window_list_[i]->SetBounds( 596 window_list_[i]->SetBounds(
564 rects[i] + offset, 597 rects[i] + offset,
565 animate 598 animate
566 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS 599 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
567 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 600 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
568 } 601 }
569 602
570 // If the selection widget is active, reposition it without any animation. 603 // If the selection widget is active, reposition it without any animation.
571 if (selection_widget_) 604 if (selection_widget_)
572 MoveSelectionWidgetToTarget(animate); 605 MoveSelectionWidgetToTarget(animate);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 *min_right = left; 1015 *min_right = left;
983 if (*max_right < left) 1016 if (*max_right < left)
984 *max_right = left; 1017 *max_right = left;
985 } 1018 }
986 *max_bottom = top + height; 1019 *max_bottom = top + height;
987 } 1020 }
988 return windows_fit; 1021 return windows_fit;
989 } 1022 }
990 1023
991 } // namespace ash 1024 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/scoped_transform_overview_window.cc ('k') | ash/common/wm/overview/window_selector_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698