| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 virtual ~ExtractSubsetImageSource() { | 285 virtual ~ExtractSubsetImageSource() { |
| 286 } | 286 } |
| 287 | 287 |
| 288 // gfx::ImageSkiaSource overrides: | 288 // gfx::ImageSkiaSource overrides: |
| 289 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 289 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| 290 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); | 290 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); |
| 291 gfx::RectF scaled_subset_bounds = subset_bounds_; | 291 gfx::RectF scaled_subset_bounds = subset_bounds_; |
| 292 scaled_subset_bounds.Scale( | 292 scaled_subset_bounds.Scale( |
| 293 ui::GetScaleFactorScale(image_rep.scale_factor())); | 293 ui::GetScaleFactorScale(image_rep.scale_factor())); |
| 294 SkIRect subset_bounds_in_pixel = RectToSkIRect( | 294 SkIRect subset_bounds_in_pixel = RectToSkIRect( |
| 295 ToEnclosingRect(scaled_subset_bounds)); | 295 ToFlooredRectDeprecated(scaled_subset_bounds)); |
| 296 SkBitmap dst; | 296 SkBitmap dst; |
| 297 bool success = image_rep.sk_bitmap().extractSubset(&dst, | 297 bool success = image_rep.sk_bitmap().extractSubset(&dst, |
| 298 subset_bounds_in_pixel); | 298 subset_bounds_in_pixel); |
| 299 DCHECK(success); | 299 DCHECK(success); |
| 300 return gfx::ImageSkiaRep(dst, image_rep.scale_factor()); | 300 return gfx::ImageSkiaRep(dst, image_rep.scale_factor()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 private: | 303 private: |
| 304 const gfx::ImageSkia image_; | 304 const gfx::ImageSkia image_; |
| 305 const gfx::Rect subset_bounds_; | 305 const gfx::Rect subset_bounds_; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 const ImageSkia& source, | 456 const ImageSkia& source, |
| 457 const ShadowValues& shadows) { | 457 const ShadowValues& shadows) { |
| 458 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); | 458 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); |
| 459 gfx::Size shadow_image_size = source.size(); | 459 gfx::Size shadow_image_size = source.size(); |
| 460 shadow_image_size.Enlarge(shadow_padding.width(), | 460 shadow_image_size.Enlarge(shadow_padding.width(), |
| 461 shadow_padding.height()); | 461 shadow_padding.height()); |
| 462 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); | 462 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace gfx | 465 } // namespace gfx |
| OLD | NEW |