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

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

Issue 581273002: Shadows: crop corner tiles instead of hiding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits from sky Created 6 years, 3 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
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 image = res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE); 165 image = res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE);
166 break; 166 break;
167 case STYLE_SMALL: 167 case STYLE_SMALL:
168 image = res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL); 168 image = res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL);
169 break; 169 break;
170 default: 170 default:
171 NOTREACHED() << "Unhandled style " << style_; 171 NOTREACHED() << "Unhandled style " << style_;
172 break; 172 break;
173 } 173 }
174 174
175 // Calculate shadow aperture for style. 175 shadow_layer_->UpdateNinePatchLayerBitmap(image.AsBitmap());
176 int shadow_aperture = GetShadowApertureForStyle(style_); 176 image_size_ = image.Size();
177 gfx::Rect aperture(shadow_aperture,
178 shadow_aperture,
179 image.Width() - shadow_aperture * 2,
180 image.Height() - shadow_aperture * 2);
181
182 // Update nine-patch layer with new bitmap and aperture.
183 shadow_layer_->UpdateNinePatchLayerBitmap(image.AsBitmap(), aperture);
184
185 // Update interior inset for style.
186 interior_inset_ = GetInteriorInsetForStyle(style_); 177 interior_inset_ = GetInteriorInsetForStyle(style_);
187 178
188 // Image sizes may have changed. 179 // Image sizes may have changed.
189 UpdateLayerBounds(); 180 UpdateLayerBounds();
190 } 181 }
191 182
192 void Shadow::UpdateLayerBounds() { 183 void Shadow::UpdateLayerBounds() {
193 // Update bounds based on content bounds and interior inset. 184 // Update bounds based on content bounds and interior inset.
194 gfx::Rect layer_bounds = content_bounds_; 185 gfx::Rect layer_bounds = content_bounds_;
195 layer_bounds.Inset(-interior_inset_, -interior_inset_); 186 layer_bounds.Inset(-interior_inset_, -interior_inset_);
196 layer()->SetBounds(layer_bounds); 187 layer()->SetBounds(layer_bounds);
197 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size())); 188 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size()));
198 189
199 // Calculate shadow border for style. Note that border is in layer space 190 // Update the shadow aperture and border for style. Note that border is in
200 // and it cannot exceed the bounds of the layer. 191 // layer space and it cannot exceed the bounds of the layer.
201 int shadow_aperture = GetShadowApertureForStyle(style_); 192 int aperture = GetShadowApertureForStyle(style_);
202 gfx::Rect border(shadow_aperture, shadow_aperture, 193 int aperture_x = std::min(aperture, layer_bounds.width() / 2);
203 shadow_aperture * 2, shadow_aperture * 2); 194 int aperture_y = std::min(aperture, layer_bounds.height() / 2);
204 if (layer_bounds.width() < border.width() || 195 shadow_layer_->UpdateNinePatchLayerAperture(
205 layer_bounds.height() < border.height()) { 196 gfx::Rect(aperture_x, aperture_y,
206 shadow_layer_->SetVisible(false); 197 image_size_.width() - aperture_x * 2,
207 } else { 198 image_size_.height() - aperture_y * 2));
208 shadow_layer_->SetVisible(true); 199 shadow_layer_->UpdateNinePatchLayerBorder(
209 shadow_layer_->UpdateNinePatchLayerBorder(border); 200 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
210 }
211 } 201 }
212 202
213 } // namespace wm 203 } // namespace wm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698