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 "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "webkit/plugins/ppapi/plugin_module.h" | 10 #include "webkit/plugins/ppapi/plugin_module.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 new PPB_Graphics3D_Impl(instance)); | 80 new PPB_Graphics3D_Impl(instance)); |
81 if (!graphics_3d->InitRaw(share_context, attrib_list)) | 81 if (!graphics_3d->InitRaw(share_context, attrib_list)) |
82 return 0; | 82 return 0; |
83 return graphics_3d->GetReference(); | 83 return graphics_3d->GetReference(); |
84 } | 84 } |
85 | 85 |
86 PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { | 86 PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { |
87 return this; | 87 return this; |
88 } | 88 } |
89 | 89 |
90 PP_Bool PPB_Graphics3D_Impl::InitCommandBuffer() { | 90 PP_Bool PPB_Graphics3D_Impl::InitCommandBuffer(int32_t size) { |
91 return PP_FromBool(GetCommandBuffer()->Initialize()); | 91 return PP_FromBool(GetCommandBuffer()->Initialize(size)); |
92 } | 92 } |
93 | 93 |
94 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { | 94 PP_Bool PPB_Graphics3D_Impl::GetRingBuffer(int* shm_handle, |
95 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); | 95 uint32_t* shm_size) { |
96 return PP_TRUE; | 96 gpu::Buffer buffer = GetCommandBuffer()->GetRingBuffer(); |
| 97 return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size); |
97 } | 98 } |
98 | 99 |
99 PP_Graphics3DTrustedState PPB_Graphics3D_Impl::GetState() { | 100 PP_Graphics3DTrustedState PPB_Graphics3D_Impl::GetState() { |
100 return PPStateFromGPUState(GetCommandBuffer()->GetState()); | 101 return PPStateFromGPUState(GetCommandBuffer()->GetState()); |
101 } | 102 } |
102 | 103 |
103 int32_t PPB_Graphics3D_Impl::CreateTransferBuffer(uint32_t size) { | 104 int32_t PPB_Graphics3D_Impl::CreateTransferBuffer(uint32_t size) { |
104 return GetCommandBuffer()->CreateTransferBuffer(size, -1); | 105 return GetCommandBuffer()->CreateTransferBuffer(size, -1); |
105 } | 106 } |
106 | 107 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 184 |
184 return PP_OK_COMPLETIONPENDING; | 185 return PP_OK_COMPLETIONPENDING; |
185 } | 186 } |
186 | 187 |
187 bool PPB_Graphics3D_Impl::Init(PP_Resource share_context, | 188 bool PPB_Graphics3D_Impl::Init(PP_Resource share_context, |
188 const int32_t* attrib_list) { | 189 const int32_t* attrib_list) { |
189 if (!InitRaw(share_context, attrib_list)) | 190 if (!InitRaw(share_context, attrib_list)) |
190 return false; | 191 return false; |
191 | 192 |
192 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); | 193 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); |
193 if (!command_buffer->Initialize()) | 194 if (!command_buffer->Initialize(kCommandBufferSize)) |
194 return false; | 195 return false; |
195 | 196 |
196 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); | 197 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); |
197 } | 198 } |
198 | 199 |
199 bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context, | 200 bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context, |
200 const int32_t* attrib_list) { | 201 const int32_t* attrib_list) { |
201 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 202 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
202 if (!plugin_instance) | 203 if (!plugin_instance) |
203 return false; | 204 return false; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const PPP_Graphics3D* ppp_graphics_3d = | 253 const PPP_Graphics3D* ppp_graphics_3d = |
253 static_cast<const PPP_Graphics3D*>( | 254 static_cast<const PPP_Graphics3D*>( |
254 instance->module()->GetPluginInterface( | 255 instance->module()->GetPluginInterface( |
255 PPP_GRAPHICS_3D_INTERFACE)); | 256 PPP_GRAPHICS_3D_INTERFACE)); |
256 if (ppp_graphics_3d) | 257 if (ppp_graphics_3d) |
257 ppp_graphics_3d->Graphics3DContextLost(pp_instance()); | 258 ppp_graphics_3d->Graphics3DContextLost(pp_instance()); |
258 } | 259 } |
259 | 260 |
260 } // namespace ppapi | 261 } // namespace ppapi |
261 } // namespace webkit | 262 } // namespace webkit |
OLD | NEW |