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

Unified Diff: ppapi/proxy/compositor_resource.cc

Issue 324983005: [PPAPI] Add browser tests for compositor API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_impl_new
Patch Set: Rebase Created 6 years, 6 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
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;
piman 2014/06/18 00:55:24 Why? It doesn't seem legit.
Peng 2014/06/18 02:35:03 Same reason.
Peng 2014/06/18 02:35:03 I explained the reason in another comment. Please
+
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.
piman 2014/06/18 00:55:24 why?
Peng 2014/06/18 02:35:03 Same reason.
+ 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());
piman 2014/06/18 00:55:24 no CHECK.
Peng 2014/06/18 02:35:03 Done.
+ enter.functions()->BindGraphics(pp_instance(), 0);
piman 2014/06/18 00:55:24 Why the need to do this? The browser side can do i
Peng 2014/06/18 02:35:03 Because the plugin will not notify the host, when
+ // BindToInstance(0) should be called by PPB_Instance_Proxy::BindGraphics().
+ CHECK(!bound_to_instance_);
piman 2014/06/18 00:55:24 no CHECK.
Peng 2014/06/18 02:35:03 Done.
+ }
+}
+
void CompositorResource::OnPluginMsgCommitLayersReply(
const ResourceMessageReplyParams& params) {
if (!TrackedCallback::IsPending(commit_callback_))

Powered by Google App Engine
This is Rietveld 408576698