OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/common/wm/forwarding_layer_delegate.h" |
| 6 |
| 7 #include "ash/common/wm_window.h" |
| 8 #include "base/callback.h" |
| 9 #include "ui/compositor/layer.h" |
| 10 |
| 11 namespace ash { |
| 12 namespace wm { |
| 13 |
| 14 ForwardingLayerDelegate::ForwardingLayerDelegate(WmWindow* original_window, |
| 15 ui::LayerDelegate* delegate) |
| 16 : original_window_(original_window), original_delegate_(delegate) {} |
| 17 |
| 18 ForwardingLayerDelegate::~ForwardingLayerDelegate() {} |
| 19 |
| 20 void ForwardingLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { |
| 21 if (!original_delegate_) |
| 22 return; |
| 23 // |original_delegate_| may have already been deleted or |
| 24 // disconnected by this time. Check if |original_delegate_| is still |
| 25 // used by the original_window tree, or skip otherwise. |
| 26 if (IsDelegateValid(original_window_->GetLayer())) |
| 27 original_delegate_->OnPaintLayer(context); |
| 28 else |
| 29 original_delegate_ = nullptr; |
| 30 } |
| 31 |
| 32 void ForwardingLayerDelegate::OnDelegatedFrameDamage( |
| 33 const gfx::Rect& damage_rect_in_dip) {} |
| 34 |
| 35 void ForwardingLayerDelegate::OnDeviceScaleFactorChanged( |
| 36 float device_scale_factor) { |
| 37 // Don't tell the original delegate about device scale factor change |
| 38 // on cloned layer because the original layer is still on the same display. |
| 39 } |
| 40 |
| 41 base::Closure ForwardingLayerDelegate::PrepareForLayerBoundsChange() { |
| 42 return base::Closure(); |
| 43 } |
| 44 |
| 45 bool ForwardingLayerDelegate::IsDelegateValid(ui::Layer* layer) const { |
| 46 if (layer->delegate() == original_delegate_) |
| 47 return true; |
| 48 for (auto* child : layer->children()) { |
| 49 if (IsDelegateValid(child)) |
| 50 return true; |
| 51 } |
| 52 return false; |
| 53 } |
| 54 |
| 55 } // namespace wm |
| 56 } // namespace ash |
OLD | NEW |