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/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 using ppapi::thunk::PPB_Graphics3D_API; | 34 using ppapi::thunk::PPB_Graphics3D_API; |
35 using blink::WebConsoleMessage; | 35 using blink::WebConsoleMessage; |
36 using blink::WebLocalFrame; | 36 using blink::WebLocalFrame; |
37 using blink::WebPluginContainer; | 37 using blink::WebPluginContainer; |
38 using blink::WebString; | 38 using blink::WebString; |
39 | 39 |
40 namespace content { | 40 namespace content { |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 const int32 kCommandBufferSize = 1024 * 1024; | 44 const int32_t kCommandBufferSize = 1024 * 1024; |
45 const int32 kTransferBufferSize = 1024 * 1024; | 45 const int32_t kTransferBufferSize = 1024 * 1024; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) | 49 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) |
50 : PPB_Graphics3D_Shared(instance), | 50 : PPB_Graphics3D_Shared(instance), |
51 bound_to_instance_(false), | 51 bound_to_instance_(false), |
52 commit_pending_(false), | 52 commit_pending_(false), |
53 sync_point_(0), | 53 sync_point_(0), |
54 has_alpha_(false), | 54 has_alpha_(false), |
55 weak_ptr_factory_(this) {} | 55 weak_ptr_factory_(this) {} |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { | 166 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { |
167 return command_buffer_.get(); | 167 return command_buffer_.get(); |
168 } | 168 } |
169 | 169 |
170 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { | 170 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { |
171 return command_buffer_.get(); | 171 return command_buffer_.get(); |
172 } | 172 } |
173 | 173 |
174 int32 PPB_Graphics3D_Impl::DoSwapBuffers() { | 174 int32_t PPB_Graphics3D_Impl::DoSwapBuffers() { |
175 DCHECK(command_buffer_); | 175 DCHECK(command_buffer_); |
176 // We do not have a GLES2 implementation when using an OOP proxy. | 176 // We do not have a GLES2 implementation when using an OOP proxy. |
177 // The plugin-side proxy is responsible for adding the SwapBuffers command | 177 // The plugin-side proxy is responsible for adding the SwapBuffers command |
178 // to the command buffer in that case. | 178 // to the command buffer in that case. |
179 if (gles2_impl()) | 179 if (gles2_impl()) |
180 gles2_impl()->SwapBuffers(); | 180 gles2_impl()->SwapBuffers(); |
181 | 181 |
182 // Since the backing texture has been updated, a new sync point should be | 182 // Since the backing texture has been updated, a new sync point should be |
183 // inserted. | 183 // inserted. |
184 sync_point_ = command_buffer_->InsertSyncPoint(); | 184 sync_point_ = command_buffer_->InsertSyncPoint(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 247 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
248 if (!render_thread) | 248 if (!render_thread) |
249 return false; | 249 return false; |
250 | 250 |
251 channel_ = render_thread->EstablishGpuChannelSync( | 251 channel_ = render_thread->EstablishGpuChannelSync( |
252 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); | 252 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); |
253 if (!channel_.get()) | 253 if (!channel_.get()) |
254 return false; | 254 return false; |
255 | 255 |
256 gfx::Size surface_size; | 256 gfx::Size surface_size; |
257 std::vector<int32> attribs; | 257 std::vector<int32_t> attribs; |
258 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 258 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
259 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() | 259 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() |
260 // interface to accept width and height in the attrib_list so that | 260 // interface to accept width and height in the attrib_list so that |
261 // we do not need to filter for width and height here. | 261 // we do not need to filter for width and height here. |
262 if (attrib_list) { | 262 if (attrib_list) { |
263 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; | 263 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
264 attr += 2) { | 264 attr += 2) { |
265 switch (attr[0]) { | 265 switch (attr[0]) { |
266 case PP_GRAPHICS3DATTRIB_WIDTH: | 266 case PP_GRAPHICS3DATTRIB_WIDTH: |
267 surface_size.set_width(attr[1]); | 267 surface_size.set_width(attr[1]); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); | 378 instance->module()->GetPluginInterface(PPP_GRAPHICS_3D_INTERFACE)); |
379 // We have to check *again* that the instance exists, because it could have | 379 // We have to check *again* that the instance exists, because it could have |
380 // been deleted during GetPluginInterface(). Even the PluginModule could be | 380 // been deleted during GetPluginInterface(). Even the PluginModule could be |
381 // deleted, but in that case, the instance should also be gone, so the | 381 // deleted, but in that case, the instance should also be gone, so the |
382 // GetInstance check covers both cases. | 382 // GetInstance check covers both cases. |
383 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) | 383 if (ppp_graphics_3d && HostGlobals::Get()->GetInstance(this_pp_instance)) |
384 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 384 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
385 } | 385 } |
386 | 386 |
387 } // namespace content | 387 } // namespace content |
OLD | NEW |