| Index: ppapi/proxy/compositor_resource.cc
|
| diff --git a/ppapi/proxy/compositor_resource.cc b/ppapi/proxy/compositor_resource.cc
|
| index 3ada734849839aca56078ac7e3859b6d574df1a6..9688f6054bc5d9796fbbfd86eacd16e61445b337 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());
|
| + CHECK(enter.succeeded());
|
| + enter.functions()->BindGraphics(pp_instance(), 0);
|
| + // BindToInstance(0) should be called by PPB_Instance_Proxy::BindGraphics().
|
| + CHECK(!bound_to_instance_);
|
| + }
|
| +}
|
| +
|
| void CompositorResource::OnPluginMsgCommitLayersReply(
|
| const ResourceMessageReplyParams& params) {
|
| if (!TrackedCallback::IsPending(commit_callback_))
|
|
|