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

Side by Side Diff: ppapi/proxy/ppb_surface_3d_proxy.cc

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppb_surface_3d_proxy.h" 5 #include "ppapi/proxy/ppb_surface_3d_proxy.h"
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" 10 #include "ppapi/c/dev/ppb_surface_3d_dev.h"
11 #include "ppapi/proxy/enter_proxy.h" 11 #include "ppapi/proxy/enter_proxy.h"
12 #include "ppapi/proxy/plugin_dispatcher.h" 12 #include "ppapi/proxy/plugin_dispatcher.h"
13 #include "ppapi/proxy/plugin_resource.h"
14 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/ppb_context_3d_proxy.h" 14 #include "ppapi/proxy/ppb_context_3d_proxy.h"
16 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
17 #include "ppapi/thunk/resource_creation_api.h" 16 #include "ppapi/thunk/resource_creation_api.h"
18 #include "ppapi/thunk/thunk.h" 17 #include "ppapi/thunk/thunk.h"
19 18
20 using ppapi::HostResource; 19 using ppapi::HostResource;
20 using ppapi::Resource;
21 using ppapi::thunk::EnterFunctionNoLock; 21 using ppapi::thunk::EnterFunctionNoLock;
22 using ppapi::thunk::PPB_Surface3D_API; 22 using ppapi::thunk::PPB_Surface3D_API;
23 using ppapi::thunk::ResourceCreationAPI; 23 using ppapi::thunk::ResourceCreationAPI;
24 24
25 namespace pp { 25 namespace pp {
26 namespace proxy { 26 namespace proxy {
27 27
28 namespace { 28 namespace {
29 29
30 InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher, 30 InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher,
31 const void* target_interface) { 31 const void* target_interface) {
32 return new PPB_Surface3D_Proxy(dispatcher, target_interface); 32 return new PPB_Surface3D_Proxy(dispatcher, target_interface);
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 // Surface3D ------------------------------------------------------------------- 37 // Surface3D -------------------------------------------------------------------
38 38
39 Surface3D::Surface3D(const HostResource& host_resource) 39 Surface3D::Surface3D(const HostResource& host_resource)
40 : PluginResource(host_resource), 40 : Resource(host_resource),
41 resource_(0),
42 context_(NULL), 41 context_(NULL),
43 current_flush_callback_(PP_BlockUntilComplete()) { 42 current_flush_callback_(PP_BlockUntilComplete()) {
44 } 43 }
45 44
46 Surface3D::~Surface3D() { 45 Surface3D::~Surface3D() {
47 if (context_) 46 if (context_)
48 context_->BindSurfaces(0, 0); 47 context_->BindSurfaces(0, 0);
49 } 48 }
50 49
51 PPB_Surface3D_API* Surface3D::AsPPB_Surface3D_API() { 50 PPB_Surface3D_API* Surface3D::AsPPB_Surface3D_API() {
(...skipping 20 matching lines...) Expand all
72 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. 71 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
73 72
74 if (!context_) 73 if (!context_)
75 return PP_ERROR_FAILED; 74 return PP_ERROR_FAILED;
76 75
77 current_flush_callback_ = callback; 76 current_flush_callback_ = callback;
78 77
79 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( 78 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers(
80 INTERFACE_ID_PPB_SURFACE_3D, host_resource()); 79 INTERFACE_ID_PPB_SURFACE_3D, host_resource());
81 msg->set_unblock(true); 80 msg->set_unblock(true);
82 GetDispatcher()->Send(msg); 81 PluginDispatcher::GetForResource(this)->Send(msg);
83 82
84 context_->gles2_impl()->SwapBuffers(); 83 context_->gles2_impl()->SwapBuffers();
85 return PP_OK_COMPLETIONPENDING; 84 return PP_OK_COMPLETIONPENDING;
86 } 85 }
87 86
88 void Surface3D::SwapBuffersACK(int32_t pp_error) { 87 void Surface3D::SwapBuffersACK(int32_t pp_error) {
89 PP_RunAndClearCompletionCallback(&current_flush_callback_, pp_error); 88 PP_RunAndClearCompletionCallback(&current_flush_callback_, pp_error);
90 } 89 }
91 90
92 // PPB_Surface3D_Proxy --------------------------------------------------------- 91 // PPB_Surface3D_Proxy ---------------------------------------------------------
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 129 }
131 } 130 }
132 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate. 131 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate.
133 132
134 HostResource result; 133 HostResource result;
135 dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create( 134 dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create(
136 INTERFACE_ID_PPB_SURFACE_3D, instance, config, attribs, &result)); 135 INTERFACE_ID_PPB_SURFACE_3D, instance, config, attribs, &result));
137 136
138 if (result.is_null()) 137 if (result.is_null())
139 return 0; 138 return 0;
140 scoped_refptr<Surface3D> surface_3d(new Surface3D(result)); 139 return (new Surface3D(result))->GetReference();
141 PP_Resource resource =
142 PluginResourceTracker::GetInstance()->AddResource(surface_3d);
143 surface_3d->set_resource(resource);
144 return resource;
145 } 140 }
146 141
147 bool PPB_Surface3D_Proxy::OnMessageReceived(const IPC::Message& msg) { 142 bool PPB_Surface3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
148 bool handled = true; 143 bool handled = true;
149 IPC_BEGIN_MESSAGE_MAP(PPB_Surface3D_Proxy, msg) 144 IPC_BEGIN_MESSAGE_MAP(PPB_Surface3D_Proxy, msg)
150 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_Create, 145 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_Create,
151 OnMsgCreate) 146 OnMsgCreate)
152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_SwapBuffers, 147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_SwapBuffers,
153 OnMsgSwapBuffers) 148 OnMsgSwapBuffers)
154 149
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 189
195 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( 190 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin(
196 int32_t result, 191 int32_t result,
197 const HostResource& surface_3d) { 192 const HostResource& surface_3d) {
198 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( 193 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK(
199 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); 194 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result));
200 } 195 }
201 196
202 } // namespace proxy 197 } // namespace proxy
203 } // namespace pp 198 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698