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