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

Side by Side Diff: mash/wm/shadow.cc

Issue 1937493002: cc: 9patch: fix shadow scaling issue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rounded corners Created 4 years, 7 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 | « cc/layers/nine_patch_layer_impl_unittest.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/shadow.h" 5 #include "mash/wm/shadow.h"
6 6
7 #include "mash/wm/property_util.h" 7 #include "mash/wm/property_util.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 gfx::Rect layer_bounds = content_bounds_; 188 gfx::Rect layer_bounds = content_bounds_;
189 layer_bounds.Inset(-interior_inset_, -interior_inset_); 189 layer_bounds.Inset(-interior_inset_, -interior_inset_);
190 layer()->SetBounds(layer_bounds); 190 layer()->SetBounds(layer_bounds);
191 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size())); 191 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size()));
192 192
193 // Update the shadow aperture and border for style. Note that border is in 193 // Update the shadow aperture and border for style. Note that border is in
194 // layer space and it cannot exceed the bounds of the layer. 194 // layer space and it cannot exceed the bounds of the layer.
195 int aperture = GetShadowApertureForStyle(style_); 195 int aperture = GetShadowApertureForStyle(style_);
196 int aperture_x = std::min(aperture, layer_bounds.width() / 2); 196 int aperture_x = std::min(aperture, layer_bounds.width() / 2);
197 int aperture_y = std::min(aperture, layer_bounds.height() / 2); 197 int aperture_y = std::min(aperture, layer_bounds.height() / 2);
198 shadow_layer_->UpdateNinePatchLayerAperture( 198 gfx::Rect aperture_rect(aperture_x, aperture_y,
199 gfx::Rect(aperture_x, aperture_y, 199 image_size_.width() - aperture_x * 2,
200 image_size_.width() - aperture_x * 2, 200 image_size_.height() - aperture_y * 2);
201 image_size_.height() - aperture_y * 2)); 201
202 shadow_layer_->UpdateNinePatchOcclusion( 202 shadow_layer_->UpdateNinePatchLayerAperture(aperture_rect);
203 content_bounds_ + gfx::Vector2d(interior_inset_, interior_inset_)); 203 shadow_layer_->UpdateNinePatchLayerBorder(
204 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
205
206 // The content bounds in the shadow's layer space are offsetted by
207 // |interior_inset_| and also shrinked by the aperture's rectangle to
208 // include rounding corners overdrawing the window's content.
209 gfx::Rect content_bounds(
210 content_bounds_.x() + interior_inset_ + aperture_rect.width(),
211 content_bounds_.y() + interior_inset_ + aperture_rect.height(),
212 content_bounds_.width() - 2 * aperture_rect.width(),
213 content_bounds_.height() - 2 * aperture_rect.height());
214 shadow_layer_->UpdateNinePatchOcclusion(content_bounds);
204 } 215 }
205 216
206 void Shadow::OnWindowDestroyed(mus::Window* window) { 217 void Shadow::OnWindowDestroyed(mus::Window* window) {
207 DCHECK_EQ(window_, window); 218 DCHECK_EQ(window_, window);
208 window_ = nullptr; 219 window_ = nullptr;
209 } 220 }
210 221
211 } // namespace wm 222 } // namespace wm
212 } // namespace mash 223 } // namespace mash
OLDNEW
« no previous file with comments | « cc/layers/nine_patch_layer_impl_unittest.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698