OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_family.h" | 5 #include "ui/gfx/image/image_family.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ui/gfx/image/image.h" | 9 #include "ui/gfx/image/image.h" |
10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 ImageFamily::const_iterator::const_iterator() {} | 15 ImageFamily::const_iterator::const_iterator() {} |
16 | 16 |
17 ImageFamily::const_iterator::const_iterator(const const_iterator& other) | 17 ImageFamily::const_iterator::const_iterator(const const_iterator& other) |
18 : map_iterator_(other.map_iterator_) {} | 18 : map_iterator_(other.map_iterator_) {} |
19 | 19 |
20 ImageFamily::const_iterator::const_iterator( | 20 ImageFamily::const_iterator::const_iterator( |
21 const std::map<MapKey, gfx::Image>::const_iterator& other) | 21 const std::map<MapKey, gfx::Image>::const_iterator& other) |
22 : map_iterator_(other) {} | 22 : map_iterator_(other) {} |
23 | 23 |
| 24 ImageFamily::const_iterator::~const_iterator() {} |
| 25 |
24 ImageFamily::ImageFamily() {} | 26 ImageFamily::ImageFamily() {} |
25 ImageFamily::~ImageFamily() {} | 27 ImageFamily::~ImageFamily() {} |
26 | 28 |
27 void ImageFamily::Add(const gfx::Image& image) { | 29 void ImageFamily::Add(const gfx::Image& image) { |
28 gfx::Size size = image.Size(); | 30 gfx::Size size = image.Size(); |
29 if (size.IsEmpty()) { | 31 if (size.IsEmpty()) { |
30 map_[MapKey(1.0f, 0)] = image; | 32 map_[MapKey(1.0f, 0)] = image; |
31 } else { | 33 } else { |
32 float aspect = static_cast<float>(size.width()) / size.height(); | 34 float aspect = static_cast<float>(size.width()) / size.height(); |
33 DCHECK_GT(aspect, 0.0f); | 35 DCHECK_GT(aspect, 0.0f); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 DCHECK(greater_or_equal != map_.begin()); | 121 DCHECK(greater_or_equal != map_.begin()); |
120 std::map<MapKey, gfx::Image>::const_iterator less_than = greater_or_equal; | 122 std::map<MapKey, gfx::Image>::const_iterator less_than = greater_or_equal; |
121 --less_than; | 123 --less_than; |
122 // This must be true because there must be at least one image with |aspect|. | 124 // This must be true because there must be at least one image with |aspect|. |
123 DCHECK_EQ(less_than->first.aspect(), aspect); | 125 DCHECK_EQ(less_than->first.aspect(), aspect); |
124 // We have found the largest image smaller than desired. | 126 // We have found the largest image smaller than desired. |
125 return &less_than->second; | 127 return &less_than->second; |
126 } | 128 } |
127 | 129 |
128 } // namespace gfx | 130 } // namespace gfx |
OLD | NEW |