| OLD | NEW |
| 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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 if (is_flush_pending()) | 67 if (is_flush_pending()) |
| 68 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. | 68 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. |
| 69 | 69 |
| 70 if (!context_) | 70 if (!context_) |
| 71 return PP_ERROR_FAILED; | 71 return PP_ERROR_FAILED; |
| 72 | 72 |
| 73 current_flush_callback_ = callback; | 73 current_flush_callback_ = callback; |
| 74 | 74 |
| 75 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( | 75 IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( |
| 76 INTERFACE_ID_PPB_SURFACE_3D, host_resource()); | 76 API_ID_PPB_SURFACE_3D, host_resource()); |
| 77 msg->set_unblock(true); | 77 msg->set_unblock(true); |
| 78 PluginDispatcher::GetForResource(this)->Send(msg); | 78 PluginDispatcher::GetForResource(this)->Send(msg); |
| 79 | 79 |
| 80 context_->gles2_impl()->SwapBuffers(); | 80 context_->gles2_impl()->SwapBuffers(); |
| 81 return PP_OK_COMPLETIONPENDING; | 81 return PP_OK_COMPLETIONPENDING; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void Surface3D::SwapBuffersACK(int32_t pp_error) { | 84 void Surface3D::SwapBuffersACK(int32_t pp_error) { |
| 85 PP_RunAndClearCompletionCallback(¤t_flush_callback_, pp_error); | 85 PP_RunAndClearCompletionCallback(¤t_flush_callback_, pp_error); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // PPB_Surface3D_Proxy --------------------------------------------------------- | 88 // PPB_Surface3D_Proxy --------------------------------------------------------- |
| 89 | 89 |
| 90 PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher) | 90 PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher) |
| 91 : InterfaceProxy(dispatcher), | 91 : InterfaceProxy(dispatcher), |
| 92 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 92 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 93 } | 93 } |
| 94 | 94 |
| 95 PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { | 95 PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { |
| 96 } | 96 } |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { | 99 const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { |
| 100 static const Info info = { | 100 static const Info info = { |
| 101 thunk::GetPPB_Surface3D_Dev_Thunk(), | 101 thunk::GetPPB_Surface3D_Dev_Thunk(), |
| 102 PPB_SURFACE_3D_DEV_INTERFACE, | 102 PPB_SURFACE_3D_DEV_INTERFACE, |
| 103 INTERFACE_ID_PPB_SURFACE_3D, | 103 API_ID_PPB_SURFACE_3D, |
| 104 false, | 104 false, |
| 105 &CreateSurface3DProxy, | 105 &CreateSurface3DProxy, |
| 106 }; | 106 }; |
| 107 return &info; | 107 return &info; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // static | 110 // static |
| 111 PP_Resource PPB_Surface3D_Proxy::CreateProxyResource( | 111 PP_Resource PPB_Surface3D_Proxy::CreateProxyResource( |
| 112 PP_Instance instance, | 112 PP_Instance instance, |
| 113 PP_Config3D_Dev config, | 113 PP_Config3D_Dev config, |
| 114 const int32_t* attrib_list) { | 114 const int32_t* attrib_list) { |
| 115 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 115 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 116 if (!dispatcher) | 116 if (!dispatcher) |
| 117 return PP_ERROR_BADARGUMENT; | 117 return PP_ERROR_BADARGUMENT; |
| 118 | 118 |
| 119 std::vector<int32_t> attribs; | 119 std::vector<int32_t> attribs; |
| 120 if (attrib_list) { | 120 if (attrib_list) { |
| 121 const int32_t* attr = attrib_list; | 121 const int32_t* attr = attrib_list; |
| 122 while(*attr != PP_GRAPHICS3DATTRIB_NONE) { | 122 while(*attr != PP_GRAPHICS3DATTRIB_NONE) { |
| 123 attribs.push_back(*(attr++)); // Attribute. | 123 attribs.push_back(*(attr++)); // Attribute. |
| 124 attribs.push_back(*(attr++)); // Value. | 124 attribs.push_back(*(attr++)); // Value. |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate. | 127 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate. |
| 128 | 128 |
| 129 HostResource result; | 129 HostResource result; |
| 130 dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create( | 130 dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create( |
| 131 INTERFACE_ID_PPB_SURFACE_3D, instance, config, attribs, &result)); | 131 API_ID_PPB_SURFACE_3D, instance, config, attribs, &result)); |
| 132 | 132 |
| 133 if (result.is_null()) | 133 if (result.is_null()) |
| 134 return 0; | 134 return 0; |
| 135 return (new Surface3D(result))->GetReference(); | 135 return (new Surface3D(result))->GetReference(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool PPB_Surface3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 138 bool PPB_Surface3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 139 bool handled = true; | 139 bool handled = true; |
| 140 IPC_BEGIN_MESSAGE_MAP(PPB_Surface3D_Proxy, msg) | 140 IPC_BEGIN_MESSAGE_MAP(PPB_Surface3D_Proxy, msg) |
| 141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_Create, | 141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBSurface3D_Create, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 int32_t pp_error) { | 180 int32_t pp_error) { |
| 181 EnterPluginFromHostResource<PPB_Surface3D_API> enter(resource); | 181 EnterPluginFromHostResource<PPB_Surface3D_API> enter(resource); |
| 182 if (enter.succeeded()) | 182 if (enter.succeeded()) |
| 183 static_cast<Surface3D*>(enter.object())->SwapBuffersACK(pp_error); | 183 static_cast<Surface3D*>(enter.object())->SwapBuffersACK(pp_error); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( | 186 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( |
| 187 int32_t result, | 187 int32_t result, |
| 188 const HostResource& surface_3d) { | 188 const HostResource& surface_3d) { |
| 189 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( | 189 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( |
| 190 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); | 190 API_ID_PPB_SURFACE_3D, surface_3d, result)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace proxy | 193 } // namespace proxy |
| 194 } // namespace ppapi | 194 } // namespace ppapi |
| OLD | NEW |