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

Unified Diff: ui/compositor/layer.cc

Issue 2254733003: Add ui::LayerObserver and use it to update Alt+Tab previews as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: appease compiler Created 4 years, 4 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
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 9accc1f3ab920799ae5b7c0e3e99037543cf1686..2be4080111b60e2c520e99595ecbf2258bb99ae6 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -28,6 +28,7 @@
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer_animator.h"
+#include "ui/compositor/layer_observer.h"
#include "ui/compositor/paint_context.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/canvas.h"
@@ -99,6 +100,8 @@ Layer::Layer(LayerType type)
}
Layer::~Layer() {
+ FOR_EACH_OBSERVER(LayerObserver, observer_list_, OnLayerDestroyed(this));
+
// Destroying the animator may cause observers to use the layer (and
// indirectly the WebLayer). Destroy the animator first so that the WebLayer
// is still around.
@@ -151,6 +154,14 @@ void Layer::ResetCompositor() {
}
}
+void Layer::AddObserver(LayerObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void Layer::RemoveObserver(LayerObserver* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
void Layer::Add(Layer* child) {
DCHECK(!child->compositor_);
if (child->parent_)
@@ -754,6 +765,11 @@ void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {
if (!delegate_)
return;
delegate_->OnDelegatedFrameDamage(damage_rect_in_dip);
+
+ for (Layer* ancestor = this; ancestor; ancestor = ancestor->parent()) {
sky 2016/08/18 13:36:21 I would like to avoid having to walk the tree on e
Evan Stade 2016/08/18 15:57:31 This only walks up (as opposed to a full tree trav
+ FOR_EACH_OBSERVER(LayerObserver, ancestor->observer_list_,
+ OnDelegatedFrameDamageInTree());
+ }
}
void Layer::SetScrollable(Layer* parent_clip_layer,
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698