Index: content/renderer/pepper/pepper_compositor_host.cc |
diff --git a/content/renderer/pepper/pepper_compositor_host.cc b/content/renderer/pepper/pepper_compositor_host.cc |
index baba5b89b16ee0d272f15ec4002b0d9be4860e49..b03b1ff210628eff1591d65dad4e65f51c98fd53 100644 |
--- a/content/renderer/pepper/pepper_compositor_host.cc |
+++ b/content/renderer/pepper/pepper_compositor_host.cc |
@@ -158,10 +158,35 @@ bool PepperCompositorHost::BindToInstance( |
if (bound_instance_ && new_instance) |
return false; // Can't change a bound device. |
bound_instance_ = new_instance; |
+ if (!bound_instance_) |
+ SendCommitLayersReplyIfNecessary(); |
+ |
return true; |
} |
void PepperCompositorHost::ViewInitiatedPaint() { |
+ SendCommitLayersReplyIfNecessary(); |
+} |
+ |
+void PepperCompositorHost::ViewFlushedPaint() {} |
+ |
+void PepperCompositorHost::ImageReleased( |
+ int32_t id, |
+ const scoped_ptr<base::SharedMemory>& shared_memory, |
+ uint32_t sync_point, |
+ bool is_lost) { |
+ ResourceReleased(id, sync_point, is_lost); |
+} |
+ |
+void PepperCompositorHost::ResourceReleased(int32_t id, |
+ uint32_t sync_point, |
+ bool is_lost) { |
+ host()->SendUnsolicitedReply( |
+ pp_resource(), |
+ PpapiPluginMsg_Compositor_ReleaseResource(id, sync_point, is_lost)); |
+} |
+ |
+void PepperCompositorHost::SendCommitLayersReplyIfNecessary() { |
if (!commit_layers_reply_context_.is_valid()) |
return; |
host()->SendReply(commit_layers_reply_context_, |
@@ -169,8 +194,6 @@ void PepperCompositorHost::ViewInitiatedPaint() { |
commit_layers_reply_context_ = ppapi::host::ReplyMessageContext(); |
} |
-void PepperCompositorHost::ViewFlushedPaint() {} |
- |
void PepperCompositorHost::UpdateLayer( |
const scoped_refptr<cc::Layer>& layer, |
const ppapi::CompositorLayerData* old_layer, |
@@ -277,28 +300,14 @@ void PepperCompositorHost::UpdateLayer( |
NOTREACHED(); |
} |
-void PepperCompositorHost::ResourceReleased(int32_t id, |
- uint32_t sync_point, |
- bool is_lost) { |
- host()->SendUnsolicitedReply( |
- pp_resource(), |
- PpapiPluginMsg_Compositor_ReleaseResource(id, sync_point, is_lost)); |
-} |
- |
-void PepperCompositorHost::ImageReleased( |
- int32_t id, |
- const scoped_ptr<base::SharedMemory>& shared_memory, |
- uint32_t sync_point, |
- bool is_lost) { |
- ResourceReleased(id, sync_point, is_lost); |
-} |
- |
int32_t PepperCompositorHost::OnResourceMessageReceived( |
const IPC::Message& msg, |
HostMessageContext* context) { |
PPAPI_BEGIN_MESSAGE_MAP(PepperCompositorHost, msg) |
PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
PpapiHostMsg_Compositor_CommitLayers, OnHostMsgCommitLayers) |
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( |
+ PpapiHostMsg_Compositor_Release, OnHostMsgRelease) |
PPAPI_END_MESSAGE_MAP() |
return ppapi::host::ResourceHost::OnResourceMessageReceived(msg, context); |
} |
@@ -311,15 +320,9 @@ int32_t PepperCompositorHost::OnHostMsgCommitLayers( |
HostMessageContext* context, |
const std::vector<ppapi::CompositorLayerData>& layers, |
bool reset) { |
- // Do not support CommitLayers() on an unbounded compositor. |
- if (!bound_instance_) |
- return PP_ERROR_FAILED; |
- |
if (commit_layers_reply_context_.is_valid()) |
return PP_ERROR_INPROGRESS; |
- commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
- |
scoped_ptr<scoped_ptr<base::SharedMemory>[]> image_shms; |
if (layers.size() > 0) { |
image_shms.reset(new scoped_ptr<base::SharedMemory>[layers.size()]); |
@@ -373,7 +376,19 @@ int32_t PepperCompositorHost::OnHostMsgCommitLayers( |
if (layer_->layer_tree_host()) |
layer_->layer_tree_host()->SetNeedsCommit(); |
+ // If the host is not bound to the instance, return PP_OK immediately. |
+ if (!bound_instance_) |
+ return PP_OK; |
+ |
+ commit_layers_reply_context_ = context->MakeReplyMessageContext(); |
return PP_OK_COMPLETIONPENDING; |
} |
+int32_t PepperCompositorHost::OnHostMsgRelease(HostMessageContext* context) { |
+ SendCommitLayersReplyIfNecessary(); |
+ layer_->RemoveAllChildren(); |
+ layers_.clear(); |
+ return PP_OK; |
+} |
+ |
} // namespace content |