| 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 ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ | 5 #ifndef ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ |
| 6 #define ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ | 6 #define ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/scoped_observer.h" |
| 9 #include "ui/compositor/layer_delegate.h" | 10 #include "ui/compositor/layer_delegate.h" |
| 11 #include "ui/compositor/layer_observer.h" |
| 10 | 12 |
| 11 namespace ui { | 13 namespace ui { |
| 12 class Layer; | 14 class Layer; |
| 13 } | 15 } |
| 14 | 16 |
| 15 namespace ash { | 17 namespace ash { |
| 16 | 18 |
| 17 class WmWindow; | 19 class WmWindow; |
| 18 | 20 |
| 19 namespace wm { | 21 namespace wm { |
| 20 | 22 |
| 21 // A layer delegate to paint the content of a recreated layer by delegating | 23 // A layer delegate to paint the content of a recreated layer by delegating |
| 22 // the paint request to the original delegate. It checks if the original | 24 // the paint request to the original delegate. It is a delegate of the recreated |
| 23 // delegate is still valid by traversing the original layers. | 25 // layer and an observer of the original layer. |
| 24 class ForwardingLayerDelegate : public ui::LayerDelegate { | 26 class ForwardingLayerDelegate : public ui::LayerDelegate, |
| 27 public ui::LayerObserver { |
| 25 public: | 28 public: |
| 26 ForwardingLayerDelegate(WmWindow* original_window, | 29 ForwardingLayerDelegate(ui::Layer* new_layer, ui::Layer* original_layer); |
| 27 ui::LayerDelegate* delegate); | |
| 28 ~ForwardingLayerDelegate() override; | 30 ~ForwardingLayerDelegate() override; |
| 29 | 31 |
| 30 private: | |
| 31 bool IsDelegateValid(ui::Layer* layer) const; | |
| 32 | |
| 33 // ui:LayerDelegate: | 32 // ui:LayerDelegate: |
| 34 void OnPaintLayer(const ui::PaintContext& context) override; | 33 void OnPaintLayer(const ui::PaintContext& context) override; |
| 35 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; | 34 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; |
| 36 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 35 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
| 37 base::Closure PrepareForLayerBoundsChange() override; | 36 base::Closure PrepareForLayerBoundsChange() override; |
| 38 | 37 |
| 39 WmWindow* original_window_; | 38 // ui::LayerObserver: |
| 40 ui::LayerDelegate* original_delegate_; | 39 void DidPaintLayer(ui::Layer* layer, const gfx::Rect& rect) override; |
| 40 void SurfaceChanged(ui::Layer* layer) override; |
| 41 void LayerDestroyed(ui::Layer* layer) override; |
| 42 |
| 43 private: |
| 44 // The layer for which |this| is the delegate. |
| 45 ui::Layer* client_layer_; |
| 46 |
| 47 // The layer that was recreated to replace |new_layer_|. |
| 48 ui::Layer* original_layer_; |
| 49 |
| 50 ScopedObserver<ui::Layer, ui::LayerObserver> scoped_observer_; |
| 41 | 51 |
| 42 DISALLOW_COPY_AND_ASSIGN(ForwardingLayerDelegate); | 52 DISALLOW_COPY_AND_ASSIGN(ForwardingLayerDelegate); |
| 43 }; | 53 }; |
| 44 | 54 |
| 45 } // namespace wm | 55 } // namespace wm |
| 46 } // namespace ash | 56 } // namespace ash |
| 47 | 57 |
| 48 #endif // ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ | 58 #endif // ASH_COMMON_WM_FORWARDING_LAYER_DELEGATE_H_ |
| OLD | NEW |