Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: ash/common/wm/forwarding_layer_delegate.cc

Issue 2383263002: Generalize layer mirroring for phantom windows (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/common/wm/forwarding_layer_delegate.cc
diff --git a/ash/common/wm/forwarding_layer_delegate.cc b/ash/common/wm/forwarding_layer_delegate.cc
index 55a12042f98821d70b9fe1b74e407d9ea8d0d181..4bef537dec5190669e44639cd1d3d70fc05b2c35 100644
--- a/ash/common/wm/forwarding_layer_delegate.cc
+++ b/ash/common/wm/forwarding_layer_delegate.cc
@@ -4,7 +4,6 @@
#include "ash/common/wm/forwarding_layer_delegate.h"
-#include "ash/common/wm_window.h"
#include "base/callback.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_owner.h"
@@ -12,11 +11,14 @@
namespace ash {
namespace wm {
-ForwardingLayerDelegate::ForwardingLayerDelegate(ui::Layer* new_layer,
- ui::Layer* original_layer)
- : client_layer_(new_layer),
+ForwardingLayerDelegate::ForwardingLayerDelegate(ui::Layer* client_layer,
+ ui::Layer* original_layer,
+ bool sync_bounds)
+ : client_layer_(client_layer),
original_layer_(original_layer),
- scoped_observer_(this) {
+ scoped_observer_(this),
+ sync_bounds_(sync_bounds) {
+ DCHECK(original_layer->owner());
scoped_observer_.Add(original_layer);
}
@@ -45,27 +47,19 @@ void ForwardingLayerDelegate::DidPaintLayer(ui::Layer* layer,
client_layer_->SchedulePaint(rect);
}
-void ForwardingLayerDelegate::SurfaceChanged(ui::Layer* layer) {
- // This will delete the old layer and any descendants.
- ui::LayerOwner old_client;
- old_client.SetLayer(client_layer_);
-
- ui::LayerOwner* owner = layer->owner();
- // The layer recreation step isn't recursive, but layers with surfaces don't
- // tend to have children anyway. We may end up missing some children, but we
- // can also reach that state if layers are ever added or removed.
- // TODO(estade): address this if it ever becomes a practical issue.
- std::unique_ptr<ui::Layer> recreated = owner->RecreateLayer();
- client_layer_ = recreated.get();
- old_client.layer()->parent()->Add(recreated.release());
- old_client.layer()->parent()->Remove(old_client.layer());
+void ForwardingLayerDelegate::BoundsChanged(ui::Layer* layer) {
+ DCHECK_EQ(layer, original_layer_);
+ if (sync_bounds_)
+ client_layer_->SetBounds(layer->bounds());
+}
- scoped_observer_.Remove(original_layer_);
- original_layer_ = owner->layer();
- scoped_observer_.Add(original_layer_);
+void ForwardingLayerDelegate::SurfaceChanged(ui::Layer* layer) {
+ DCHECK_EQ(layer, original_layer_);
+ layer->owner()->MirrorLayer(client_layer_);
}
void ForwardingLayerDelegate::LayerDestroyed(ui::Layer* layer) {
+ DCHECK_EQ(layer, original_layer_);
original_layer_ = nullptr;
scoped_observer_.Remove(layer);
}

Powered by Google App Engine
This is Rietveld 408576698