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

Side by Side Diff: ui/wm/core/shadow.cc

Issue 2083083004: cc: nine patch: add occlusion support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on ToT before commit 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
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/skia/include/core/SkBitmap.h" 7 #include "third_party/skia/include/core/SkBitmap.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/compositor/scoped_layer_animation_settings.h" 10 #include "ui/compositor/scoped_layer_animation_settings.h"
(...skipping 10 matching lines...) Expand all
21 // curved corners that extend inwards beyond a window's borders. 21 // curved corners that extend inwards beyond a window's borders.
22 const int kActiveInteriorAperture = 134; 22 const int kActiveInteriorAperture = 134;
23 const int kInactiveInteriorAperture = 134; 23 const int kInactiveInteriorAperture = 134;
24 const int kSmallInteriorAperture = 9; 24 const int kSmallInteriorAperture = 9;
25 25
26 // Interior inset for different styles. 26 // Interior inset for different styles.
27 const int kActiveInteriorInset = 64; 27 const int kActiveInteriorInset = 64;
28 const int kInactiveInteriorInset = 64; 28 const int kInactiveInteriorInset = 64;
29 const int kSmallInteriorInset = 4; 29 const int kSmallInteriorInset = 4;
30 30
31 // Rounded corners are overdrawn on top of the window's content layer,
32 // we need to exclude them from the occlusion area.
33 const int kRoundedCornerRadius = 2;
34
31 // Duration for opacity animation in milliseconds. 35 // Duration for opacity animation in milliseconds.
32 const int kShadowAnimationDurationMs = 100; 36 const int kShadowAnimationDurationMs = 100;
33 37
34 int GetShadowApertureForStyle(wm::Shadow::Style style) { 38 int GetShadowApertureForStyle(wm::Shadow::Style style) {
35 switch (style) { 39 switch (style) {
36 case wm::Shadow::STYLE_ACTIVE: 40 case wm::Shadow::STYLE_ACTIVE:
37 return kActiveInteriorAperture; 41 return kActiveInteriorAperture;
38 case wm::Shadow::STYLE_INACTIVE: 42 case wm::Shadow::STYLE_INACTIVE:
39 return kInactiveInteriorAperture; 43 return kInactiveInteriorAperture;
40 case wm::Shadow::STYLE_SMALL: 44 case wm::Shadow::STYLE_SMALL:
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 gfx::Rect layer_bounds = content_bounds_; 179 gfx::Rect layer_bounds = content_bounds_;
176 layer_bounds.Inset(-interior_inset_, -interior_inset_); 180 layer_bounds.Inset(-interior_inset_, -interior_inset_);
177 layer()->SetBounds(layer_bounds); 181 layer()->SetBounds(layer_bounds);
178 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size())); 182 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size()));
179 183
180 // Update the shadow aperture and border for style. Note that border is in 184 // Update the shadow aperture and border for style. Note that border is in
181 // layer space and it cannot exceed the bounds of the layer. 185 // layer space and it cannot exceed the bounds of the layer.
182 int aperture = GetShadowApertureForStyle(style_); 186 int aperture = GetShadowApertureForStyle(style_);
183 int aperture_x = std::min(aperture, layer_bounds.width() / 2); 187 int aperture_x = std::min(aperture, layer_bounds.width() / 2);
184 int aperture_y = std::min(aperture, layer_bounds.height() / 2); 188 int aperture_y = std::min(aperture, layer_bounds.height() / 2);
185 shadow_layer_->UpdateNinePatchLayerAperture( 189 gfx::Rect aperture_rect(aperture_x, aperture_y,
186 gfx::Rect(aperture_x, aperture_y, 190 image_size_.width() - aperture_x * 2,
187 image_size_.width() - aperture_x * 2, 191 image_size_.height() - aperture_y * 2);
188 image_size_.height() - aperture_y * 2)); 192
193 shadow_layer_->UpdateNinePatchLayerAperture(aperture_rect);
189 shadow_layer_->UpdateNinePatchLayerBorder( 194 shadow_layer_->UpdateNinePatchLayerBorder(
190 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2)); 195 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
196
197 // The content bounds in the shadow's layer space are offsetted by
198 // |interior_inset_|. The occlusion area also has to be shrinked to
199 // allow rounded corners overdrawing on top of the window's content.
200 gfx::Rect content_bounds(
201 content_bounds_.x() + interior_inset_ + kRoundedCornerRadius,
202 content_bounds_.y() + interior_inset_ + kRoundedCornerRadius,
203 content_bounds_.width() - 2 * kRoundedCornerRadius,
204 content_bounds_.height() - 2 * kRoundedCornerRadius);
205 shadow_layer_->UpdateNinePatchOcclusion(content_bounds);
191 } 206 }
192 207
193 } // namespace wm 208 } // namespace wm
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698