OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_AURA_SHELL_IMAGE_GRID_H_ | 5 #ifndef UI_AURA_SHELL_IMAGE_GRID_H_ |
6 #define UI_AURA_SHELL_IMAGE_GRID_H_ | 6 #define UI_AURA_SHELL_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" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ui::Layer* center_layer() const { return grid_->center_layer_.get(); } | 71 ui::Layer* center_layer() const { return grid_->center_layer_.get(); } |
72 ui::Layer* right_layer() const { return grid_->right_layer_.get(); } | 72 ui::Layer* right_layer() const { return grid_->right_layer_.get(); } |
73 ui::Layer* bottom_left_layer() const { | 73 ui::Layer* bottom_left_layer() const { |
74 return grid_->bottom_left_layer_.get(); | 74 return grid_->bottom_left_layer_.get(); |
75 } | 75 } |
76 ui::Layer* bottom_layer() const { return grid_->bottom_layer_.get(); } | 76 ui::Layer* bottom_layer() const { return grid_->bottom_layer_.get(); } |
77 ui::Layer* bottom_right_layer() const { | 77 ui::Layer* bottom_right_layer() const { |
78 return grid_->bottom_right_layer_.get(); | 78 return grid_->bottom_right_layer_.get(); |
79 } | 79 } |
80 | 80 |
| 81 gfx::Rect top_left_clip_rect() const { |
| 82 return grid_->top_left_painter_->clip_rect_; |
| 83 } |
| 84 gfx::Rect top_right_clip_rect() const { |
| 85 return grid_->top_right_painter_->clip_rect_; |
| 86 } |
| 87 gfx::Rect bottom_left_clip_rect() const { |
| 88 return grid_->bottom_left_painter_->clip_rect_; |
| 89 } |
| 90 gfx::Rect bottom_right_clip_rect() const { |
| 91 return grid_->bottom_right_painter_->clip_rect_; |
| 92 } |
| 93 |
81 // Returns |layer|'s bounds after applying the layer's current transform. | 94 // Returns |layer|'s bounds after applying the layer's current transform. |
82 gfx::Rect GetTransformedLayerBounds(const ui::Layer& layer); | 95 gfx::Rect GetTransformedLayerBounds(const ui::Layer& layer); |
83 | 96 |
84 private: | 97 private: |
85 ImageGrid* grid_; // not owned | 98 ImageGrid* grid_; // not owned |
86 | 99 |
87 DISALLOW_COPY_AND_ASSIGN(TestAPI); | 100 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
88 }; | 101 }; |
89 | 102 |
90 ImageGrid(); | 103 ImageGrid(); |
(...skipping 19 matching lines...) Expand all Loading... |
110 | 123 |
111 void SetSize(const gfx::Size& size); | 124 void SetSize(const gfx::Size& size); |
112 | 125 |
113 private: | 126 private: |
114 // Delegate responsible for painting a specific image on a layer. | 127 // Delegate responsible for painting a specific image on a layer. |
115 class ImagePainter : public ui::LayerDelegate { | 128 class ImagePainter : public ui::LayerDelegate { |
116 public: | 129 public: |
117 ImagePainter(const gfx::Image* image) : image_(image) {} | 130 ImagePainter(const gfx::Image* image) : image_(image) {} |
118 virtual ~ImagePainter() {} | 131 virtual ~ImagePainter() {} |
119 | 132 |
| 133 // Clips |layer| to |clip_rect|. Triggers a repaint if the clipping |
| 134 // rectangle has changed. An empty rectangle disables clipping. |
| 135 void SetClipRect(const gfx::Rect& clip_rect, ui::Layer* layer); |
| 136 |
120 // ui::LayerDelegate implementation: | 137 // ui::LayerDelegate implementation: |
121 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 138 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
122 | 139 |
123 private: | 140 private: |
| 141 friend class TestAPI; |
| 142 |
124 const gfx::Image* image_; // not owned | 143 const gfx::Image* image_; // not owned |
125 | 144 |
| 145 gfx::Rect clip_rect_; |
| 146 |
126 DISALLOW_COPY_AND_ASSIGN(ImagePainter); | 147 DISALLOW_COPY_AND_ASSIGN(ImagePainter); |
127 }; | 148 }; |
128 | 149 |
129 // Returns the dimensions of |image| if non-NULL or gfx::Size(0, 0) otherwise. | 150 // Returns the dimensions of |image| if non-NULL or gfx::Size(0, 0) otherwise. |
130 static gfx::Size GetImageSize(const gfx::Image* image); | 151 static gfx::Size GetImageSize(const gfx::Image* image); |
131 | 152 |
| 153 // Returns true if |layer|'s bounds don't fit within |size|. |
| 154 static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size); |
| 155 |
132 // Initializes |layer_ptr| and |painter_ptr| to display |image|. | 156 // Initializes |layer_ptr| and |painter_ptr| to display |image|. |
133 // Also adds the passed-in layer to |layer_|. | 157 // Also adds the passed-in layer to |layer_|. |
134 void InitImage(const gfx::Image* image, | 158 void InitImage(const gfx::Image* image, |
135 scoped_ptr<ui::Layer>* layer_ptr, | 159 scoped_ptr<ui::Layer>* layer_ptr, |
136 scoped_ptr<ImagePainter>* painter_ptr); | 160 scoped_ptr<ImagePainter>* painter_ptr); |
137 | 161 |
138 // Layer that contains all of the image layers. | 162 // Layer that contains all of the image layers. |
139 scoped_ptr<ui::Layer> layer_; | 163 scoped_ptr<ui::Layer> layer_; |
140 | 164 |
141 // The grid's dimensions. | 165 // The grid's dimensions. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 scoped_ptr<ImagePainter> bottom_painter_; | 203 scoped_ptr<ImagePainter> bottom_painter_; |
180 scoped_ptr<ImagePainter> bottom_right_painter_; | 204 scoped_ptr<ImagePainter> bottom_right_painter_; |
181 | 205 |
182 DISALLOW_COPY_AND_ASSIGN(ImageGrid); | 206 DISALLOW_COPY_AND_ASSIGN(ImageGrid); |
183 }; | 207 }; |
184 | 208 |
185 } // namespace internal | 209 } // namespace internal |
186 } // namespace aura_shell | 210 } // namespace aura_shell |
187 | 211 |
188 #endif // UI_AURA_SHELL_IMAGE_GRID_H_ | 212 #endif // UI_AURA_SHELL_IMAGE_GRID_H_ |
OLD | NEW |