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

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

Issue 10386145: Add the necessary plumbing mechanisms to ensure proper WebGL support inside the <browser> tag, whic… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nits picked Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_graphics_3d_proxy.h" 5 #include "ppapi/proxy/ppb_graphics_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/proxy/enter_proxy.h" 9 #include "ppapi/proxy/enter_proxy.h"
10 #include "ppapi/proxy/plugin_dispatcher.h" 10 #include "ppapi/proxy/plugin_dispatcher.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } // namespace 62 } // namespace
63 63
64 Graphics3D::Graphics3D(const HostResource& resource) 64 Graphics3D::Graphics3D(const HostResource& resource)
65 : PPB_Graphics3D_Shared(resource) { 65 : PPB_Graphics3D_Shared(resource) {
66 } 66 }
67 67
68 Graphics3D::~Graphics3D() { 68 Graphics3D::~Graphics3D() {
69 DestroyGLES2Impl(); 69 DestroyGLES2Impl();
70 } 70 }
71 71
72 bool Graphics3D::Init() { 72 bool Graphics3D::Init(gpu::gles2::GLES2Implementation *share_gles2) {
brettw 2012/05/25 23:19:41 Nit: * next to type rather than arg name
73 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); 73 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
74 if (!dispatcher) 74 if (!dispatcher)
75 return false; 75 return false;
76 76
77 command_buffer_.reset( 77 command_buffer_.reset(
78 new PpapiCommandBufferProxy(host_resource(), dispatcher)); 78 new PpapiCommandBufferProxy(host_resource(), dispatcher));
79 if (!command_buffer_->Initialize()) 79 if (!command_buffer_->Initialize())
80 return false; 80 return false;
81 81
82 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); 82 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize,
83 share_gles2);
83 } 84 }
84 85
85 PP_Bool Graphics3D::InitCommandBuffer() { 86 PP_Bool Graphics3D::InitCommandBuffer() {
86 return PP_FALSE; 87 return PP_FALSE;
87 } 88 }
88 89
89 PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) { 90 PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) {
90 return PP_FALSE; 91 return PP_FALSE;
91 } 92 }
92 93
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 : InterfaceProxy(dispatcher), 140 : InterfaceProxy(dispatcher),
140 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 141 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
141 } 142 }
142 143
143 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { 144 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() {
144 } 145 }
145 146
146 // static 147 // static
147 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( 148 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
148 PP_Instance instance, 149 PP_Instance instance,
149 PP_Resource share_context, 150 PPB_Graphics3D_API* share_context,
150 const int32_t* attrib_list) { 151 const int32_t* attrib_list) {
151 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 152 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
153 Graphics3D* share_graphics = static_cast<Graphics3D*>(share_context);
152 if (!dispatcher) 154 if (!dispatcher)
153 return PP_ERROR_BADARGUMENT; 155 return PP_ERROR_BADARGUMENT;
154 156
155 // TODO(alokp): Support shared context. 157 HostResource share_host;
156 DCHECK_EQ(0, share_context); 158 gpu::gles2::GLES2Implementation* share_gles2 = NULL;
157 if (share_context != 0) 159 if (share_context) {
158 return 0; 160 share_host = share_graphics->host_resource();
161 share_gles2 = share_graphics->gles2_impl();
162 }
159 163
160 std::vector<int32_t> attribs; 164 std::vector<int32_t> attribs;
161 if (attrib_list) { 165 if (attrib_list) {
162 for (const int32_t* attr = attrib_list; 166 for (const int32_t* attr = attrib_list;
163 attr[0] != PP_GRAPHICS3DATTRIB_NONE; 167 attr[0] != PP_GRAPHICS3DATTRIB_NONE;
164 attr += 2) { 168 attr += 2) {
165 attribs.push_back(attr[0]); 169 attribs.push_back(attr[0]);
166 attribs.push_back(attr[1]); 170 attribs.push_back(attr[1]);
167 } 171 }
168 } 172 }
169 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); 173 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
170 174
171 HostResource result; 175 HostResource result;
172 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( 176 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(
173 API_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); 177 API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result));
174 if (result.is_null()) 178 if (result.is_null())
175 return 0; 179 return 0;
176 180
177 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); 181 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result));
178 if (!graphics_3d->Init()) 182 if (!graphics_3d->Init(share_gles2))
179 return 0; 183 return 0;
180 return graphics_3d->GetReference(); 184 return graphics_3d->GetReference();
181 } 185 }
182 186
183 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { 187 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
184 bool handled = true; 188 bool handled = true;
185 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) 189 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg)
186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, 190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create,
187 OnMsgCreate) 191 OnMsgCreate)
188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, 192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
(...skipping 18 matching lines...) Expand all
207 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, 211 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK,
208 OnMsgSwapBuffersACK) 212 OnMsgSwapBuffersACK)
209 IPC_MESSAGE_UNHANDLED(handled = false) 213 IPC_MESSAGE_UNHANDLED(handled = false)
210 214
211 IPC_END_MESSAGE_MAP() 215 IPC_END_MESSAGE_MAP()
212 // FIXME(brettw) handle bad messages! 216 // FIXME(brettw) handle bad messages!
213 return handled; 217 return handled;
214 } 218 }
215 219
216 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, 220 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance,
221 HostResource share_context,
217 const std::vector<int32_t>& attribs, 222 const std::vector<int32_t>& attribs,
218 HostResource* result) { 223 HostResource* result) {
219 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) 224 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE)
220 return; // Bad message. 225 return; // Bad message.
221 226
222 thunk::EnterResourceCreation enter(instance); 227 thunk::EnterResourceCreation enter(instance);
228 PPB_Graphics3D_API *share_api = NULL;
229 if (share_context.host_resource() != 0) {
230 thunk::EnterResource<thunk::PPB_Graphics3D_API>
231 enter_share(share_context.host_resource(), true);
232 if (!enter_share.succeeded())
233 return;
234 share_api = enter_share.object();
235 }
236
223 if (enter.succeeded()) { 237 if (enter.succeeded()) {
224 result->SetHostResource( 238 result->SetHostResource(
225 instance, 239 instance,
226 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); 240 enter.functions()->CreateGraphics3DRaw(instance,
241 share_api,
242 &attribs.front()));
227 } 243 }
228 } 244 }
229 245
230 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( 246 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer(
231 const HostResource& context) { 247 const HostResource& context) {
232 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 248 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
233 if (enter.failed()) 249 if (enter.failed())
234 return; 250 return;
235 251
236 if (!enter.object()->InitCommandBuffer()) 252 if (!enter.object()->InitCommandBuffer())
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( 352 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
337 int32_t result, 353 int32_t result,
338 const HostResource& context) { 354 const HostResource& context) {
339 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( 355 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
340 API_ID_PPB_GRAPHICS_3D, context, result)); 356 API_ID_PPB_GRAPHICS_3D, context, result));
341 } 357 }
342 358
343 } // namespace proxy 359 } // namespace proxy
344 } // namespace ppapi 360 } // namespace ppapi
345 361
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698