OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "gpu/gles2_conform_support/egl/context.h" | 5 #include "gpu/gles2_conform_support/egl/context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 void Context::SignalSyncToken(const gpu::SyncToken& sync_token, | 224 void Context::SignalSyncToken(const gpu::SyncToken& sync_token, |
225 const base::Closure& callback) { | 225 const base::Closure& callback) { |
226 NOTIMPLEMENTED(); | 226 NOTIMPLEMENTED(); |
227 } | 227 } |
228 | 228 |
229 bool Context::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { | 229 bool Context::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { |
230 return false; | 230 return false; |
231 } | 231 } |
232 | 232 |
233 void Context::ApplyCurrentContext(gfx::GLSurface* current_surface) { | 233 void Context::ApplyCurrentContext(gl::GLSurface* current_surface) { |
234 DCHECK(HasService()); | 234 DCHECK(HasService()); |
235 // The current_surface will be the same as | 235 // The current_surface will be the same as |
236 // the surface of the decoder. We can not DCHECK as there is | 236 // the surface of the decoder. We can not DCHECK as there is |
237 // no accessor. | 237 // no accessor. |
238 if (!WasServiceContextLost()) { | 238 if (!WasServiceContextLost()) { |
239 if (!gl_context_->MakeCurrent(current_surface)) | 239 if (!gl_context_->MakeCurrent(current_surface)) |
240 MarkServiceContextLost(); | 240 MarkServiceContextLost(); |
241 } | 241 } |
242 gles2::SetGLContext(client_gl_context_.get()); | 242 gles2::SetGLContext(client_gl_context_.get()); |
243 } | 243 } |
244 | 244 |
245 void Context::ApplyContextReleased() { | 245 void Context::ApplyContextReleased() { |
246 gles2::SetGLContext(nullptr); | 246 gles2::SetGLContext(nullptr); |
247 } | 247 } |
248 | 248 |
249 bool Context::CreateService(gfx::GLSurface* gl_surface) { | 249 bool Context::CreateService(gl::GLSurface* gl_surface) { |
250 scoped_refptr<gpu::TransferBufferManager> transfer_buffer_manager( | 250 scoped_refptr<gpu::TransferBufferManager> transfer_buffer_manager( |
251 new gpu::TransferBufferManager(nullptr)); | 251 new gpu::TransferBufferManager(nullptr)); |
252 transfer_buffer_manager->Initialize(); | 252 transfer_buffer_manager->Initialize(); |
253 | 253 |
254 std::unique_ptr<gpu::CommandBufferService> command_buffer( | 254 std::unique_ptr<gpu::CommandBufferService> command_buffer( |
255 new gpu::CommandBufferService(transfer_buffer_manager.get())); | 255 new gpu::CommandBufferService(transfer_buffer_manager.get())); |
256 | 256 |
257 scoped_refptr<gpu::gles2::FeatureInfo> feature_info( | 257 scoped_refptr<gpu::gles2::FeatureInfo> feature_info( |
258 new gpu::gles2::FeatureInfo(gpu_driver_bug_workarounds_)); | 258 new gpu::gles2::FeatureInfo(gpu_driver_bug_workarounds_)); |
259 scoped_refptr<gpu::gles2::ContextGroup> group(new gpu::gles2::ContextGroup( | 259 scoped_refptr<gpu::gles2::ContextGroup> group(new gpu::gles2::ContextGroup( |
260 gpu_preferences_, nullptr, nullptr, | 260 gpu_preferences_, nullptr, nullptr, |
261 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_), | 261 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_), |
262 new gpu::gles2::FramebufferCompletenessCache, feature_info, true)); | 262 new gpu::gles2::FramebufferCompletenessCache, feature_info, true)); |
263 | 263 |
264 std::unique_ptr<gpu::gles2::GLES2Decoder> decoder( | 264 std::unique_ptr<gpu::gles2::GLES2Decoder> decoder( |
265 gpu::gles2::GLES2Decoder::Create(group.get())); | 265 gpu::gles2::GLES2Decoder::Create(group.get())); |
266 if (!decoder.get()) | 266 if (!decoder.get()) |
267 return false; | 267 return false; |
268 | 268 |
269 std::unique_ptr<gpu::CommandExecutor> command_executor( | 269 std::unique_ptr<gpu::CommandExecutor> command_executor( |
270 new gpu::CommandExecutor(command_buffer.get(), decoder.get(), | 270 new gpu::CommandExecutor(command_buffer.get(), decoder.get(), |
271 decoder.get())); | 271 decoder.get())); |
272 | 272 |
273 decoder->set_engine(command_executor.get()); | 273 decoder->set_engine(command_executor.get()); |
274 | 274 |
275 scoped_refptr<gfx::GLContext> gl_context( | 275 scoped_refptr<gl::GLContext> gl_context( |
276 gl::init::CreateGLContext(nullptr, gl_surface, gfx::PreferDiscreteGpu)); | 276 gl::init::CreateGLContext(nullptr, gl_surface, gl::PreferDiscreteGpu)); |
277 if (!gl_context) | 277 if (!gl_context) |
278 return false; | 278 return false; |
279 | 279 |
280 gl_context->MakeCurrent(gl_surface); | 280 gl_context->MakeCurrent(gl_surface); |
281 | 281 |
282 gpu::gles2::ContextCreationAttribHelper helper; | 282 gpu::gles2::ContextCreationAttribHelper helper; |
283 config_->GetAttrib(EGL_ALPHA_SIZE, &helper.alpha_size); | 283 config_->GetAttrib(EGL_ALPHA_SIZE, &helper.alpha_size); |
284 config_->GetAttrib(EGL_DEPTH_SIZE, &helper.depth_size); | 284 config_->GetAttrib(EGL_DEPTH_SIZE, &helper.depth_size); |
285 config_->GetAttrib(EGL_STENCIL_SIZE, &helper.stencil_size); | 285 config_->GetAttrib(EGL_STENCIL_SIZE, &helper.stencil_size); |
286 | 286 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // because GTF windowless window surfaces might be emulated with offscreen | 374 // because GTF windowless window surfaces might be emulated with offscreen |
375 // surfaces. | 375 // surfaces. |
376 EGLint value = EGL_NONE; | 376 EGLint value = EGL_NONE; |
377 config_->GetAttrib(EGL_SURFACE_TYPE, &value); | 377 config_->GetAttrib(EGL_SURFACE_TYPE, &value); |
378 bool context_config_is_offscreen = (value & EGL_PBUFFER_BIT) != 0; | 378 bool context_config_is_offscreen = (value & EGL_PBUFFER_BIT) != 0; |
379 surface->config()->GetAttrib(EGL_SURFACE_TYPE, &value); | 379 surface->config()->GetAttrib(EGL_SURFACE_TYPE, &value); |
380 bool surface_config_is_offscreen = (value & EGL_PBUFFER_BIT) != 0; | 380 bool surface_config_is_offscreen = (value & EGL_PBUFFER_BIT) != 0; |
381 return surface_config_is_offscreen == context_config_is_offscreen; | 381 return surface_config_is_offscreen == context_config_is_offscreen; |
382 } | 382 } |
383 | 383 |
384 bool Context::Flush(gfx::GLSurface* gl_surface) { | 384 bool Context::Flush(gl::GLSurface* gl_surface) { |
385 if (WasServiceContextLost()) | 385 if (WasServiceContextLost()) |
386 return false; | 386 return false; |
387 if (!gl_context_->MakeCurrent(gl_surface)) { | 387 if (!gl_context_->MakeCurrent(gl_surface)) { |
388 MarkServiceContextLost(); | 388 MarkServiceContextLost(); |
389 return false; | 389 return false; |
390 } | 390 } |
391 client_gl_context_->Flush(); | 391 client_gl_context_->Flush(); |
392 return true; | 392 return true; |
393 } | 393 } |
394 | 394 |
395 } // namespace egl | 395 } // namespace egl |
OLD | NEW |