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 "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Ensure the gles2 library is initialized first in a thread safe way. | 140 // Ensure the gles2 library is initialized first in a thread safe way. |
141 g_gles2_initializer.Get(); | 141 g_gles2_initializer.Get(); |
142 | 142 |
143 if (!context_) { | 143 if (!context_) { |
144 // TODO(kbr): More work will be needed in this implementation to | 144 // TODO(kbr): More work will be needed in this implementation to |
145 // properly support GPU switching. Like in the out-of-process | 145 // properly support GPU switching. Like in the out-of-process |
146 // command buffer implementation, all previously created contexts | 146 // command buffer implementation, all previously created contexts |
147 // will need to be lost either when the first context requesting the | 147 // will need to be lost either when the first context requesting the |
148 // discrete GPU is created, or the last one is destroyed. | 148 // discrete GPU is created, or the last one is destroyed. |
149 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 149 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
150 | 150 context_.reset(GLInProcessContext::Create(NULL, /* service */ |
151 context_.reset(GLInProcessContext::CreateContext( | 151 NULL, /* surface */ |
152 is_offscreen_, | 152 is_offscreen_, |
153 window_, | 153 window_, |
154 gfx::Size(1, 1), | 154 gfx::Size(1, 1), |
155 share_resources_, | 155 NULL, /* share_context */ |
156 attribs_, | 156 share_resources_, |
157 gpu_preference)); | 157 attribs_, |
| 158 gpu_preference)); |
158 } | 159 } |
159 | 160 |
160 if (context_) { | 161 if (context_) { |
161 base::Closure context_lost_callback = base::Bind( | 162 base::Closure context_lost_callback = base::Bind( |
162 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, | 163 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, |
163 base::Unretained(this)); | 164 base::Unretained(this)); |
164 context_->SetContextLostCallback(context_lost_callback); | 165 context_->SetContextLostCallback(context_lost_callback); |
165 } else { | 166 } else { |
166 initialize_failed_ = true; | 167 initialize_failed_ = true; |
167 return false; | 168 return false; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { | 202 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
202 // TODO(kbr): improve the precision here. | 203 // TODO(kbr): improve the precision here. |
203 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; | 204 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
204 if (context_lost_callback_) { | 205 if (context_lost_callback_) { |
205 context_lost_callback_->onContextLost(); | 206 context_lost_callback_->onContextLost(); |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
209 } // namespace gpu | 210 } // namespace gpu |
210 } // namespace webkit | 211 } // namespace webkit |
OLD | NEW |