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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 106 |
107 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { | 107 PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { |
108 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); | 108 GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); |
109 return PP_TRUE; | 109 return PP_TRUE; |
110 } | 110 } |
111 | 111 |
112 gpu::CommandBuffer::State PPB_Graphics3D_Impl::GetState() { | 112 gpu::CommandBuffer::State PPB_Graphics3D_Impl::GetState() { |
113 return GetCommandBuffer()->GetState(); | 113 return GetCommandBuffer()->GetState(); |
114 } | 114 } |
115 | 115 |
116 int32_t PPB_Graphics3D_Impl::CreateTransferBuffer(uint32_t size) { | 116 int32_t PPB_Graphics3D_Impl::CreateTransferBuffer(uint32_t size, |
117 int* shm_handle, | |
118 uint32_t* shm_size) { | |
117 int32_t id = -1; | 119 int32_t id = -1; |
118 GetCommandBuffer()->CreateTransferBuffer(size, &id); | 120 scoped_refptr<gpu::Buffer> buffer = |
121 GetCommandBuffer()->CreateTransferBuffer(size, &id); | |
122 if (id < 0) | |
no sievers
2014/03/28 21:01:03
Why not 'if (!buffer) return id'?
piman
2014/03/28 23:23:40
Either way, doesn't matter. Either buffer is set a
| |
123 return id; | |
124 DCHECK(buffer); | |
125 PP_Bool result = ShmToHandle( | |
126 buffer->shared_memory(), buffer->size(), shm_handle, shm_size); | |
127 DCHECK(result); | |
119 return id; | 128 return id; |
120 } | 129 } |
121 | 130 |
122 PP_Bool PPB_Graphics3D_Impl::DestroyTransferBuffer(int32_t id) { | 131 PP_Bool PPB_Graphics3D_Impl::DestroyTransferBuffer(int32_t id) { |
123 GetCommandBuffer()->DestroyTransferBuffer(id); | 132 GetCommandBuffer()->DestroyTransferBuffer(id); |
124 return PP_TRUE; | 133 return PP_TRUE; |
125 } | 134 } |
126 | 135 |
127 PP_Bool PPB_Graphics3D_Impl::GetTransferBuffer(int32_t id, | |
128 int* shm_handle, | |
129 uint32_t* shm_size) { | |
130 scoped_refptr<gpu::Buffer> buffer = GetCommandBuffer()->GetTransferBuffer(id); | |
131 return ShmToHandle( | |
132 buffer->shared_memory(), buffer->size(), shm_handle, shm_size); | |
133 } | |
134 | |
135 PP_Bool PPB_Graphics3D_Impl::Flush(int32_t put_offset) { | 136 PP_Bool PPB_Graphics3D_Impl::Flush(int32_t put_offset) { |
136 GetCommandBuffer()->Flush(put_offset); | 137 GetCommandBuffer()->Flush(put_offset); |
137 return PP_TRUE; | 138 return PP_TRUE; |
138 } | 139 } |
139 | 140 |
140 gpu::CommandBuffer::State PPB_Graphics3D_Impl::WaitForTokenInRange( | 141 gpu::CommandBuffer::State PPB_Graphics3D_Impl::WaitForTokenInRange( |
141 int32_t start, | 142 int32_t start, |
142 int32_t end) { | 143 int32_t end) { |
143 GetCommandBuffer()->WaitForTokenInRange(start, end); | 144 GetCommandBuffer()->WaitForTokenInRange(start, end); |
144 return GetCommandBuffer()->GetLastState(); | 145 return GetCommandBuffer()->GetLastState(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 PPP_GRAPHICS_3D_INTERFACE)); | 336 PPP_GRAPHICS_3D_INTERFACE)); |
336 // We have to check *again* that the instance exists, because it could have | 337 // We have to check *again* that the instance exists, because it could have |
337 // been deleted during GetPluginInterface(). Even the PluginModule could be | 338 // been deleted during GetPluginInterface(). Even the PluginModule could be |
338 // deleted, but in that case, the instance should also be gone, so the | 339 // deleted, but in that case, the instance should also be gone, so the |
339 // GetInstance check covers both cases. | 340 // GetInstance check covers both cases. |
340 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) | 341 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) |
341 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 342 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
342 } | 343 } |
343 | 344 |
344 } // namespace content | 345 } // namespace content |
OLD | NEW |