| 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 #ifndef UI_GFX_IMAGE_IMAGE_FAMILY_H_ | 5 #ifndef UI_GFX_IMAGE_IMAGE_FAMILY_H_ |
| 6 #define UI_GFX_IMAGE_IMAGE_FAMILY_H_ | 6 #define UI_GFX_IMAGE_IMAGE_FAMILY_H_ |
| 7 | 7 |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // exists, chooses the nearest larger image using GetBest() and scales it to | 140 // exists, chooses the nearest larger image using GetBest() and scales it to |
| 141 // the desired size. If there are no images in the family, returns an empty | 141 // the desired size. If there are no images in the family, returns an empty |
| 142 // image. | 142 // image. |
| 143 gfx::Image CreateExact(int width, int height) const; | 143 gfx::Image CreateExact(int width, int height) const; |
| 144 | 144 |
| 145 // Gets an image of size |size|. If no image of that exact size exists, | 145 // Gets an image of size |size|. If no image of that exact size exists, |
| 146 // chooses the nearest larger image using GetBest() and scales it to the | 146 // chooses the nearest larger image using GetBest() and scales it to the |
| 147 // desired size. If there are no images in the family, returns an empty image. | 147 // desired size. If there are no images in the family, returns an empty image. |
| 148 gfx::Image CreateExact(const gfx::Size& size) const; | 148 gfx::Image CreateExact(const gfx::Size& size) const; |
| 149 | 149 |
| 150 // Calls DisableThreadChecking() on all images. |
| 151 void DisableThreadChecking(); |
| 152 |
| 153 // Calls DetachFromThread() on all images. |
| 154 void DetachFromThread(); |
| 155 |
| 150 private: | 156 private: |
| 151 // Find the closest aspect ratio in the map to |desired_aspect|. | 157 // Find the closest aspect ratio in the map to |desired_aspect|. |
| 152 // Ties are broken by the thinner aspect. | 158 // Ties are broken by the thinner aspect. |
| 153 // |map_| must not be empty. |desired_aspect| must be > 0.0. | 159 // |map_| must not be empty. |desired_aspect| must be > 0.0. |
| 154 float GetClosestAspect(float desired_aspect) const; | 160 float GetClosestAspect(float desired_aspect) const; |
| 155 | 161 |
| 156 // Gets an image with aspect ratio |aspect|, at the best size for |width|. | 162 // Gets an image with aspect ratio |aspect|, at the best size for |width|. |
| 157 // Returns the smallest image of aspect ratio |aspect| with its width bigger | 163 // Returns the smallest image of aspect ratio |aspect| with its width bigger |
| 158 // or equal to |width|. If none exists, returns the largest image of aspect | 164 // or equal to |width|. If none exists, returns the largest image of aspect |
| 159 // ratio |aspect|. Behavior is undefined if there is not at least one image in | 165 // ratio |aspect|. Behavior is undefined if there is not at least one image in |
| 160 // |map_| of aspect ratio |aspect|. | 166 // |map_| of aspect ratio |aspect|. |
| 161 const gfx::Image* GetWithExactAspect(float aspect, int width) const; | 167 const gfx::Image* GetWithExactAspect(float aspect, int width) const; |
| 162 | 168 |
| 163 // Map from (aspect ratio, width) to image. | 169 // Map from (aspect ratio, width) to image. |
| 164 std::map<MapKey, gfx::Image> map_; | 170 std::map<MapKey, gfx::Image> map_; |
| 165 }; | 171 }; |
| 166 | 172 |
| 167 } // namespace gfx | 173 } // namespace gfx |
| 168 | 174 |
| 169 #endif // UI_GFX_IMAGE_IMAGE_FAMILY_H_ | 175 #endif // UI_GFX_IMAGE_IMAGE_FAMILY_H_ |
| OLD | NEW |