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

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: fix for other test 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 c7111526207124f5ba5b647301a49742c2bc4ea9..5cf93d099cc5f2b60ffa8c116cdedce3201a26a2 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"
@@ -95,6 +96,8 @@ Layer::Layer(LayerType type)
}
Layer::~Layer() {
+ FOR_EACH_OBSERVER(LayerObserver, observer_list_, LayerDestroyed(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.
@@ -147,6 +150,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_)
@@ -584,6 +595,8 @@ void Layer::SetShowSurface(
frame_size_in_dip_ = frame_size_in_dip;
RecomputeDrawsContentAndUVRect();
+
+ FOR_EACH_OBSERVER(LayerObserver, observer_list_, SurfaceChanged(this));
}
void Layer::SetShowSolidColorContent() {
@@ -729,9 +742,8 @@ void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) {
void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {
DCHECK(surface_layer_.get());
- if (!delegate_)
- return;
- delegate_->OnDelegatedFrameDamage(damage_rect_in_dip);
+ if (delegate_)
+ delegate_->OnDelegatedFrameDamage(damage_rect_in_dip);
}
void Layer::SetScrollable(Layer* parent_clip_layer,
@@ -787,6 +799,8 @@ scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList(
PaintContext(display_list.get(), device_scale_factor_, invalidation));
}
display_list->Finalize();
+ FOR_EACH_OBSERVER(LayerObserver, observer_list_,
+ DidPaintLayer(this, invalidation));
return display_list;
}
« 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