| OLD | NEW |
| 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/gfx/image/image_skia_operations.h" | 5 #include "ui/gfx/image/image_skia_operations.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "skia/ext/image_operations.h" | 9 #include "skia/ext/image_operations.h" |
| 10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 : image_(image), | 279 : image_(image), |
| 280 subset_bounds_(subset_bounds) { | 280 subset_bounds_(subset_bounds) { |
| 281 } | 281 } |
| 282 | 282 |
| 283 virtual ~ExtractSubsetImageSource() { | 283 virtual ~ExtractSubsetImageSource() { |
| 284 } | 284 } |
| 285 | 285 |
| 286 // gfx::ImageSkiaSource overrides: | 286 // gfx::ImageSkiaSource overrides: |
| 287 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 287 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| 288 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); | 288 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); |
| 289 SkIRect subset_bounds_in_pixel = RectToSkIRect(subset_bounds_.Scale( | 289 SkIRect subset_bounds_in_pixel = RectToSkIRect( |
| 290 ui::GetScaleFactorScale(image_rep.scale_factor()))); | 290 subset_bounds_.ScaleUnsafe( |
| 291 ui::GetScaleFactorScale(image_rep.scale_factor()))); |
| 291 SkBitmap dst; | 292 SkBitmap dst; |
| 292 bool success = image_rep.sk_bitmap().extractSubset(&dst, | 293 bool success = image_rep.sk_bitmap().extractSubset(&dst, |
| 293 subset_bounds_in_pixel); | 294 subset_bounds_in_pixel); |
| 294 DCHECK(success); | 295 DCHECK(success); |
| 295 return gfx::ImageSkiaRep(dst, image_rep.scale_factor()); | 296 return gfx::ImageSkiaRep(dst, image_rep.scale_factor()); |
| 296 } | 297 } |
| 297 | 298 |
| 298 private: | 299 private: |
| 299 const gfx::ImageSkia image_; | 300 const gfx::ImageSkia image_; |
| 300 const gfx::Rect subset_bounds_; | 301 const gfx::Rect subset_bounds_; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 const ImageSkia& source, | 450 const ImageSkia& source, |
| 450 const ShadowValues& shadows) { | 451 const ShadowValues& shadows) { |
| 451 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); | 452 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); |
| 452 gfx::Size shadow_image_size = source.size(); | 453 gfx::Size shadow_image_size = source.size(); |
| 453 shadow_image_size.Enlarge(shadow_padding.width(), | 454 shadow_image_size.Enlarge(shadow_padding.width(), |
| 454 shadow_padding.height()); | 455 shadow_padding.height()); |
| 455 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); | 456 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); |
| 456 } | 457 } |
| 457 | 458 |
| 458 } // namespace gfx | 459 } // namespace gfx |
| OLD | NEW |