| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | |
| 10 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| 12 #include "ui/compositor/layer_delegate.h" | 11 #include "ui/compositor/layer_delegate.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 16 #include "ui/wm/wm_export.h" | 15 #include "ui/wm/wm_export.h" |
| 17 | 16 |
| 18 namespace gfx { | 17 namespace gfx { |
| 19 class Image; | 18 class Image; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // | xXX| | 54 // | xXX| |
| 56 // | xXX|< window's left edge | 55 // | xXX|< window's left edge |
| 57 // | xXX| | 56 // | xXX| |
| 58 // ... | 57 // ... |
| 59 // | 58 // |
| 60 class WM_EXPORT ImageGrid { | 59 class WM_EXPORT ImageGrid { |
| 61 public: | 60 public: |
| 62 // Helper class for use by tests. | 61 // Helper class for use by tests. |
| 63 class WM_EXPORT TestAPI { | 62 class WM_EXPORT TestAPI { |
| 64 public: | 63 public: |
| 65 TestAPI(ImageGrid* grid) : grid_(grid) {} | 64 explicit TestAPI(ImageGrid* grid) : grid_(grid) {} |
| 66 | 65 |
| 67 gfx::Rect top_left_clip_rect() const { | 66 gfx::Rect top_left_clip_rect() const { |
| 68 return grid_->top_left_painter_->clip_rect_; | 67 return grid_->top_left_painter_->clip_rect_; |
| 69 } | 68 } |
| 70 gfx::Rect top_right_clip_rect() const { | 69 gfx::Rect top_right_clip_rect() const { |
| 71 return grid_->top_right_painter_->clip_rect_; | 70 return grid_->top_right_painter_->clip_rect_; |
| 72 } | 71 } |
| 73 gfx::Rect bottom_left_clip_rect() const { | 72 gfx::Rect bottom_left_clip_rect() const { |
| 74 return grid_->bottom_left_painter_->clip_rect_; | 73 return grid_->bottom_left_painter_->clip_rect_; |
| 75 } | 74 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void SetSize(const gfx::Size& size); | 121 void SetSize(const gfx::Size& size); |
| 123 | 122 |
| 124 // Sets the grid to a position and size such that the inner edges of the top, | 123 // Sets the grid to a position and size such that the inner edges of the top, |
| 125 // bottom, left and right images will be flush with |content_bounds_in_dip|. | 124 // bottom, left and right images will be flush with |content_bounds_in_dip|. |
| 126 void SetContentBounds(const gfx::Rect& content_bounds_in_dip); | 125 void SetContentBounds(const gfx::Rect& content_bounds_in_dip); |
| 127 | 126 |
| 128 private: | 127 private: |
| 129 // Delegate responsible for painting a specific image on a layer. | 128 // Delegate responsible for painting a specific image on a layer. |
| 130 class ImagePainter : public ui::LayerDelegate { | 129 class ImagePainter : public ui::LayerDelegate { |
| 131 public: | 130 public: |
| 132 ImagePainter(const gfx::ImageSkia& image) : image_(image) {} | 131 explicit ImagePainter(const gfx::ImageSkia& image) : image_(image) {} |
| 133 ~ImagePainter() override {} | 132 ~ImagePainter() override {} |
| 134 | 133 |
| 135 // Clips |layer| to |clip_rect|. Triggers a repaint if the clipping | 134 // Clips |layer| to |clip_rect|. Triggers a repaint if the clipping |
| 136 // rectangle has changed. An empty rectangle disables clipping. | 135 // rectangle has changed. An empty rectangle disables clipping. |
| 137 void SetClipRect(const gfx::Rect& clip_rect, ui::Layer* layer); | 136 void SetClipRect(const gfx::Rect& clip_rect, ui::Layer* layer); |
| 138 | 137 |
| 139 // ui::LayerDelegate implementation: | 138 // ui::LayerDelegate implementation: |
| 140 void OnPaintLayer(const ui::PaintContext& context) override; | 139 void OnPaintLayer(const ui::PaintContext& context) override; |
| 141 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; | 140 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; |
| 142 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 141 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 scoped_ptr<ImagePainter> bottom_left_painter_; | 212 scoped_ptr<ImagePainter> bottom_left_painter_; |
| 214 scoped_ptr<ImagePainter> bottom_painter_; | 213 scoped_ptr<ImagePainter> bottom_painter_; |
| 215 scoped_ptr<ImagePainter> bottom_right_painter_; | 214 scoped_ptr<ImagePainter> bottom_right_painter_; |
| 216 | 215 |
| 217 DISALLOW_COPY_AND_ASSIGN(ImageGrid); | 216 DISALLOW_COPY_AND_ASSIGN(ImageGrid); |
| 218 }; | 217 }; |
| 219 | 218 |
| 220 } // namespace wm | 219 } // namespace wm |
| 221 | 220 |
| 222 #endif // UI_WM_CORE_IMAGE_GRID_H_ | 221 #endif // UI_WM_CORE_IMAGE_GRID_H_ |
| OLD | NEW |