| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/wm/core/shadow.h" | 5 #include "ui/wm/core/shadow.h" |
| 6 | 6 |
| 7 #include "ui/base/resource/resource_bundle.h" | 7 #include "ui/base/resource/resource_bundle.h" |
| 8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
| 9 #include "ui/compositor/scoped_layer_animation_settings.h" | 9 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 10 #include "ui/gfx/geometry/insets.h" | 10 #include "ui/gfx/geometry/insets.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 Shadow::Shadow() | 28 Shadow::Shadow() |
| 29 : desired_elevation_(ShadowElevation::NONE), | 29 : desired_elevation_(ShadowElevation::NONE), |
| 30 rounded_corner_radius_(kDefaultRoundedCornerRadius) {} | 30 rounded_corner_radius_(kDefaultRoundedCornerRadius) {} |
| 31 | 31 |
| 32 Shadow::~Shadow() {} | 32 Shadow::~Shadow() {} |
| 33 | 33 |
| 34 void Shadow::Init(ShadowElevation elevation) { | 34 void Shadow::Init(ShadowElevation elevation) { |
| 35 DCHECK_NE(ShadowElevation::DEFAULT, elevation); |
| 35 desired_elevation_ = elevation; | 36 desired_elevation_ = elevation; |
| 36 layer_.reset(new ui::Layer(ui::LAYER_NOT_DRAWN)); | 37 layer_.reset(new ui::Layer(ui::LAYER_NOT_DRAWN)); |
| 37 RecreateShadowLayer(); | 38 RecreateShadowLayer(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void Shadow::SetContentBounds(const gfx::Rect& content_bounds) { | 41 void Shadow::SetContentBounds(const gfx::Rect& content_bounds) { |
| 41 // When the window moves but doesn't change size, this is a no-op. (The | 42 // When the window moves but doesn't change size, this is a no-op. (The |
| 42 // origin stays the same in this case.) | 43 // origin stays the same in this case.) |
| 43 if (content_bounds == content_bounds_) | 44 if (content_bounds == content_bounds_) |
| 44 return; | 45 return; |
| 45 | 46 |
| 46 content_bounds_ = content_bounds; | 47 content_bounds_ = content_bounds; |
| 47 UpdateLayerBounds(); | 48 UpdateLayerBounds(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void Shadow::SetElevation(ShadowElevation elevation) { | 51 void Shadow::SetElevation(ShadowElevation elevation) { |
| 52 DCHECK_NE(ShadowElevation::DEFAULT, elevation); |
| 51 if (desired_elevation_ == elevation) | 53 if (desired_elevation_ == elevation) |
| 52 return; | 54 return; |
| 53 | 55 |
| 54 desired_elevation_ = elevation; | 56 desired_elevation_ = elevation; |
| 55 | 57 |
| 56 // Stop waiting for any as yet unfinished implicit animations. | 58 // Stop waiting for any as yet unfinished implicit animations. |
| 57 StopObservingImplicitAnimations(); | 59 StopObservingImplicitAnimations(); |
| 58 | 60 |
| 59 // The old shadow layer is the new fading out layer. | 61 // The old shadow layer is the new fading out layer. |
| 60 DCHECK(shadow_layer_); | 62 DCHECK(shadow_layer_); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 occlusion_bounds.Inset(-margins + gfx::Insets(rounded_corner_radius_)); | 173 occlusion_bounds.Inset(-margins + gfx::Insets(rounded_corner_radius_)); |
| 172 shadow_layer_->UpdateNinePatchOcclusion(occlusion_bounds); | 174 shadow_layer_->UpdateNinePatchOcclusion(occlusion_bounds); |
| 173 | 175 |
| 174 // The border is the same inset as the aperture. | 176 // The border is the same inset as the aperture. |
| 175 shadow_layer_->UpdateNinePatchLayerBorder( | 177 shadow_layer_->UpdateNinePatchLayerBorder( |
| 176 gfx::Rect(blur_region.left(), blur_region.top(), blur_region.width(), | 178 gfx::Rect(blur_region.left(), blur_region.top(), blur_region.width(), |
| 177 blur_region.height())); | 179 blur_region.height())); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace wm | 182 } // namespace wm |
| OLD | NEW |