OLD | NEW |
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 "content/renderer/pepper/ppb_graphics_3d_impl.h" | 5 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 using blink::WebFrame; | 31 using blink::WebFrame; |
32 using blink::WebPluginContainer; | 32 using blink::WebPluginContainer; |
33 using blink::WebString; | 33 using blink::WebString; |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 | 36 |
37 namespace { | 37 namespace { |
38 const int32 kCommandBufferSize = 1024 * 1024; | 38 const int32 kCommandBufferSize = 1024 * 1024; |
39 const int32 kTransferBufferSize = 1024 * 1024; | 39 const int32 kTransferBufferSize = 1024 * 1024; |
40 | 40 |
41 PP_Bool ShmToHandle(base::SharedMemory* shm, | 41 PP_Bool BufferToHandle(scoped_refptr<gpu::Buffer> buffer, |
42 size_t size, | |
43 int* shm_handle, | 42 int* shm_handle, |
44 uint32_t* shm_size) { | 43 uint32_t* shm_size) { |
45 if (!shm || !shm_handle || !shm_size) | 44 if (!buffer || !shm_handle || !shm_size) |
46 return PP_FALSE; | 45 return PP_FALSE; |
47 #if defined(OS_POSIX) | 46 #if defined(OS_POSIX) |
48 *shm_handle = shm->handle().fd; | 47 *shm_handle = buffer->shared_memory()->handle().fd; |
49 #elif defined(OS_WIN) | 48 #elif defined(OS_WIN) |
50 *shm_handle = reinterpret_cast<int>(shm->handle()); | 49 *shm_handle = reinterpret_cast<int>(buffer->shared_memory()->handle()); |
51 #else | 50 #else |
52 #error "Platform not supported." | 51 #error "Platform not supported." |
53 #endif | 52 #endif |
54 *shm_size = size; | 53 *shm_size = buffer->size(); |
55 return PP_TRUE; | 54 return PP_TRUE; |
56 } | 55 } |
57 | 56 |
58 } // namespace. | 57 } // namespace. |
59 | 58 |
60 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) | 59 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) |
61 : PPB_Graphics3D_Shared(instance), | 60 : PPB_Graphics3D_Shared(instance), |
62 bound_to_instance_(false), | 61 bound_to_instance_(false), |
63 commit_pending_(false), | 62 commit_pending_(false), |
64 weak_ptr_factory_(this) { | 63 weak_ptr_factory_(this) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 120 |
122 PP_Bool PPB_Graphics3D_Impl::DestroyTransferBuffer(int32_t id) { | 121 PP_Bool PPB_Graphics3D_Impl::DestroyTransferBuffer(int32_t id) { |
123 GetCommandBuffer()->DestroyTransferBuffer(id); | 122 GetCommandBuffer()->DestroyTransferBuffer(id); |
124 return PP_TRUE; | 123 return PP_TRUE; |
125 } | 124 } |
126 | 125 |
127 PP_Bool PPB_Graphics3D_Impl::GetTransferBuffer(int32_t id, | 126 PP_Bool PPB_Graphics3D_Impl::GetTransferBuffer(int32_t id, |
128 int* shm_handle, | 127 int* shm_handle, |
129 uint32_t* shm_size) { | 128 uint32_t* shm_size) { |
130 scoped_refptr<gpu::Buffer> buffer = GetCommandBuffer()->GetTransferBuffer(id); | 129 scoped_refptr<gpu::Buffer> buffer = GetCommandBuffer()->GetTransferBuffer(id); |
131 return ShmToHandle( | 130 return BufferToHandle(buffer, shm_handle, shm_size); |
132 buffer->shared_memory(), buffer->size(), shm_handle, shm_size); | |
133 } | 131 } |
134 | 132 |
135 PP_Bool PPB_Graphics3D_Impl::Flush(int32_t put_offset) { | 133 PP_Bool PPB_Graphics3D_Impl::Flush(int32_t put_offset) { |
136 GetCommandBuffer()->Flush(put_offset); | 134 GetCommandBuffer()->Flush(put_offset); |
137 return PP_TRUE; | 135 return PP_TRUE; |
138 } | 136 } |
139 | 137 |
140 gpu::CommandBuffer::State PPB_Graphics3D_Impl::WaitForTokenInRange( | 138 gpu::CommandBuffer::State PPB_Graphics3D_Impl::WaitForTokenInRange( |
141 int32_t start, | 139 int32_t start, |
142 int32_t end) { | 140 int32_t end) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 PPP_GRAPHICS_3D_INTERFACE)); | 333 PPP_GRAPHICS_3D_INTERFACE)); |
336 // We have to check *again* that the instance exists, because it could have | 334 // We have to check *again* that the instance exists, because it could have |
337 // been deleted during GetPluginInterface(). Even the PluginModule could be | 335 // been deleted during GetPluginInterface(). Even the PluginModule could be |
338 // deleted, but in that case, the instance should also be gone, so the | 336 // deleted, but in that case, the instance should also be gone, so the |
339 // GetInstance check covers both cases. | 337 // GetInstance check covers both cases. |
340 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) | 338 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) |
341 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 339 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
342 } | 340 } |
343 | 341 |
344 } // namespace content | 342 } // namespace content |
OLD | NEW |