| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/scoped_transform_overview_window.h" | 5 #include "ash/common/wm/overview/scoped_transform_overview_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 original_transform_(window->GetTargetTransform()), | 261 original_transform_(window->GetTargetTransform()), |
| 262 original_opacity_(window->GetTargetOpacity()), | 262 original_opacity_(window->GetTargetOpacity()), |
| 263 weak_ptr_factory_(this) {} | 263 weak_ptr_factory_(this) {} |
| 264 | 264 |
| 265 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} | 265 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} |
| 266 | 266 |
| 267 void ScopedTransformOverviewWindow::RestoreWindow() { | 267 void ScopedTransformOverviewWindow::RestoreWindow() { |
| 268 ScopedAnimationSettings animation_settings_list; | 268 ScopedAnimationSettings animation_settings_list; |
| 269 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, | 269 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, |
| 270 &animation_settings_list); | 270 &animation_settings_list); |
| 271 SetTransform(window()->GetRootWindow(), original_transform_, 0); | 271 SetTransform(window()->GetRootWindow(), original_transform_, false, 0); |
| 272 | 272 |
| 273 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 273 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 274 CreateScopedOverviewAnimationSettings( | 274 CreateScopedOverviewAnimationSettings( |
| 275 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, | 275 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, |
| 276 window_); | 276 window_); |
| 277 gfx::Transform transform; | 277 gfx::Transform transform; |
| 278 if ((original_visibility_ == ORIGINALLY_MINIMIZED && | 278 if ((original_visibility_ == ORIGINALLY_MINIMIZED && |
| 279 window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) || | 279 window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) || |
| 280 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && | 280 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED && |
| 281 window_->GetWindowState()->GetStateType() != | 281 window_->GetWindowState()->GetStateType() != |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 gfx::Transform transform; | 410 gfx::Transform transform; |
| 411 transform.Translate(dst_rect.x() - src_rect.x(), dst_rect.y() - src_rect.y()); | 411 transform.Translate(dst_rect.x() - src_rect.x(), dst_rect.y() - src_rect.y()); |
| 412 transform.Scale(static_cast<float>(dst_rect.width()) / src_rect.width(), | 412 transform.Scale(static_cast<float>(dst_rect.width()) / src_rect.width(), |
| 413 static_cast<float>(dst_rect.height()) / src_rect.height()); | 413 static_cast<float>(dst_rect.height()) / src_rect.height()); |
| 414 return transform; | 414 return transform; |
| 415 } | 415 } |
| 416 | 416 |
| 417 void ScopedTransformOverviewWindow::SetTransform( | 417 void ScopedTransformOverviewWindow::SetTransform( |
| 418 WmWindow* root_window, | 418 WmWindow* root_window, |
| 419 const gfx::Transform& transform, | 419 const gfx::Transform& transform, |
| 420 bool use_masks, |
| 420 float radius) { | 421 float radius) { |
| 421 DCHECK(overview_started_); | 422 DCHECK(overview_started_); |
| 422 | 423 |
| 423 if (ash::MaterialDesignController::IsOverviewMaterial() && | 424 if (ash::MaterialDesignController::IsOverviewMaterial() && |
| 424 &transform != &original_transform_) { | 425 &transform != &original_transform_) { |
| 425 if (!mask_) { | 426 if (use_masks && !mask_) { |
| 426 mask_.reset(new OverviewContentMask(radius)); | 427 mask_.reset(new OverviewContentMask(radius)); |
| 427 mask_->layer()->SetFillsBoundsOpaquely(false); | 428 mask_->layer()->SetFillsBoundsOpaquely(false); |
| 428 window()->GetLayer()->SetMaskLayer(mask_->layer()); | 429 window()->GetLayer()->SetMaskLayer(mask_->layer()); |
| 429 } | 430 } |
| 430 gfx::Rect bounds(GetTargetBoundsInScreen().size()); | 431 gfx::Rect bounds(GetTargetBoundsInScreen().size()); |
| 431 mask_->layer()->SetBounds(bounds); | 432 if (mask_) { |
| 432 mask_->set_radius(radius); | 433 mask_->layer()->SetBounds(bounds); |
| 433 window()->GetLayer()->SchedulePaint(bounds); | 434 mask_->set_radius(radius); |
| 434 | 435 window()->GetLayer()->SchedulePaint(bounds); |
| 436 } |
| 435 if (!determined_original_window_shape_) { | 437 if (!determined_original_window_shape_) { |
| 436 determined_original_window_shape_ = true; | 438 determined_original_window_shape_ = true; |
| 437 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); | 439 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); |
| 438 if (!original_window_shape_ && window_shape) | 440 if (!original_window_shape_ && window_shape) |
| 439 original_window_shape_.reset(new SkRegion(*window_shape)); | 441 original_window_shape_.reset(new SkRegion(*window_shape)); |
| 440 } | 442 } |
| 441 const int inset = | 443 const int inset = |
| 442 window()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET); | 444 use_masks ? window()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET) |
| 445 : 0; |
| 443 if (inset > 0) { | 446 if (inset > 0) { |
| 444 bounds.Inset(0, inset, 0, 0); | 447 bounds.Inset(0, inset, 0, 0); |
| 445 SkRegion* region = new SkRegion; | 448 SkRegion* region = new SkRegion; |
| 446 region->setRect(RectToSkIRect(bounds)); | 449 region->setRect(RectToSkIRect(bounds)); |
| 447 if (original_window_shape_) | 450 if (original_window_shape_) |
| 448 region->op(*original_window_shape_, SkRegion::kIntersect_Op); | 451 region->op(*original_window_shape_, SkRegion::kIntersect_Op); |
| 449 window()->GetLayer()->SetAlphaShape(base::WrapUnique(region)); | 452 window()->GetLayer()->SetAlphaShape(base::WrapUnique(region)); |
| 450 window()->SetMasksToBounds(true); | 453 window()->SetMasksToBounds(true); |
| 451 } | 454 } |
| 452 } | 455 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 if (parent_window) | 498 if (parent_window) |
| 496 parent_window->CloseWidget(); | 499 parent_window->CloseWidget(); |
| 497 } | 500 } |
| 498 | 501 |
| 499 // static | 502 // static |
| 500 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { | 503 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { |
| 501 immediate_close_for_tests = true; | 504 immediate_close_for_tests = true; |
| 502 } | 505 } |
| 503 | 506 |
| 504 } // namespace ash | 507 } // namespace ash |
| OLD | NEW |