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

Unified Diff: ppapi/proxy/ppb_instance_proxy.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: Remove change in base folder. 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/ppb_instance_proxy.cc
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 4f64e917af4413db9697ca6a3a7fc373d596b53d..7169ee4498d977bd56b1176c03de7ab0579da30c 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -216,37 +216,44 @@ PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance,
PP_Resource device) {
// If device is 0, pass a null HostResource. This signals the host to unbind
// all devices.
- HostResource host_resource;
PP_Resource pp_resource = 0;
if (device) {
- Resource* resource =
- PpapiGlobals::Get()->GetResourceTracker()->GetResource(device);
- if (!resource || resource->pp_instance() != instance)
+ do {
+ // Try enter device as a Graphics3D deivce.
+ EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
+ if (enter_3d.succeeded()) {
+ if (enter_3d.resource()->pp_instance() != instance)
+ return PP_FALSE;
+ pp_resource = enter_3d.resource()->host_resource().host_resource();
+ break;
+ }
+
+ // Try enter device as a Graphics2D device.
+ EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
+ if (enter_2d.succeeded()) {
+ if (enter_2d.resource()->pp_instance() != instance)
+ return PP_FALSE;
+ pp_resource = enter_2d.resource()->pp_resource();
+ break;
+ }
+
+ // Try enter device as a Compositor device.
+ EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false);
+ if (enter_compositor.succeeded()) {
+ if (enter_compositor.resource()->pp_instance() != instance)
+ return PP_FALSE;
+ pp_resource = enter_compositor.resource()->pp_resource();
+ break;
+ }
+
return PP_FALSE;
- host_resource = resource->host_resource();
- pp_resource = resource->pp_resource();
- } else {
- // Passing 0 means unbinding all devices.
- dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
- API_ID_PPB_INSTANCE, instance, 0));
- return PP_TRUE;
+ } while (false);
piman 2014/06/19 20:44:04 This is not needed any more, right?
Peng 2014/06/19 22:33:41 It is not necessary anymore, but it is an improvem
}
- // We need to pass different resource to Graphics 2D and 3D right now. Once
- // 3D is migrated to the new design, we should be able to unify this.
- EnterResourceNoLock<PPB_Compositor_API> enter_compositor(device, false);
- EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
- EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
- if (enter_compositor.succeeded() || enter_2d.succeeded()) {
- dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
API_ID_PPB_INSTANCE, instance, pp_resource));
- return PP_TRUE;
- } else if (enter_3d.succeeded()) {
- dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
- API_ID_PPB_INSTANCE, instance, host_resource.host_resource()));
- return PP_TRUE;
- }
- return PP_FALSE;
+
+ return PP_TRUE;
}
PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) {

Powered by Google App Engine
This is Rietveld 408576698