| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_VIEWS_ANIMATION_INK_DROP_MASK_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ |
| 6 #define UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
| 10 #include "ui/compositor/layer_delegate.h" | 10 #include "ui/compositor/layer_delegate.h" |
| 11 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 // Base class for different ink drop masks. It is responsible for creating the | 17 // Base class for different ink drop masks. It is responsible for creating the |
| 18 // ui::Layer that can be set as the mask layer for ink drop layer. | 18 // ui::Layer that can be set as the mask layer for ink drop layer. |
| 19 class VIEWS_EXPORT InkDropMask : public ui::LayerDelegate { | 19 class VIEWS_EXPORT InkDropMask : public ui::LayerDelegate { |
| 20 public: | 20 public: |
| 21 ~InkDropMask() override; | 21 ~InkDropMask() override; |
| 22 | 22 |
| 23 ui::Layer* layer() { return &layer_; } | 23 ui::Layer* layer() { return &layer_; } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 explicit InkDropMask(const gfx::Rect& layer_bounds); | 26 explicit InkDropMask(const gfx::Size& layer_size); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Overriden from ui::LayerDelegate: | 29 // Overriden from ui::LayerDelegate: |
| 30 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; | 30 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; |
| 31 | 31 |
| 32 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 32 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
| 33 | 33 |
| 34 ui::Layer layer_; | 34 ui::Layer layer_; |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(InkDropMask); | 36 DISALLOW_COPY_AND_ASSIGN(InkDropMask); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // A rectangular ink drop mask with rounded corners. | 39 // A rectangular ink drop mask with rounded corners. |
| 40 class VIEWS_EXPORT RoundRectInkDropMask : public InkDropMask { | 40 class VIEWS_EXPORT RoundRectInkDropMask : public InkDropMask { |
| 41 public: | 41 public: |
| 42 RoundRectInkDropMask(const gfx::Rect& layer_bounds, | 42 RoundRectInkDropMask(const gfx::Size& layer_size, |
| 43 const gfx::Rect& mask_bounds, | 43 const gfx::Rect& mask_bounds, |
| 44 int corner_radius); | 44 int corner_radius); |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // Overriden from InkDropMask: | 47 // Overriden from InkDropMask: |
| 48 void OnPaintLayer(const ui::PaintContext& context) override; | 48 void OnPaintLayer(const ui::PaintContext& context) override; |
| 49 | 49 |
| 50 gfx::Rect mask_bounds_; | 50 gfx::Rect mask_bounds_; |
| 51 int corner_radius_; | 51 int corner_radius_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(RoundRectInkDropMask); | 53 DISALLOW_COPY_AND_ASSIGN(RoundRectInkDropMask); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // A circular ink drop mask. | 56 // A circular ink drop mask. |
| 57 class VIEWS_EXPORT CircleInkDropMask : public InkDropMask { | 57 class VIEWS_EXPORT CircleInkDropMask : public InkDropMask { |
| 58 public: | 58 public: |
| 59 CircleInkDropMask(const gfx::Rect& layer_bounds, | 59 CircleInkDropMask(const gfx::Size& layer_size, |
| 60 const gfx::Point& mask_center, | 60 const gfx::Point& mask_center, |
| 61 int mask_radius); | 61 int mask_radius); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // Overriden from InkDropMask: | 64 // Overriden from InkDropMask: |
| 65 void OnPaintLayer(const ui::PaintContext& context) override; | 65 void OnPaintLayer(const ui::PaintContext& context) override; |
| 66 | 66 |
| 67 gfx::Point mask_center_; | 67 gfx::Point mask_center_; |
| 68 int mask_radius_; | 68 int mask_radius_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CircleInkDropMask); | 70 DISALLOW_COPY_AND_ASSIGN(CircleInkDropMask); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace views | 73 } // namespace views |
| 74 | 74 |
| 75 #endif // UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ | 75 #endif // UI_VIEWS_ANIMATION_INK_DROP_MASK_H_ |
| OLD | NEW |