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: 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: Address nits from danakj. 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
« no previous file with comments | « ui/wm/core/shadow.h ('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 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 // Update nine-patch layer with new bitmap.
danakj 2014/09/18 21:35:29 Thanks, this comment now just says the function na
hshi1 2014/09/18 21:37:12 Done.
176 int shadow_aperture = GetShadowApertureForStyle(style_); 176 shadow_layer_->UpdateNinePatchLayerBitmap(image.AsBitmap());
177 gfx::Rect aperture(shadow_aperture,
178 shadow_aperture,
179 image.Width() - shadow_aperture * 2,
180 image.Height() - shadow_aperture * 2);
181 177
182 // Update nine-patch layer with new bitmap and aperture. 178 // Update shadow image size.
danakj 2014/09/18 21:35:29 Similar comment about this comment, wdyt?
hshi1 2014/09/18 21:37:12 Done.
183 shadow_layer_->UpdateNinePatchLayerBitmap(image.AsBitmap(), aperture); 179 image_size_ = image.Size();
184 180
185 // Update interior inset for style. 181 // Update interior inset for style.
hshi1 2014/09/18 21:37:12 Lemme remove this line too (the function name is a
186 interior_inset_ = GetInteriorInsetForStyle(style_); 182 interior_inset_ = GetInteriorInsetForStyle(style_);
187 183
188 // Image sizes may have changed. 184 // Image sizes may have changed.
189 UpdateLayerBounds(); 185 UpdateLayerBounds();
190 } 186 }
191 187
192 void Shadow::UpdateLayerBounds() { 188 void Shadow::UpdateLayerBounds() {
193 // Update bounds based on content bounds and interior inset. 189 // Update bounds based on content bounds and interior inset.
194 gfx::Rect layer_bounds = content_bounds_; 190 gfx::Rect layer_bounds = content_bounds_;
195 layer_bounds.Inset(-interior_inset_, -interior_inset_); 191 layer_bounds.Inset(-interior_inset_, -interior_inset_);
196 layer()->SetBounds(layer_bounds); 192 layer()->SetBounds(layer_bounds);
197 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size())); 193 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size()));
198 194
199 // Calculate shadow border for style. Note that border is in layer space 195 // Update the shadow aperture and border for style. Note that border is in
200 // and it cannot exceed the bounds of the layer. 196 // layer space and it cannot exceed the bounds of the layer.
201 int shadow_aperture = GetShadowApertureForStyle(style_); 197 int aperture = GetShadowApertureForStyle(style_);
202 gfx::Rect border(shadow_aperture, shadow_aperture, 198 int aperture_x = std::min(aperture, layer_bounds.width() / 2);
203 shadow_aperture * 2, shadow_aperture * 2); 199 int aperture_y = std::min(aperture, layer_bounds.height() / 2);
204 if (layer_bounds.width() < border.width() || 200 shadow_layer_->UpdateNinePatchLayerAperture(
205 layer_bounds.height() < border.height()) { 201 gfx::Rect(aperture_x, aperture_y,
206 shadow_layer_->SetVisible(false); 202 image_size_.width() - aperture_x * 2,
207 } else { 203 image_size_.height() - aperture_y * 2));
208 shadow_layer_->SetVisible(true); 204 shadow_layer_->UpdateNinePatchLayerBorder(
209 shadow_layer_->UpdateNinePatchLayerBorder(border); 205 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
210 }
211 } 206 }
212 207
213 } // namespace wm 208 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/shadow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698