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

Unified Diff: ash/mus/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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/layers/nine_patch_layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/shadow.cc
diff --git a/ash/mus/shadow.cc b/ash/mus/shadow.cc
index ceaae792b2491208ee4e3ff7c27f2d47e7590447..08731ea6a5dbb907c459d23b0d2c3979f51d5bf3 100644
--- a/ash/mus/shadow.cc
+++ b/ash/mus/shadow.cc
@@ -32,6 +32,10 @@ const int kActiveInteriorInset = 64;
const int kInactiveInteriorInset = 64;
const int kSmallInteriorInset = 4;
+// Rounded corners are overdrawn on top of the window's content layer,
+// we need to exclude them from the occlusion area.
+const int kRoundedCornerRadius = 2;
+
// Duration for opacity animation in milliseconds.
const int kShadowAnimationDurationMs = 100;
@@ -194,11 +198,23 @@ void Shadow::UpdateLayerBounds() {
int aperture = GetShadowApertureForStyle(style_);
int aperture_x = std::min(aperture, layer_bounds.width() / 2);
int aperture_y = std::min(aperture, layer_bounds.height() / 2);
- shadow_layer_->UpdateNinePatchLayerAperture(
- gfx::Rect(aperture_x, aperture_y, image_size_.width() - aperture_x * 2,
- image_size_.height() - aperture_y * 2));
+ gfx::Rect aperture_rect(aperture_x, aperture_y,
+ image_size_.width() - aperture_x * 2,
+ image_size_.height() - aperture_y * 2);
+
+ shadow_layer_->UpdateNinePatchLayerAperture(aperture_rect);
shadow_layer_->UpdateNinePatchLayerBorder(
gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
+
+ // The content bounds in the shadow's layer space are offsetted by
+ // |interior_inset_|. The occlusion area also has to be shrinked to
+ // allow rounded corners overdrawing on top of the window's content.
+ gfx::Rect content_bounds(
+ content_bounds_.x() + interior_inset_ + kRoundedCornerRadius,
+ content_bounds_.y() + interior_inset_ + kRoundedCornerRadius,
+ content_bounds_.width() - 2 * kRoundedCornerRadius,
+ content_bounds_.height() - 2 * kRoundedCornerRadius);
+ shadow_layer_->UpdateNinePatchOcclusion(content_bounds);
}
void Shadow::OnWindowDestroyed(::ui::Window* window) {
« no previous file with comments | « no previous file | cc/layers/nine_patch_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698