| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
| 9 #include "base/thread_local.h" | 9 #include "base/thread_local.h" |
| 10 #include "chrome/renderer/command_buffer_proxy.h" | 10 #include "chrome/renderer/command_buffer_proxy.h" |
| 11 #include "chrome/renderer/ggl/ggl.h" | 11 #include "chrome/renderer/ggl/ggl.h" |
| 12 #include "chrome/renderer/gpu_channel_host.h" | 12 #include "chrome/renderer/gpu_channel_host.h" |
| 13 #include "chrome/renderer/render_widget.h" | 13 #include "chrome/renderer/render_widget.h" |
| 14 #include "ipc/ipc_channel_handle.h" | 14 #include "ipc/ipc_channel_handle.h" |
| 15 | 15 |
| 16 #if defined(ENABLE_GPU) | 16 #if defined(ENABLE_GPU) |
| 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 18 #include "gpu/command_buffer/client/gles2_implementation.h" | 18 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 19 #include "gpu/command_buffer/client/gles2_lib.h" | 19 #include "gpu/command_buffer/client/gles2_lib.h" |
| 20 #include "gpu/command_buffer/common/constants.h" | 20 #include "gpu/command_buffer/common/constants.h" |
| 21 #include "gpu/GLES2/gles2_command_buffer.h" |
| 21 #endif // ENABLE_GPU | 22 #endif // ENABLE_GPU |
| 22 | 23 |
| 23 namespace ggl { | 24 namespace ggl { |
| 24 | 25 |
| 25 #if defined(ENABLE_GPU) | 26 #if defined(ENABLE_GPU) |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const int32 kCommandBufferSize = 1024 * 1024; | 30 const int32 kCommandBufferSize = 1024 * 1024; |
| 30 // TODO(kbr): make the transfer buffer size configurable via context | 31 // TODO(kbr): make the transfer buffer size configurable via context |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 static bool MakeCurrent(Context* context); | 76 static bool MakeCurrent(Context* context); |
| 76 | 77 |
| 77 // Display all content rendered since last call to SwapBuffers. | 78 // Display all content rendered since last call to SwapBuffers. |
| 78 // TODO(apatrick): support rendering to browser window. This function is | 79 // TODO(apatrick): support rendering to browser window. This function is |
| 79 // not useful at this point. | 80 // not useful at this point. |
| 80 bool SwapBuffers(); | 81 bool SwapBuffers(); |
| 81 | 82 |
| 82 // Get the current error code. | 83 // Get the current error code. |
| 83 Error GetError(); | 84 Error GetError(); |
| 84 | 85 |
| 86 // TODO(gman): Remove this. |
| 87 void DisableShaderTranslation(); |
| 88 |
| 85 private: | 89 private: |
| 86 scoped_refptr<GpuChannelHost> channel_; | 90 scoped_refptr<GpuChannelHost> channel_; |
| 87 Context* parent_; | 91 Context* parent_; |
| 88 uint32 parent_texture_id_; | 92 uint32 parent_texture_id_; |
| 89 CommandBufferProxy* command_buffer_; | 93 CommandBufferProxy* command_buffer_; |
| 90 gpu::gles2::GLES2CmdHelper* gles2_helper_; | 94 gpu::gles2::GLES2CmdHelper* gles2_helper_; |
| 91 int32 transfer_buffer_id_; | 95 int32 transfer_buffer_id_; |
| 92 gpu::gles2::GLES2Implementation* gles2_implementation_; | 96 gpu::gles2::GLES2Implementation* gles2_implementation_; |
| 93 | 97 |
| 94 DISALLOW_COPY_AND_ASSIGN(Context); | 98 DISALLOW_COPY_AND_ASSIGN(Context); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 245 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
| 242 if (state.error == gpu::error::kNoError) { | 246 if (state.error == gpu::error::kNoError) { |
| 243 return SUCCESS; | 247 return SUCCESS; |
| 244 } else { | 248 } else { |
| 245 // All command buffer errors are unrecoverable. The error is treated as a | 249 // All command buffer errors are unrecoverable. The error is treated as a |
| 246 // lost context: destroy the context and create another one. | 250 // lost context: destroy the context and create another one. |
| 247 return CONTEXT_LOST; | 251 return CONTEXT_LOST; |
| 248 } | 252 } |
| 249 } | 253 } |
| 250 | 254 |
| 255 // TODO(gman): Remove This |
| 256 void Context::DisableShaderTranslation() { |
| 257 gles2_implementation_->CommandBufferEnable(PEPPER3D_SKIP_GLSL_TRANSLATION); |
| 258 } |
| 259 |
| 251 #endif // ENABLE_GPU | 260 #endif // ENABLE_GPU |
| 252 | 261 |
| 253 Context* CreateViewContext(GpuChannelHost* channel, gfx::NativeViewId view) { | 262 Context* CreateViewContext(GpuChannelHost* channel, gfx::NativeViewId view) { |
| 254 #if defined(ENABLE_GPU) | 263 #if defined(ENABLE_GPU) |
| 255 scoped_ptr<Context> context(new Context(channel, NULL)); | 264 scoped_ptr<Context> context(new Context(channel, NULL)); |
| 256 if (!context->Initialize(view, gfx::Size())) | 265 if (!context->Initialize(view, gfx::Size())) |
| 257 return NULL; | 266 return NULL; |
| 258 | 267 |
| 259 return context.release(); | 268 return context.release(); |
| 260 #else | 269 #else |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 Context* context = GetCurrentContext(); | 347 Context* context = GetCurrentContext(); |
| 339 if (!context) | 348 if (!context) |
| 340 return BAD_CONTEXT; | 349 return BAD_CONTEXT; |
| 341 | 350 |
| 342 return context->GetError(); | 351 return context->GetError(); |
| 343 #else | 352 #else |
| 344 return NOT_INITIALIZED; | 353 return NOT_INITIALIZED; |
| 345 #endif | 354 #endif |
| 346 } | 355 } |
| 347 | 356 |
| 357 // TODO(gman): Remove This |
| 358 void DisableShaderTranslation(Context* context) { |
| 359 #if defined(ENABLE_GPU) |
| 360 if (context) { |
| 361 context->DisableShaderTranslation(); |
| 362 } |
| 363 #endif |
| 364 } |
| 348 } // namespace ggl | 365 } // namespace ggl |
| OLD | NEW |