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 #ifndef UI_WM_CORE_IMAGE_GRID_H_ | 5 #ifndef UI_WM_CORE_IMAGE_GRID_H_ |
6 #define UI_WM_CORE_IMAGE_GRID_H_ | 6 #define UI_WM_CORE_IMAGE_GRID_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "ui/compositor/layer.h" | 11 #include "ui/compositor/layer.h" |
11 #include "ui/compositor/layer_delegate.h" | 12 #include "ui/compositor/layer_delegate.h" |
12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
14 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
15 #include "ui/wm/wm_export.h" | 16 #include "ui/wm/wm_export.h" |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 class Image; | 19 class Image; |
19 } // namespace gfx | 20 } // namespace gfx |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 NONE, | 158 NONE, |
158 }; | 159 }; |
159 | 160 |
160 // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the | 161 // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the |
161 // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and | 162 // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and |
162 // |painter_ptr| and removes any existing layer from |layer_|. | 163 // |painter_ptr| and removes any existing layer from |layer_|. |
163 // If |type| is either HORIZONTAL or VERTICAL, it may resize the image to | 164 // If |type| is either HORIZONTAL or VERTICAL, it may resize the image to |
164 // guarantee that it has minimum size in order for scaling work properly | 165 // guarantee that it has minimum size in order for scaling work properly |
165 // with fractional device scale factors. crbug.com/376519. | 166 // with fractional device scale factors. crbug.com/376519. |
166 void SetImage(const gfx::Image* image, | 167 void SetImage(const gfx::Image* image, |
167 scoped_ptr<ui::Layer>* layer_ptr, | 168 std::unique_ptr<ui::Layer>* layer_ptr, |
168 scoped_ptr<ImagePainter>* painter_ptr, | 169 std::unique_ptr<ImagePainter>* painter_ptr, |
169 ImageType type); | 170 ImageType type); |
170 | 171 |
171 // Layer that contains all of the image layers. | 172 // Layer that contains all of the image layers. |
172 scoped_ptr<ui::Layer> layer_; | 173 std::unique_ptr<ui::Layer> layer_; |
173 | 174 |
174 // The grid's dimensions. | 175 // The grid's dimensions. |
175 gfx::Size size_; | 176 gfx::Size size_; |
176 | 177 |
177 // Heights and widths of the images displayed by |top_layer_|, | 178 // Heights and widths of the images displayed by |top_layer_|, |
178 // |bottom_layer_|, |left_layer_|, and |right_layer_|. | 179 // |bottom_layer_|, |left_layer_|, and |right_layer_|. |
179 int top_image_height_; | 180 int top_image_height_; |
180 int bottom_image_height_; | 181 int bottom_image_height_; |
181 int left_image_width_; | 182 int left_image_width_; |
182 int right_image_width_; | 183 int right_image_width_; |
183 | 184 |
184 // Heights of the tallest images in the top and bottom rows and the widest | 185 // Heights of the tallest images in the top and bottom rows and the widest |
185 // images in the left and right columns. Note that we may have less actual | 186 // images in the left and right columns. Note that we may have less actual |
186 // space than this available if the images are large and |size_| is small. | 187 // space than this available if the images are large and |size_| is small. |
187 int base_top_row_height_; | 188 int base_top_row_height_; |
188 int base_bottom_row_height_; | 189 int base_bottom_row_height_; |
189 int base_left_column_width_; | 190 int base_left_column_width_; |
190 int base_right_column_width_; | 191 int base_right_column_width_; |
191 | 192 |
192 // Layers used to display the various images. Children of |layer_|. | 193 // Layers used to display the various images. Children of |layer_|. |
193 // Positions for which no images were supplied are NULL. | 194 // Positions for which no images were supplied are NULL. |
194 scoped_ptr<ui::Layer> top_left_layer_; | 195 std::unique_ptr<ui::Layer> top_left_layer_; |
195 scoped_ptr<ui::Layer> top_layer_; | 196 std::unique_ptr<ui::Layer> top_layer_; |
196 scoped_ptr<ui::Layer> top_right_layer_; | 197 std::unique_ptr<ui::Layer> top_right_layer_; |
197 scoped_ptr<ui::Layer> left_layer_; | 198 std::unique_ptr<ui::Layer> left_layer_; |
198 scoped_ptr<ui::Layer> center_layer_; | 199 std::unique_ptr<ui::Layer> center_layer_; |
199 scoped_ptr<ui::Layer> right_layer_; | 200 std::unique_ptr<ui::Layer> right_layer_; |
200 scoped_ptr<ui::Layer> bottom_left_layer_; | 201 std::unique_ptr<ui::Layer> bottom_left_layer_; |
201 scoped_ptr<ui::Layer> bottom_layer_; | 202 std::unique_ptr<ui::Layer> bottom_layer_; |
202 scoped_ptr<ui::Layer> bottom_right_layer_; | 203 std::unique_ptr<ui::Layer> bottom_right_layer_; |
203 | 204 |
204 // Delegates responsible for painting the above layers. | 205 // Delegates responsible for painting the above layers. |
205 // Positions for which no images were supplied are NULL. | 206 // Positions for which no images were supplied are NULL. |
206 scoped_ptr<ImagePainter> top_left_painter_; | 207 std::unique_ptr<ImagePainter> top_left_painter_; |
207 scoped_ptr<ImagePainter> top_painter_; | 208 std::unique_ptr<ImagePainter> top_painter_; |
208 scoped_ptr<ImagePainter> top_right_painter_; | 209 std::unique_ptr<ImagePainter> top_right_painter_; |
209 scoped_ptr<ImagePainter> left_painter_; | 210 std::unique_ptr<ImagePainter> left_painter_; |
210 scoped_ptr<ImagePainter> center_painter_; | 211 std::unique_ptr<ImagePainter> center_painter_; |
211 scoped_ptr<ImagePainter> right_painter_; | 212 std::unique_ptr<ImagePainter> right_painter_; |
212 scoped_ptr<ImagePainter> bottom_left_painter_; | 213 std::unique_ptr<ImagePainter> bottom_left_painter_; |
213 scoped_ptr<ImagePainter> bottom_painter_; | 214 std::unique_ptr<ImagePainter> bottom_painter_; |
214 scoped_ptr<ImagePainter> bottom_right_painter_; | 215 std::unique_ptr<ImagePainter> bottom_right_painter_; |
215 | 216 |
216 DISALLOW_COPY_AND_ASSIGN(ImageGrid); | 217 DISALLOW_COPY_AND_ASSIGN(ImageGrid); |
217 }; | 218 }; |
218 | 219 |
219 } // namespace wm | 220 } // namespace wm |
220 | 221 |
221 #endif // UI_WM_CORE_IMAGE_GRID_H_ | 222 #endif // UI_WM_CORE_IMAGE_GRID_H_ |
OLD | NEW |