Index: ppapi/proxy/compositor_resource.cc |
diff --git a/ppapi/proxy/compositor_resource.cc b/ppapi/proxy/compositor_resource.cc |
index 3ada734849839aca56078ac7e3859b6d574df1a6..8b8a3523fb8a13cd465536dcafde3fa750156d21 100644 |
--- a/ppapi/proxy/compositor_resource.cc |
+++ b/ppapi/proxy/compositor_resource.cc |
@@ -6,6 +6,7 @@ |
#include "base/logging.h" |
#include "ppapi/proxy/ppapi_messages.h" |
+#include "ppapi/thunk/enter.h" |
namespace ppapi { |
namespace proxy { |
@@ -14,6 +15,7 @@ CompositorResource::CompositorResource(Connection connection, |
PP_Instance instance) |
: PluginResource(connection, instance), |
layer_reset_(true), |
+ bound_to_instance_(false), |
last_resource_id_(0) { |
SendCreate(RENDERER, PpapiHostMsg_Compositor_Create()); |
} |
@@ -39,6 +41,9 @@ void CompositorResource::OnReplyReceived( |
} |
PP_Resource CompositorResource::AddLayer() { |
+ if (!bound_to_instance_) |
+ return 0; |
+ |
scoped_refptr<CompositorLayerResource> resource(new CompositorLayerResource( |
connection(), pp_instance(), this)); |
layers_.push_back(resource); |
@@ -47,6 +52,9 @@ PP_Resource CompositorResource::AddLayer() { |
int32_t CompositorResource::CommitLayers( |
const scoped_refptr<ppapi::TrackedCallback>& callback) { |
+ if (!bound_to_instance_) |
+ return PP_ERROR_FAILED; |
+ |
if (IsInProgress()) |
return PP_ERROR_INPROGRESS; |
@@ -72,12 +80,41 @@ int32_t CompositorResource::CommitLayers( |
} |
int32_t CompositorResource::ResetLayers() { |
+ if (!bound_to_instance_) |
+ return PP_ERROR_FAILED; |
+ |
if (IsInProgress()) |
return PP_ERROR_INPROGRESS; |
+ |
ResetLayersInternal(); |
return PP_OK; |
} |
+void CompositorResource::BindToInstance(bool bound) { |
+ ProxyLock::AssertAcquiredDebugOnly(); |
+ |
+ if (bound == bound_to_instance_) |
+ return; |
+ bound_to_instance_ = bound; |
+ |
+ // Reset layers when the compositor is un bound from the instance. |
+ if (!bound_to_instance_) |
+ ResetLayersInternal(); |
+} |
+ |
+void CompositorResource::NotifyLastPluginRefWasDeleted() { |
+ ProxyLock::AssertAcquiredDebugOnly(); |
+ |
+ PluginResource::NotifyLastPluginRefWasDeleted(); |
+ if (bound_to_instance_) { |
+ ppapi::thunk::EnterInstanceNoLock enter(pp_instance()); |
+ DCHECK(enter.succeeded()); |
+ enter.functions()->BindGraphics(pp_instance(), 0); |
+ // BindToInstance(0) should be called by PPB_Instance_Proxy::BindGraphics(). |
+ DCHECK(!bound_to_instance_); |
+ } |
raymes
2014/06/18 05:58:44
Why do we need to do this?
Peng
2014/06/18 11:14:37
Because the plugin instance holds a scoped_refptr
raymes
2014/06/19 00:39:13
I think this would be much simpler if we didn't ma
Peng
2014/06/19 17:35:11
In the recent patchset, we do not manage the bind
|
+} |
+ |
void CompositorResource::OnPluginMsgCommitLayersReply( |
const ResourceMessageReplyParams& params) { |
if (!TrackedCallback::IsPending(commit_callback_)) |