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 "base/weak_ptr.h" | 10 #include "base/weak_ptr.h" |
11 #include "chrome/renderer/command_buffer_proxy.h" | 11 #include "chrome/renderer/command_buffer_proxy.h" |
12 #include "chrome/renderer/ggl/ggl.h" | 12 #include "chrome/renderer/ggl/ggl.h" |
13 #include "chrome/renderer/gpu_channel_host.h" | 13 #include "chrome/renderer/gpu_channel_host.h" |
| 14 #include "chrome/renderer/gpu_video_service_host.h" |
14 #include "chrome/renderer/render_widget.h" | 15 #include "chrome/renderer/render_widget.h" |
15 #include "ipc/ipc_channel_handle.h" | 16 #include "ipc/ipc_channel_handle.h" |
16 | 17 |
17 #if defined(ENABLE_GPU) | 18 #if defined(ENABLE_GPU) |
18 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 19 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
19 #include "gpu/command_buffer/client/gles2_implementation.h" | 20 #include "gpu/command_buffer/client/gles2_implementation.h" |
20 #include "gpu/command_buffer/client/gles2_lib.h" | 21 #include "gpu/command_buffer/client/gles2_lib.h" |
21 #include "gpu/command_buffer/common/constants.h" | 22 #include "gpu/command_buffer/common/constants.h" |
22 #include "gpu/GLES2/gles2_command_buffer.h" | 23 #include "gpu/GLES2/gles2_command_buffer.h" |
23 #endif // ENABLE_GPU | 24 #endif // ENABLE_GPU |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void Destroy(); | 91 void Destroy(); |
91 | 92 |
92 // Make a GGL context current for the calling thread. | 93 // Make a GGL context current for the calling thread. |
93 static bool MakeCurrent(Context* context); | 94 static bool MakeCurrent(Context* context); |
94 | 95 |
95 // Display all content rendered since last call to SwapBuffers. | 96 // Display all content rendered since last call to SwapBuffers. |
96 // TODO(apatrick): support rendering to browser window. This function is | 97 // TODO(apatrick): support rendering to browser window. This function is |
97 // not useful at this point. | 98 // not useful at this point. |
98 bool SwapBuffers(); | 99 bool SwapBuffers(); |
99 | 100 |
| 101 // Create a hardware accelerated video decoder associated with this context. |
| 102 GpuVideoDecoderHost* CreateVideoDecoder(); |
| 103 |
100 // Get the current error code. | 104 // Get the current error code. |
101 Error GetError(); | 105 Error GetError(); |
102 | 106 |
103 // TODO(gman): Remove this. | 107 // TODO(gman): Remove this. |
104 void DisableShaderTranslation(); | 108 void DisableShaderTranslation(); |
105 | 109 |
106 private: | 110 private: |
107 void OnSwapBuffers(); | 111 void OnSwapBuffers(); |
108 | 112 |
109 scoped_refptr<GpuChannelHost> channel_; | 113 scoped_refptr<GpuChannelHost> channel_; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 bool Context::SwapBuffers() { | 317 bool Context::SwapBuffers() { |
314 // Don't request latest error status from service. Just use the locally cached | 318 // Don't request latest error status from service. Just use the locally cached |
315 // information from the last flush. | 319 // information from the last flush. |
316 if (command_buffer_->GetLastState().error != gpu::error::kNoError) | 320 if (command_buffer_->GetLastState().error != gpu::error::kNoError) |
317 return false; | 321 return false; |
318 | 322 |
319 gles2_implementation_->SwapBuffers(); | 323 gles2_implementation_->SwapBuffers(); |
320 return true; | 324 return true; |
321 } | 325 } |
322 | 326 |
| 327 GpuVideoDecoderHost* Context::CreateVideoDecoder() { |
| 328 return GpuVideoServiceHost::get()->CreateVideoDecoder( |
| 329 command_buffer_->route_id()); |
| 330 } |
| 331 |
323 Error Context::GetError() { | 332 Error Context::GetError() { |
324 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 333 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
325 if (state.error == gpu::error::kNoError) { | 334 if (state.error == gpu::error::kNoError) { |
326 return SUCCESS; | 335 return SUCCESS; |
327 } else { | 336 } else { |
328 // All command buffer errors are unrecoverable. The error is treated as a | 337 // All command buffer errors are unrecoverable. The error is treated as a |
329 // lost context: destroy the context and create another one. | 338 // lost context: destroy the context and create another one. |
330 return CONTEXT_LOST; | 339 return CONTEXT_LOST; |
331 } | 340 } |
332 } | 341 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (context == GetCurrentContext()) | 458 if (context == GetCurrentContext()) |
450 MakeCurrent(NULL); | 459 MakeCurrent(NULL); |
451 | 460 |
452 delete context; | 461 delete context; |
453 return true; | 462 return true; |
454 #else | 463 #else |
455 return false; | 464 return false; |
456 #endif | 465 #endif |
457 } | 466 } |
458 | 467 |
| 468 GpuVideoDecoderHost* CreateVideoDecoder(Context* context) { |
| 469 return context->CreateVideoDecoder(); |
| 470 } |
| 471 |
459 Error GetError() { | 472 Error GetError() { |
460 #if defined(ENABLE_GPU) | 473 #if defined(ENABLE_GPU) |
461 Context* context = GetCurrentContext(); | 474 Context* context = GetCurrentContext(); |
462 if (!context) | 475 if (!context) |
463 return BAD_CONTEXT; | 476 return BAD_CONTEXT; |
464 | 477 |
465 return context->GetError(); | 478 return context->GetError(); |
466 #else | 479 #else |
467 return NOT_INITIALIZED; | 480 return NOT_INITIALIZED; |
468 #endif | 481 #endif |
469 } | 482 } |
470 | 483 |
471 // TODO(gman): Remove This | 484 // TODO(gman): Remove This |
472 void DisableShaderTranslation(Context* context) { | 485 void DisableShaderTranslation(Context* context) { |
473 #if defined(ENABLE_GPU) | 486 #if defined(ENABLE_GPU) |
474 if (context) { | 487 if (context) { |
475 context->DisableShaderTranslation(); | 488 context->DisableShaderTranslation(); |
476 } | 489 } |
477 #endif | 490 #endif |
478 } | 491 } |
479 } // namespace ggl | 492 } // namespace ggl |
OLD | NEW |