| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // ImageSkiaSource which uses SkBitmap::extractSubset to generate image reps | 274 // ImageSkiaSource which uses SkBitmap::extractSubset to generate image reps |
| 275 // for the target image. | 275 // for the target image. |
| 276 class ExtractSubsetImageSource: public gfx::ImageSkiaSource { | 276 class ExtractSubsetImageSource: public gfx::ImageSkiaSource { |
| 277 public: | 277 public: |
| 278 ExtractSubsetImageSource(const gfx::ImageSkia& image, | 278 ExtractSubsetImageSource(const gfx::ImageSkia& image, |
| 279 const gfx::Rect& subset_bounds) | 279 const gfx::Rect& subset_bounds) |
| 280 : image_(image), | 280 : image_(image), |
| 281 subset_bounds_(subset_bounds) { | 281 subset_bounds_(subset_bounds) { |
| 282 } | 282 } |
| 283 | 283 |
| 284 ~ExtractSubsetImageSource() { | 284 virtual ~ExtractSubsetImageSource() { |
| 285 } | 285 } |
| 286 | 286 |
| 287 // gfx::ImageSkiaSource overrides: | 287 // gfx::ImageSkiaSource overrides: |
| 288 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 288 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| 289 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); | 289 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); |
| 290 SkIRect subset_bounds_in_pixel = RectToSkIRect(subset_bounds_.Scale( | 290 SkIRect subset_bounds_in_pixel = RectToSkIRect(subset_bounds_.Scale( |
| 291 ui::GetScaleFactorScale(image_rep.scale_factor()))); | 291 ui::GetScaleFactorScale(image_rep.scale_factor()))); |
| 292 SkBitmap dst; | 292 SkBitmap dst; |
| 293 bool success = image_rep.sk_bitmap().extractSubset(&dst, | 293 bool success = image_rep.sk_bitmap().extractSubset(&dst, |
| 294 subset_bounds_in_pixel); | 294 subset_bounds_in_pixel); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 const ImageSkia& source, | 450 const ImageSkia& source, |
| 451 const ShadowValues& shadows) { | 451 const ShadowValues& shadows) { |
| 452 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); | 452 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); |
| 453 gfx::Size shadow_image_size = source.size(); | 453 gfx::Size shadow_image_size = source.size(); |
| 454 shadow_image_size.Enlarge(shadow_padding.width(), | 454 shadow_image_size.Enlarge(shadow_padding.width(), |
| 455 shadow_padding.height()); | 455 shadow_padding.height()); |
| 456 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); | 456 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace gfx | 459 } // namespace gfx |
| OLD | NEW |