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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 bool operator()(const ImageSkiaRep& rep) const { | 50 bool operator()(const ImageSkiaRep& rep) const { |
51 return rep.scale() == scale_; | 51 return rep.scale() == scale_; |
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 DCHECK_NE(rep.scale(), target_scale); | 59 if (rep.is_null() || rep.scale() == target_scale) |
60 if (rep.is_null()) | |
61 return rep; | 60 return rep; |
62 | 61 |
63 gfx::Size scaled_size = ToCeiledSize( | 62 gfx::Size scaled_size = ToCeiledSize( |
64 gfx::ScaleSize(rep.pixel_size(), target_scale / rep.scale())); | 63 gfx::ScaleSize(rep.pixel_size(), target_scale / rep.scale())); |
65 return ImageSkiaRep(skia::ImageOperations::Resize( | 64 return ImageSkiaRep(skia::ImageOperations::Resize( |
66 rep.sk_bitmap(), | 65 rep.sk_bitmap(), |
67 skia::ImageOperations::RESIZE_LANCZOS3, | 66 skia::ImageOperations::RESIZE_LANCZOS3, |
68 scaled_size.width(), | 67 scaled_size.width(), |
69 scaled_size.height()), target_scale); | 68 scaled_size.height()), target_scale); |
70 } | 69 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 bool ImageSkia::CanModify() const { | 492 bool ImageSkia::CanModify() const { |
494 return !storage_.get() || storage_->CanModify(); | 493 return !storage_.get() || storage_->CanModify(); |
495 } | 494 } |
496 | 495 |
497 void ImageSkia::DetachStorageFromThread() { | 496 void ImageSkia::DetachStorageFromThread() { |
498 if (storage_.get()) | 497 if (storage_.get()) |
499 storage_->DetachFromThread(); | 498 storage_->DetachFromThread(); |
500 } | 499 } |
501 | 500 |
502 } // namespace gfx | 501 } // namespace gfx |
OLD | NEW |