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

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

Issue 2146323004: [ash-md] Improves smoothness with many windows in overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Improves smoothness with many windows in overview (added flags) Created 4 years, 5 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 23 matching lines...) Expand all
66 67
67 // Conceptually the window overview is a table or grid of cells having this 68 // Conceptually the window overview is a table or grid of cells having this
68 // fixed aspect ratio. The number of columns is determined by maximizing the 69 // fixed aspect ratio. The number of columns is determined by maximizing the
69 // area of them based on the number of window_list. 70 // area of them based on the number of window_list.
70 const float kCardAspectRatio = 4.0f / 3.0f; 71 const float kCardAspectRatio = 4.0f / 3.0f;
71 72
72 // The minimum number of cards along the major axis (i.e. horizontally on a 73 // The minimum number of cards along the major axis (i.e. horizontally on a
73 // landscape orientation). 74 // landscape orientation).
74 const int kMinCardsMajor = 3; 75 const int kMinCardsMajor = 3;
75 76
77 // Hiding window headers can be resource intensive. Only hide the headers when
78 // the number of windows in this grid is less or equal than this number.
79 const int kMaxWindowsCountToHideHeader = 10;
80
76 const int kOverviewSelectorTransitionMilliseconds = 250; 81 const int kOverviewSelectorTransitionMilliseconds = 250;
77 82
78 // The color and opacity of the screen shield in overview. 83 // The color and opacity of the screen shield in overview.
79 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); 84 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0);
80 const float kShieldOpacity = 0.7f; 85 const float kShieldOpacity = 0.7f;
81 86
82 // The color and opacity of the overview selector. 87 // The color and opacity of the overview selector.
83 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); 88 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0);
84 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255); 89 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255);
85 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255); 90 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 void WindowGrid::PrepareForOverview() { 450 void WindowGrid::PrepareForOverview() {
446 if (ash::MaterialDesignController::IsOverviewMaterial()) 451 if (ash::MaterialDesignController::IsOverviewMaterial())
447 InitShieldWidget(); 452 InitShieldWidget();
448 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) 453 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter)
449 (*iter)->PrepareForOverview(); 454 (*iter)->PrepareForOverview();
450 } 455 }
451 456
452 void WindowGrid::PositionWindowsMD(bool animate) { 457 void WindowGrid::PositionWindowsMD(bool animate) {
453 if (window_list_.empty()) 458 if (window_list_.empty())
454 return; 459 return;
460
461 const int kUnlimited = -1;
462 const size_t windows_count = window_list_.size();
463 const base::CommandLine* command_line =
464 base::CommandLine::ForCurrentProcess();
465 int windows_to_use_masks = kMaxWindowsCountToHideHeader;
466 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseMaskInOverview) &&
467 (!base::StringToInt(command_line->GetSwitchValueASCII(
468 switches::kAshMaxWindowsToUseMaskInOverview),
469 &windows_to_use_masks) ||
470 windows_to_use_masks <= kUnlimited)) {
471 windows_to_use_masks = kMaxWindowsCountToHideHeader;
472 }
473 int windows_to_use_shapes = kUnlimited;
474 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseShapeInOverview) &&
475 (!base::StringToInt(command_line->GetSwitchValueASCII(
476 switches::kAshMaxWindowsToUseShapeInOverview),
477 &windows_to_use_shapes) ||
478 windows_to_use_shapes <= kUnlimited)) {
479 windows_to_use_shapes = kUnlimited;
480 }
481 WindowSelectorItem::set_use_mask(windows_to_use_masks <= kUnlimited ||
482 static_cast<int>(windows_count) <=
483 windows_to_use_masks);
484 WindowSelectorItem::set_use_shape(windows_to_use_shapes <= kUnlimited ||
485 static_cast<int>(windows_count) <=
486 windows_to_use_shapes);
487
455 gfx::Rect total_bounds = 488 gfx::Rect total_bounds =
456 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent( 489 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent(
457 root_window_->GetChildByShellWindowId( 490 root_window_->GetChildByShellWindowId(
458 kShellWindowId_DefaultContainer))); 491 kShellWindowId_DefaultContainer)));
459 // Windows occupy vertically centered area with additional vertical insets. 492 // Windows occupy vertically centered area with additional vertical insets.
460 int horizontal_inset = 493 int horizontal_inset =
461 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(), 494 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(),
462 kOverviewInsetRatio * total_bounds.height())); 495 kOverviewInsetRatio * total_bounds.height()));
463 int vertical_inset = 496 int vertical_inset =
464 horizontal_inset + 497 horizontal_inset +
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // |right_bound| was reverted. Perform one last pass to position the |rects|. 586 // |right_bound| was reverted. Perform one last pass to position the |rects|.
554 if (make_last_adjustment) { 587 if (make_last_adjustment) {
555 gfx::Rect overview_bounds(total_bounds); 588 gfx::Rect overview_bounds(total_bounds);
556 overview_bounds.set_width(right_bound - total_bounds.x()); 589 overview_bounds.set_width(right_bound - total_bounds.x());
557 FitWindowRectsInBounds(overview_bounds, 590 FitWindowRectsInBounds(overview_bounds,
558 std::min(kMaxHeight + 2 * kWindowMarginMD, height), 591 std::min(kMaxHeight + 2 * kWindowMarginMD, height),
559 &rects, &max_bottom, &min_right, &max_right); 592 &rects, &max_bottom, &min_right, &max_right);
560 } 593 }
561 // Position the windows centering the left-aligned rows vertically. 594 // Position the windows centering the left-aligned rows vertically.
562 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2); 595 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2);
563 for (size_t i = 0; i < window_list_.size(); ++i) { 596 for (size_t i = 0; i < windows_count; ++i) {
564 window_list_[i]->SetBounds( 597 window_list_[i]->SetBounds(
565 rects[i] + offset, 598 rects[i] + offset,
566 animate 599 animate
567 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS 600 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
568 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 601 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
569 } 602 }
570 603
571 // If the selection widget is active, reposition it without any animation. 604 // If the selection widget is active, reposition it without any animation.
572 if (selection_widget_) 605 if (selection_widget_)
573 MoveSelectionWidgetToTarget(animate); 606 MoveSelectionWidgetToTarget(animate);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 *min_right = left; 1047 *min_right = left;
1015 if (*max_right < left) 1048 if (*max_right < left)
1016 *max_right = left; 1049 *max_right = left;
1017 } 1050 }
1018 *max_bottom = top + height; 1051 *max_bottom = top + height;
1019 } 1052 }
1020 return windows_fit; 1053 return windows_fit;
1021 } 1054 }
1022 1055
1023 } // namespace ash 1056 } // 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