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