Index: ui/compositor/compositor.cc |
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc |
index 148a5bd28c782ebc0a5ebac6fa65742d4d092717..d1938f5879cd9950e5fdf3f50b6b0aab7a512a39 100644 |
--- a/ui/compositor/compositor.cc |
+++ b/ui/compositor/compositor.cc |
@@ -162,6 +162,9 @@ Compositor::Compositor(CompositorDelegate* delegate, |
} |
Compositor::~Compositor() { |
+ // Clear out any pending callbacks. |
+ didCommit(); |
+ |
// Don't call |CompositorDelegate::ScheduleDraw| from this point. |
delegate_ = NULL; |
// There's a cycle between |root_web_layer_| and |host_|, which results in |
@@ -170,6 +173,11 @@ Compositor::~Compositor() { |
host_.setRootLayer(NULL); |
if (root_layer_) |
root_layer_->SetCompositor(NULL); |
+ |
+ // Stop all outstanding draws before telling the ContextFactory to tear |
+ // down any contexts that the host_ may rely upon. |
+ host_.reset(); |
+ |
if (!test_compositor_enabled) |
ContextFactory::GetInstance()->RemoveCompositor(this); |
} |
@@ -342,6 +350,17 @@ WebKit::WebGraphicsContext3D* Compositor::createContext3D() { |
void Compositor::didRebindGraphicsContext(bool success) { |
} |
+// Called once per draw in single-threaded compositor mode and potentially |
+// many times between draws in the multi-threaded compositor mode. |
+void Compositor::didCommit() { |
+ for (std::vector< base::Callback<void(Compositor*)> >::const_iterator |
+ it = did_commit_callbacks_.begin(); |
+ it != did_commit_callbacks_.end(); ++it) { |
+ it->Run(this); |
piman
2012/07/12 00:18:09
btw, you run the risk of the closure modifying did
|
+ } |
+ did_commit_callbacks_.clear(); |
+} |
+ |
void Compositor::didCommitAndDrawFrame() { |
// TODO(backer): Plumb through an earlier impl side will start. |
if (g_compositor_thread) |
@@ -363,6 +382,11 @@ void Compositor::scheduleComposite() { |
ScheduleDraw(); |
} |
+void Compositor::AddDidCommitCallback( |
+ const base::Callback<void(ui::Compositor*)>& callback) { |
+ did_commit_callbacks_.push_back(callback); |
+} |
+ |
void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels, |
const gfx::Size& image_size) { |
// Swizzle from RGBA to BGRA |