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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 public: | 54 public: |
55 ImageSkiaStorage(ImageSkiaSource* source, const gfx::Size& size) | 55 ImageSkiaStorage(ImageSkiaSource* source, const gfx::Size& size) |
56 : source_(source), | 56 : source_(source), |
57 size_(size), | 57 size_(size), |
58 read_only_(false) { | 58 read_only_(false) { |
59 } | 59 } |
60 | 60 |
61 ImageSkiaStorage(ImageSkiaSource* source, ui::ScaleFactor scale_factor) | 61 ImageSkiaStorage(ImageSkiaSource* source, ui::ScaleFactor scale_factor) |
62 : source_(source), | 62 : source_(source), |
63 read_only_(false) { | 63 read_only_(false) { |
64 const ImageSkiaRep& image = *FindRepresentation(scale_factor, true); | 64 ImageSkia::ImageSkiaReps::iterator it = |
65 if (image.is_null()) | 65 FindRepresentation(scale_factor, true); |
| 66 // TODO(oshima): This is necessary as there are scale indepdent |
| 67 // resources loaded as 100P. Fix them and remove this. |
| 68 if (scale_factor != ui::SCALE_FACTOR_100P && |
| 69 (it == image_reps_.end() || it->is_null())) |
| 70 it = FindRepresentation(ui::SCALE_FACTOR_100P, true); |
| 71 |
| 72 if (it == image_reps_.end() || it->is_null()) |
66 source_.reset(); | 73 source_.reset(); |
67 else | 74 else |
68 size_.SetSize(image.GetWidth(), image.GetHeight()); | 75 size_.SetSize(it->GetWidth(), it->GetHeight()); |
69 } | 76 } |
70 | 77 |
71 bool has_source() const { return source_.get() != NULL; } | 78 bool has_source() const { return source_.get() != NULL; } |
72 | 79 |
73 std::vector<gfx::ImageSkiaRep>& image_reps() { return image_reps_; } | 80 std::vector<gfx::ImageSkiaRep>& image_reps() { return image_reps_; } |
74 | 81 |
75 const gfx::Size& size() const { return size_; } | 82 const gfx::Size& size() const { return size_; } |
76 | 83 |
77 bool read_only() const { return read_only_; } | 84 bool read_only() const { return read_only_; } |
78 | 85 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 bool ImageSkia::CanModify() const { | 408 bool ImageSkia::CanModify() const { |
402 return !storage_ || storage_->CanModify(); | 409 return !storage_ || storage_->CanModify(); |
403 } | 410 } |
404 | 411 |
405 void ImageSkia::DetachStorageFromThread() { | 412 void ImageSkia::DetachStorageFromThread() { |
406 if (storage_) | 413 if (storage_) |
407 storage_->DetachFromThread(); | 414 storage_->DetachFromThread(); |
408 } | 415 } |
409 | 416 |
410 } // namespace gfx | 417 } // namespace gfx |
OLD | NEW |