OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/gl/gl_context.h" | 5 #include "app/gfx/gl/gl_context.h" |
6 #include "gpu/command_buffer/service/gpu_processor.h" | 6 #include "gpu/command_buffer/service/gpu_processor.h" |
7 | 7 |
8 using ::base::SharedMemory; | 8 using ::base::SharedMemory; |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 | 11 |
12 bool GPUProcessor::Initialize(gfx::PluginWindowHandle window, | 12 bool GPUProcessor::Initialize(gfx::PluginWindowHandle window, |
13 const gfx::Size& size, | 13 const gfx::Size& size, |
14 GPUProcessor* parent, | 14 GPUProcessor* parent, |
15 uint32 parent_texture_id) { | 15 uint32 parent_texture_id) { |
16 // Cannot reinitialize. | 16 // Cannot reinitialize. |
17 if (context_.get()) | 17 if (context_.get()) |
18 return false; | 18 return false; |
19 | 19 |
20 // Get the parent decoder and the GLContext to share IDs with, if any. | 20 // Get the parent decoder and the GLContext to share IDs with, if any. |
21 gles2::GLES2Decoder* parent_decoder = NULL; | 21 gles2::GLES2Decoder* parent_decoder = NULL; |
22 gfx::GLContext* parent_context = NULL; | 22 gfx::GLContext* parent_context = NULL; |
23 void* parent_handle = NULL; | 23 void* parent_handle = NULL; |
24 if (parent) { | 24 if (parent) { |
25 parent_decoder = parent->decoder_.get(); | 25 parent_decoder = parent->decoder_.get(); |
26 DCHECK(parent_decoder); | 26 DCHECK(parent_decoder); |
27 | 27 |
28 parent_context = parent_decoder->GetGLContext(); | 28 parent_context = parent_decoder->GetGLContext(); |
29 DCHECK(parent_context); | 29 DCHECK(parent_context); |
30 | |
31 parent_handle = parent_context->GetHandle(); | |
32 DCHECK(parent_handle); | |
33 } | 30 } |
34 | 31 |
35 // Create either a view or pbuffer based GLContext. | 32 // Create either a view or pbuffer based GLContext. |
36 if (window) { | 33 if (window) { |
37 DCHECK(!parent_handle); | 34 DCHECK(!parent_handle); |
38 | 35 |
39 // TODO(apatrick): support multisampling. | 36 // TODO(apatrick): support multisampling. |
40 context_.reset(gfx::GLContext::CreateViewGLContext(window, false)); | 37 context_.reset(gfx::GLContext::CreateViewGLContext(window, false)); |
41 } else { | 38 } else { |
42 context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_handle)); | 39 context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_context)); |
43 } | 40 } |
44 | 41 |
45 if (!context_.get()) | 42 if (!context_.get()) |
46 return false; | 43 return false; |
47 | 44 |
48 return InitializeCommon(size, parent_decoder, parent_texture_id); | 45 return InitializeCommon(size, parent_decoder, parent_texture_id); |
49 } | 46 } |
50 | 47 |
51 void GPUProcessor::Destroy() { | 48 void GPUProcessor::Destroy() { |
52 DestroyCommon(); | 49 DestroyCommon(); |
53 } | 50 } |
54 | 51 |
55 void GPUProcessor::WillSwapBuffers() { | 52 void GPUProcessor::WillSwapBuffers() { |
56 if (wrapped_swap_buffers_callback_.get()) { | 53 if (wrapped_swap_buffers_callback_.get()) { |
57 wrapped_swap_buffers_callback_->Run(); | 54 wrapped_swap_buffers_callback_->Run(); |
58 } | 55 } |
59 } | 56 } |
60 | 57 |
61 } // namespace gpu | 58 } // namespace gpu |
OLD | NEW |