Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: ash/wm/image_grid.h

Issue 10221028: Move DIP translation from ui/aura to ui/compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ASH_WM_IMAGE_GRID_H_ 5 #ifndef ASH_WM_IMAGE_GRID_H_
6 #define ASH_WM_IMAGE_GRID_H_ 6 #define ASH_WM_IMAGE_GRID_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "ash/ash_export.h" 12 #include "ash/ash_export.h"
13 #include "ui/gfx/compositor/layer.h" 13 #include "ui/gfx/compositor/layer.h"
14 #include "ui/gfx/compositor/layer_delegate.h" 14 #include "ui/gfx/compositor/layer_delegate.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 17
18 namespace aura {
19 class Window;
20 } // namespace aura
21
22 namespace gfx { 18 namespace gfx {
23 class Image; 19 class Image;
24 } // namespace gfx 20 } // namespace gfx
25 21
26 namespace ash { 22 namespace ash {
27 namespace internal { 23 namespace internal {
28 24
29 // An ImageGrid is a 3x3 array of ui::Layers, each containing an image. 25 // An ImageGrid is a 3x3 array of ui::Layers, each containing an image.
30 // 26 //
31 // As the grid is resized, its images fill the requested space: 27 // As the grid is resized, its images fill the requested space:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 80
85 // Returns |layer|'s bounds after applying the layer's current transform. 81 // Returns |layer|'s bounds after applying the layer's current transform.
86 gfx::Rect GetTransformedLayerBounds(const ui::Layer& layer); 82 gfx::Rect GetTransformedLayerBounds(const ui::Layer& layer);
87 83
88 private: 84 private:
89 ImageGrid* grid_; // not owned 85 ImageGrid* grid_; // not owned
90 86
91 DISALLOW_COPY_AND_ASSIGN(TestAPI); 87 DISALLOW_COPY_AND_ASSIGN(TestAPI);
92 }; 88 };
93 89
94 explicit ImageGrid(aura::Window* window); 90 ImageGrid();
95 ~ImageGrid(); 91 ~ImageGrid();
96 92
97 ui::Layer* layer() { return layer_.get(); } 93 ui::Layer* layer() { return layer_.get(); }
98 int top_image_height() const { return top_image_height_; } 94 int top_image_height() const { return top_image_height_; }
99 int bottom_image_height() const { return bottom_image_height_; } 95 int bottom_image_height() const { return bottom_image_height_; }
100 int left_image_width() const { return left_image_width_; } 96 int left_image_width() const { return left_image_width_; }
101 int right_image_width() const { return right_image_width_; } 97 int right_image_width() const { return right_image_width_; }
102 98
103 // Visible to allow independent layer animations and for testing. 99 // Visible to allow independent layer animations and for testing.
104 ui::Layer* top_left_layer() const { return top_left_layer_.get(); } 100 ui::Layer* top_left_layer() const { return top_left_layer_.get(); }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Returns true if |layer|'s bounds don't fit within |size|. 156 // Returns true if |layer|'s bounds don't fit within |size|.
161 static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size); 157 static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size);
162 158
163 // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the 159 // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the
164 // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and 160 // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and
165 // |painter_ptr| and removes any existing layer from |layer_|. 161 // |painter_ptr| and removes any existing layer from |layer_|.
166 void SetImage(const gfx::Image* image, 162 void SetImage(const gfx::Image* image,
167 scoped_ptr<ui::Layer>* layer_ptr, 163 scoped_ptr<ui::Layer>* layer_ptr,
168 scoped_ptr<ImagePainter>* painter_ptr); 164 scoped_ptr<ImagePainter>* painter_ptr);
169 165
170 // A possibly-arbitrary window that is drawn at the same DPI
171 // (i.e. on the same monitor) as this grid.
172 // TODO(oshima): move scale factor to gfx/compositor and remove this.
173 aura::Window* window_;
174
175 // Layer that contains all of the image layers. 166 // Layer that contains all of the image layers.
176 scoped_ptr<ui::Layer> layer_; 167 scoped_ptr<ui::Layer> layer_;
177 168
178 // The grid's dimensions. 169 // The grid's dimensions.
179 gfx::Size size_; 170 gfx::Size size_;
180 171
181 // Heights and widths of the images displayed by |top_layer_|, 172 // Heights and widths of the images displayed by |top_layer_|,
182 // |bottom_layer_|, |left_layer_|, and |right_layer_|. 173 // |bottom_layer_|, |left_layer_|, and |right_layer_|.
183 int top_image_height_; 174 int top_image_height_;
184 int bottom_image_height_; 175 int bottom_image_height_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 scoped_ptr<ImagePainter> bottom_painter_; 208 scoped_ptr<ImagePainter> bottom_painter_;
218 scoped_ptr<ImagePainter> bottom_right_painter_; 209 scoped_ptr<ImagePainter> bottom_right_painter_;
219 210
220 DISALLOW_COPY_AND_ASSIGN(ImageGrid); 211 DISALLOW_COPY_AND_ASSIGN(ImageGrid);
221 }; 212 };
222 213
223 } // namespace internal 214 } // namespace internal
224 } // namespace ash 215 } // namespace ash
225 216
226 #endif // ASH_WM_IMAGE_GRID_H_ 217 #endif // ASH_WM_IMAGE_GRID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698