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.h" | 5 #include "ui/gfx/image/image_skia.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 float scale_; | 55 float scale_; |
56 }; | 56 }; |
57 | 57 |
58 ImageSkiaRep ScaleImageSkiaRep(const ImageSkiaRep& rep, float target_scale) { | 58 ImageSkiaRep ScaleImageSkiaRep(const ImageSkiaRep& rep, float target_scale) { |
59 if (rep.is_null() || rep.scale() == target_scale) | 59 if (rep.is_null() || rep.scale() == target_scale) |
60 return rep; | 60 return rep; |
61 | 61 |
62 gfx::Size scaled_size = ToCeiledSize( | 62 gfx::Size scaled_size = |
63 gfx::ScaleSize(rep.pixel_size(), target_scale / rep.scale())); | 63 gfx::ScaleToCeiledSize(rep.pixel_size(), target_scale / rep.scale()); |
64 return ImageSkiaRep(skia::ImageOperations::Resize( | 64 return ImageSkiaRep(skia::ImageOperations::Resize( |
65 rep.sk_bitmap(), | 65 rep.sk_bitmap(), |
66 skia::ImageOperations::RESIZE_LANCZOS3, | 66 skia::ImageOperations::RESIZE_LANCZOS3, |
67 scaled_size.width(), | 67 scaled_size.width(), |
68 scaled_size.height()), target_scale); | 68 scaled_size.height()), target_scale); |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 // A helper class such that ImageSkia can be cheaply copied. ImageSkia holds a | 73 // A helper class such that ImageSkia can be cheaply copied. ImageSkia holds a |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 bool ImageSkia::CanModify() const { | 492 bool ImageSkia::CanModify() const { |
493 return !storage_.get() || storage_->CanModify(); | 493 return !storage_.get() || storage_->CanModify(); |
494 } | 494 } |
495 | 495 |
496 void ImageSkia::DetachStorageFromThread() { | 496 void ImageSkia::DetachStorageFromThread() { |
497 if (storage_.get()) | 497 if (storage_.get()) |
498 storage_->DetachFromThread(); | 498 storage_->DetachFromThread(); |
499 } | 499 } |
500 | 500 |
501 } // namespace gfx | 501 } // namespace gfx |
OLD | NEW |