[email protected] | aaa11b3 | 2012-03-08 12:30:13 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
| 6 | |
| 7 | #include "gpu/command_buffer/client/gles2_implementation.h" |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 8 | #include "gpu/command_buffer/common/command_buffer.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 9 | #include "ppapi/c/pp_errors.h" |
| 10 | #include "ppapi/proxy/enter_proxy.h" |
| 11 | #include "ppapi/proxy/plugin_dispatcher.h" |
[email protected] | aaa11b3 | 2012-03-08 12:30:13 | [diff] [blame] | 12 | #include "ppapi/proxy/ppapi_command_buffer_proxy.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 13 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 14 | #include "ppapi/shared_impl/ppapi_globals.h" |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 15 | #include "ppapi/thunk/enter.h" |
| 16 | #include "ppapi/thunk/resource_creation_api.h" |
| 17 | #include "ppapi/thunk/thunk.h" |
| 18 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 19 | using ppapi::thunk::EnterResourceNoLock; |
| 20 | using ppapi::thunk::PPB_Graphics3D_API; |
| 21 | using ppapi::thunk::ResourceCreationAPI; |
| 22 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 23 | namespace ppapi { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 24 | namespace proxy { |
| 25 | |
| 26 | namespace { |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 27 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 28 | const int32 kCommandBufferSize = 1024 * 1024; |
| 29 | const int32 kTransferBufferSize = 1024 * 1024; |
| 30 | |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 31 | base::SharedMemoryHandle TransportSHMHandle(Dispatcher* dispatcher, |
| 32 | base::SharedMemory* shm) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 33 | base::PlatformFile source = |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 34 | IPC::PlatformFileForTransitToPlatformFile(shm->handle()); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 35 | // Don't close the handle, it doesn't belong to us. |
| 36 | return dispatcher->ShareHandleWithRemote(source, false); |
| 37 | } |
| 38 | |
[email protected] | 914f526 | 2013-06-01 00:17:22 | [diff] [blame] | 39 | gpu::CommandBuffer::State GetErrorState() { |
| 40 | gpu::CommandBuffer::State error_state; |
| 41 | error_state.error = gpu::error::kGenericError; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 42 | return error_state; |
| 43 | } |
| 44 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 45 | } // namespace |
| 46 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 47 | Graphics3D::Graphics3D(const HostResource& resource) |
[email protected] | 4e46a73 | 2013-09-30 18:35:59 | [diff] [blame] | 48 | : PPB_Graphics3D_Shared(resource) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | Graphics3D::~Graphics3D() { |
[email protected] | edccb56 | 2013-10-02 00:01:20 | [diff] [blame] | 52 | DestroyGLES2Impl(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 53 | } |
| 54 | |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 55 | bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2) { |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 56 | PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 57 | if (!dispatcher) |
| 58 | return false; |
| 59 | |
[email protected] | aaa11b3 | 2012-03-08 12:30:13 | [diff] [blame] | 60 | command_buffer_.reset( |
| 61 | new PpapiCommandBufferProxy(host_resource(), dispatcher)); |
[email protected] | 84b44c55 | 2012-10-15 20:58:17 | [diff] [blame] | 62 | |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 63 | return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, |
| 64 | share_gles2); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 65 | } |
| 66 | |
[email protected] | 503b3a2 | 2011-12-12 23:29:40 | [diff] [blame] | 67 | PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 68 | return PP_FALSE; |
| 69 | } |
| 70 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 71 | PP_Bool Graphics3D::Flush(int32_t put_offset) { |
| 72 | return PP_FALSE; |
| 73 | } |
| 74 | |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 75 | scoped_refptr<gpu::Buffer> Graphics3D::CreateTransferBuffer( |
| 76 | uint32_t size, |
| 77 | int32_t* id) { |
| 78 | *id = -1; |
| 79 | return NULL; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) { |
| 83 | return PP_FALSE; |
| 84 | } |
| 85 | |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 86 | gpu::CommandBuffer::State Graphics3D::WaitForTokenInRange(int32_t start, |
| 87 | int32_t end) { |
| 88 | return GetErrorState(); |
| 89 | } |
| 90 | |
| 91 | gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(int32_t start, |
| 92 | int32_t end) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 93 | return GetErrorState(); |
| 94 | } |
| 95 | |
[email protected] | b096d03 | 2013-03-08 03:08:01 | [diff] [blame] | 96 | uint32_t Graphics3D::InsertSyncPoint() { |
| 97 | NOTREACHED(); |
| 98 | return 0; |
| 99 | } |
| 100 | |
[email protected] | 7035bc9 | 2014-07-01 00:27:22 | [diff] [blame^] | 101 | uint32_t Graphics3D::InsertFutureSyncPoint() { |
| 102 | NOTREACHED(); |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | void Graphics3D::RetireSyncPoint(uint32_t sync_point) { |
| 107 | NOTREACHED(); |
| 108 | } |
| 109 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 110 | gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { |
[email protected] | 4e46a73 | 2013-09-30 18:35:59 | [diff] [blame] | 111 | return command_buffer_.get(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 112 | } |
| 113 | |
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 114 | gpu::GpuControl* Graphics3D::GetGpuControl() { |
| 115 | return command_buffer_.get(); |
| 116 | } |
| 117 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 118 | int32 Graphics3D::DoSwapBuffers() { |
[email protected] | 561438abd | 2011-11-24 01:06:23 | [diff] [blame] | 119 | gles2_impl()->SwapBuffers(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 120 | IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 121 | API_ID_PPB_GRAPHICS_3D, host_resource()); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 122 | msg->set_unblock(true); |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 123 | PluginDispatcher::GetForResource(this)->Send(msg); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 124 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 125 | return PP_OK_COMPLETIONPENDING; |
| 126 | } |
| 127 | |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 128 | PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) |
| 129 | : InterfaceProxy(dispatcher), |
[email protected] | a2f53dc | 2013-04-30 01:06:35 | [diff] [blame] | 130 | callback_factory_(this) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { |
| 134 | } |
| 135 | |
| 136 | // static |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 137 | PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( |
| 138 | PP_Instance instance, |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 139 | PP_Resource share_context, |
| 140 | const int32_t* attrib_list) { |
| 141 | PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 142 | if (!dispatcher) |
| 143 | return PP_ERROR_BADARGUMENT; |
| 144 | |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 145 | HostResource share_host; |
| 146 | gpu::gles2::GLES2Implementation* share_gles2 = NULL; |
| 147 | if (share_context != 0) { |
| 148 | EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true); |
| 149 | if (enter.failed()) |
| 150 | return PP_ERROR_BADARGUMENT; |
| 151 | |
| 152 | PPB_Graphics3D_Shared* share_graphics = |
| 153 | static_cast<PPB_Graphics3D_Shared*>(enter.object()); |
| 154 | share_host = share_graphics->host_resource(); |
| 155 | share_gles2 = share_graphics->gles2_impl(); |
| 156 | } |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 157 | |
| 158 | std::vector<int32_t> attribs; |
| 159 | if (attrib_list) { |
| 160 | for (const int32_t* attr = attrib_list; |
[email protected] | 0e50fc4d | 2011-08-01 15:33:51 | [diff] [blame] | 161 | attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
| 162 | attr += 2) { |
| 163 | attribs.push_back(attr[0]); |
| 164 | attribs.push_back(attr[1]); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 165 | } |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 166 | } |
[email protected] | 0e50fc4d | 2011-08-01 15:33:51 | [diff] [blame] | 167 | attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 168 | |
| 169 | HostResource result; |
| 170 | dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 171 | API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result)); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 172 | if (result.is_null()) |
| 173 | return 0; |
| 174 | |
[email protected] | 51e1aec | 2011-08-11 04:48:30 | [diff] [blame] | 175 | scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 176 | if (!graphics_3d->Init(share_gles2)) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 177 | return 0; |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 178 | return graphics_3d->GetReference(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 182 | bool handled = true; |
| 183 | IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 184 | #if !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 185 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, |
| 186 | OnMsgCreate) |
[email protected] | 503b3a2 | 2011-12-12 23:29:40 | [diff] [blame] | 187 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, |
| 188 | OnMsgSetGetBuffer) |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 189 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange, |
| 190 | OnMsgWaitForTokenInRange) |
| 191 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange, |
| 192 | OnMsgWaitForGetOffsetInRange) |
| 193 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 194 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, |
| 195 | OnMsgCreateTransferBuffer) |
| 196 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, |
| 197 | OnMsgDestroyTransferBuffer) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 198 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, |
| 199 | OnMsgSwapBuffers) |
[email protected] | b096d03 | 2013-03-08 03:08:01 | [diff] [blame] | 200 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint, |
| 201 | OnMsgInsertSyncPoint) |
[email protected] | 7035bc9 | 2014-07-01 00:27:22 | [diff] [blame^] | 202 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertFutureSyncPoint, |
| 203 | OnMsgInsertFutureSyncPoint) |
| 204 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_RetireSyncPoint, |
| 205 | OnMsgRetireSyncPoint) |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 206 | #endif // !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 207 | |
| 208 | IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
| 209 | OnMsgSwapBuffersACK) |
| 210 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 211 | |
| 212 | IPC_END_MESSAGE_MAP() |
| 213 | // FIXME(brettw) handle bad messages! |
| 214 | return handled; |
| 215 | } |
| 216 | |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 217 | #if !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 218 | void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 219 | HostResource share_context, |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 220 | const std::vector<int32_t>& attribs, |
| 221 | HostResource* result) { |
[email protected] | 48c1db7 | 2012-12-17 20:56:11 | [diff] [blame] | 222 | if (attribs.empty() || |
| 223 | attribs.back() != PP_GRAPHICS3DATTRIB_NONE || |
| 224 | !(attribs.size() & 1)) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 225 | return; // Bad message. |
| 226 | |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 227 | thunk::EnterResourceCreation enter(instance); |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 228 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 229 | if (enter.succeeded()) { |
| 230 | result->SetHostResource( |
[email protected] | 9ed07f8 | 2012-05-29 21:54:55 | [diff] [blame] | 231 | instance, |
| 232 | enter.functions()->CreateGraphics3DRaw(instance, |
| 233 | share_context.host_resource(), |
| 234 | &attribs.front())); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
[email protected] | 503b3a2 | 2011-12-12 23:29:40 | [diff] [blame] | 238 | void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer( |
| 239 | const HostResource& context, |
| 240 | int32 transfer_buffer_id) { |
| 241 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 242 | if (enter.succeeded()) |
| 243 | enter.object()->SetGetBuffer(transfer_buffer_id); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 246 | void PPB_Graphics3D_Proxy::OnMsgWaitForTokenInRange( |
| 247 | const HostResource& context, |
| 248 | int32 start, |
| 249 | int32 end, |
| 250 | gpu::CommandBuffer::State* state, |
| 251 | bool* success) { |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 252 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
[email protected] | 571b35e8 | 2012-05-19 00:04:35 | [diff] [blame] | 253 | if (enter.failed()) { |
| 254 | *success = false; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 255 | return; |
[email protected] | 571b35e8 | 2012-05-19 00:04:35 | [diff] [blame] | 256 | } |
[email protected] | 7fe4198b | 2014-03-18 21:52:36 | [diff] [blame] | 257 | *state = enter.object()->WaitForTokenInRange(start, end); |
| 258 | *success = true; |
| 259 | } |
| 260 | |
| 261 | void PPB_Graphics3D_Proxy::OnMsgWaitForGetOffsetInRange( |
| 262 | const HostResource& context, |
| 263 | int32 start, |
| 264 | int32 end, |
| 265 | gpu::CommandBuffer::State* state, |
| 266 | bool* success) { |
| 267 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 268 | if (enter.failed()) { |
| 269 | *success = false; |
| 270 | return; |
| 271 | } |
| 272 | *state = enter.object()->WaitForGetOffsetInRange(start, end); |
[email protected] | 571b35e8 | 2012-05-19 00:04:35 | [diff] [blame] | 273 | *success = true; |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context, |
| 277 | int32 put_offset) { |
| 278 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 279 | if (enter.succeeded()) |
| 280 | enter.object()->Flush(put_offset); |
| 281 | } |
| 282 | |
| 283 | void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer( |
| 284 | const HostResource& context, |
[email protected] | b31199e | 2012-12-12 00:48:29 | [diff] [blame] | 285 | uint32 size, |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 286 | int32* id, |
| 287 | ppapi::proxy::SerializedHandle* transfer_buffer) { |
| 288 | transfer_buffer->set_null_shmem(); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 289 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 290 | if (enter.succeeded()) { |
| 291 | scoped_refptr<gpu::Buffer> buffer = |
| 292 | enter.object()->CreateTransferBuffer(size, id); |
| 293 | if (!buffer) |
| 294 | return; |
[email protected] | 8a978df | 2014-04-02 23:54:09 | [diff] [blame] | 295 | gpu::SharedMemoryBufferBacking* backing = |
| 296 | static_cast<gpu::SharedMemoryBufferBacking*>(buffer->backing()); |
| 297 | DCHECK(backing && backing->shared_memory()); |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 298 | transfer_buffer->set_shmem( |
[email protected] | 8a978df | 2014-04-02 23:54:09 | [diff] [blame] | 299 | TransportSHMHandle(dispatcher(), backing->shared_memory()), |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 300 | buffer->size()); |
| 301 | } else { |
[email protected] | 67c8078 | 2012-12-21 01:16:52 | [diff] [blame] | 302 | *id = -1; |
[email protected] | 046fa1ac | 2014-04-01 09:06:43 | [diff] [blame] | 303 | } |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( |
| 307 | const HostResource& context, |
| 308 | int32 id) { |
| 309 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 310 | if (enter.succeeded()) |
| 311 | enter.object()->DestroyTransferBuffer(id); |
| 312 | } |
| 313 | |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 314 | void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { |
[email protected] | 79d23c7 | 2011-08-08 19:40:40 | [diff] [blame] | 315 | EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
| 316 | context, callback_factory_, |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 317 | &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 318 | if (enter.succeeded()) |
[email protected] | 79d23c7 | 2011-08-08 19:40:40 | [diff] [blame] | 319 | enter.SetResult(enter.object()->SwapBuffers(enter.callback())); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 320 | } |
[email protected] | b096d03 | 2013-03-08 03:08:01 | [diff] [blame] | 321 | |
| 322 | void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context, |
| 323 | uint32* sync_point) { |
| 324 | *sync_point = 0; |
| 325 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 326 | if (enter.succeeded()) |
| 327 | *sync_point = enter.object()->InsertSyncPoint(); |
| 328 | } |
[email protected] | 7035bc9 | 2014-07-01 00:27:22 | [diff] [blame^] | 329 | |
| 330 | void PPB_Graphics3D_Proxy::OnMsgInsertFutureSyncPoint( |
| 331 | const HostResource& context, |
| 332 | uint32* sync_point) { |
| 333 | *sync_point = 0; |
| 334 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 335 | if (enter.succeeded()) |
| 336 | *sync_point = enter.object()->InsertFutureSyncPoint(); |
| 337 | } |
| 338 | |
| 339 | void PPB_Graphics3D_Proxy::OnMsgRetireSyncPoint(const HostResource& context, |
| 340 | uint32 sync_point) { |
| 341 | EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 342 | if (enter.succeeded()) |
| 343 | enter.object()->RetireSyncPoint(sync_point); |
| 344 | } |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 345 | #endif // !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 346 | |
| 347 | void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, |
| 348 | int32_t pp_error) { |
| 349 | EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); |
| 350 | if (enter.succeeded()) |
| 351 | static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); |
| 352 | } |
| 353 | |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 354 | #if !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 355 | void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
| 356 | int32_t result, |
| 357 | const HostResource& context) { |
| 358 | dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 359 | API_ID_PPB_GRAPHICS_3D, context, result)); |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 360 | } |
[email protected] | 11494c5c | 2012-11-13 02:50:57 | [diff] [blame] | 361 | #endif // !defined(OS_NACL) |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 362 | |
| 363 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 364 | } // namespace ppapi |
[email protected] | eeb4e4a | 2011-07-19 16:22:06 | [diff] [blame] | 365 | |