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

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

Issue 1002393002: Change ui::wm::Shadow to pass ImageSkia instead of SkBitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle device scale factor change. Created 5 years, 9 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
« ui/compositor/layer.cc ('K') | « 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 image = res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE); 155 image = res.GetImageNamed(IDR_AURA_SHADOW_INACTIVE);
156 break; 156 break;
157 case STYLE_SMALL: 157 case STYLE_SMALL:
158 image = res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL); 158 image = res.GetImageNamed(IDR_WINDOW_BUBBLE_SHADOW_SMALL);
159 break; 159 break;
160 default: 160 default:
161 NOTREACHED() << "Unhandled style " << style_; 161 NOTREACHED() << "Unhandled style " << style_;
162 break; 162 break;
163 } 163 }
164 164
165 shadow_layer_->UpdateNinePatchLayerBitmap(image.AsBitmap()); 165 shadow_layer_->UpdateNinePatchLayerImage(image.AsImageSkia());
166 image_size_ = image.Size(); 166 image_size_ = image.Size();
167 interior_inset_ = GetInteriorInsetForStyle(style_); 167 interior_inset_ = GetInteriorInsetForStyle(style_);
168 168
169 // Image sizes may have changed. 169 // Image sizes may have changed.
170 UpdateLayerBounds(); 170 UpdateLayerBounds();
171 } 171 }
172 172
173 void Shadow::UpdateLayerBounds() { 173 void Shadow::UpdateLayerBounds() {
174 // Update bounds based on content bounds and interior inset. 174 // Update bounds based on content bounds and interior inset.
175 gfx::Rect layer_bounds = content_bounds_; 175 gfx::Rect layer_bounds = content_bounds_;
176 layer_bounds.Inset(-interior_inset_, -interior_inset_); 176 layer_bounds.Inset(-interior_inset_, -interior_inset_);
177 layer()->SetBounds(layer_bounds); 177 layer()->SetBounds(layer_bounds);
178 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size())); 178 shadow_layer_->SetBounds(gfx::Rect(layer_bounds.size()));
179 179
180 // Update the shadow aperture and border for style. Note that border is in 180 // 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. 181 // layer space and it cannot exceed the bounds of the layer.
182 int aperture = GetShadowApertureForStyle(style_); 182 int aperture = GetShadowApertureForStyle(style_);
183 int aperture_x = std::min(aperture, layer_bounds.width() / 2); 183 int aperture_x = std::min(aperture, layer_bounds.width() / 2);
184 int aperture_y = std::min(aperture, layer_bounds.height() / 2); 184 int aperture_y = std::min(aperture, layer_bounds.height() / 2);
185 shadow_layer_->UpdateNinePatchLayerAperture( 185 shadow_layer_->UpdateNinePatchLayerAperture(
186 gfx::Rect(aperture_x, aperture_y, 186 gfx::Rect(aperture_x, aperture_y,
187 image_size_.width() - aperture_x * 2, 187 image_size_.width() - aperture_x * 2,
188 image_size_.height() - aperture_y * 2)); 188 image_size_.height() - aperture_y * 2));
189 shadow_layer_->UpdateNinePatchLayerBorder( 189 shadow_layer_->UpdateNinePatchLayerBorder(
190 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2)); 190 gfx::Rect(aperture_x, aperture_y, aperture_x * 2, aperture_y * 2));
191 } 191 }
192 192
193 } // namespace wm 193 } // namespace wm
OLDNEW
« ui/compositor/layer.cc ('K') | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698