| 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" |
| 11 #include "gpu/command_buffer/client/gles2_lib.h" | 11 #include "gpu/command_buffer/client/gles2_lib.h" |
| 12 #include "gpu/command_buffer/client/shared_memory_limits.h" | 12 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 13 #include "gpu/command_buffer/client/transfer_buffer.h" | 13 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 14 #include "gpu/command_buffer/service/context_group.h" | 14 #include "gpu/command_buffer/service/context_group.h" |
| 15 #include "gpu/command_buffer/service/mailbox_manager.h" | 15 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 16 #include "gpu/command_buffer/service/memory_tracking.h" | 16 #include "gpu/command_buffer/service/memory_tracking.h" |
| 17 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 17 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 18 #include "gpu/gles2_conform_support/egl/config.h" | 18 #include "gpu/gles2_conform_support/egl/config.h" |
| 19 #include "gpu/gles2_conform_support/egl/display.h" | 19 #include "gpu/gles2_conform_support/egl/display.h" |
| 20 #include "gpu/gles2_conform_support/egl/surface.h" | 20 #include "gpu/gles2_conform_support/egl/surface.h" |
| 21 #include "gpu/gles2_conform_support/egl/thread_state.h" | 21 #include "gpu/gles2_conform_support/egl/thread_state.h" |
| 22 #include "ui/gl/init/gl_factory.h" |
| 22 | 23 |
| 23 // The slight complexification in this file comes from following properties: | 24 // The slight complexification in this file comes from following properties: |
| 24 // 1) Command buffer connection (context) can not be established without a | 25 // 1) Command buffer connection (context) can not be established without a |
| 25 // GLSurface. EGL Context can be created independent of a surface. This is why | 26 // GLSurface. EGL Context can be created independent of a surface. This is why |
| 26 // the connection is created only during first MakeCurrent. | 27 // the connection is created only during first MakeCurrent. |
| 27 // 2) Command buffer MakeCurrent calls need the real gl context and surface be | 28 // 2) Command buffer MakeCurrent calls need the real gl context and surface be |
| 28 // current. | 29 // current. |
| 29 // 3) Client can change real EGL context behind the scenes and then still expect | 30 // 3) Client can change real EGL context behind the scenes and then still expect |
| 30 // command buffer MakeCurrent re-set the command buffer context. This is why all | 31 // command buffer MakeCurrent re-set the command buffer context. This is why all |
| 31 // MakeCurrent calls must actually reset the real context, even though command | 32 // MakeCurrent calls must actually reset the real context, even though command |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 gpu::gles2::GLES2Decoder::Create(group.get())); | 265 gpu::gles2::GLES2Decoder::Create(group.get())); |
| 265 if (!decoder.get()) | 266 if (!decoder.get()) |
| 266 return false; | 267 return false; |
| 267 | 268 |
| 268 std::unique_ptr<gpu::CommandExecutor> command_executor( | 269 std::unique_ptr<gpu::CommandExecutor> command_executor( |
| 269 new gpu::CommandExecutor(command_buffer.get(), decoder.get(), | 270 new gpu::CommandExecutor(command_buffer.get(), decoder.get(), |
| 270 decoder.get())); | 271 decoder.get())); |
| 271 | 272 |
| 272 decoder->set_engine(command_executor.get()); | 273 decoder->set_engine(command_executor.get()); |
| 273 | 274 |
| 274 scoped_refptr<gfx::GLContext> gl_context(gfx::GLContext::CreateGLContext( | 275 scoped_refptr<gfx::GLContext> gl_context( |
| 275 nullptr, gl_surface, gfx::PreferDiscreteGpu)); | 276 gl::init::CreateGLContext(nullptr, gl_surface, gfx::PreferDiscreteGpu)); |
| 276 if (!gl_context) | 277 if (!gl_context) |
| 277 return false; | 278 return false; |
| 278 | 279 |
| 279 gl_context->MakeCurrent(gl_surface); | 280 gl_context->MakeCurrent(gl_surface); |
| 280 | 281 |
| 281 gpu::gles2::ContextCreationAttribHelper helper; | 282 gpu::gles2::ContextCreationAttribHelper helper; |
| 282 config_->GetAttrib(EGL_ALPHA_SIZE, &helper.alpha_size); | 283 config_->GetAttrib(EGL_ALPHA_SIZE, &helper.alpha_size); |
| 283 config_->GetAttrib(EGL_DEPTH_SIZE, &helper.depth_size); | 284 config_->GetAttrib(EGL_DEPTH_SIZE, &helper.depth_size); |
| 284 config_->GetAttrib(EGL_STENCIL_SIZE, &helper.stencil_size); | 285 config_->GetAttrib(EGL_STENCIL_SIZE, &helper.stencil_size); |
| 285 | 286 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 return false; | 388 return false; |
| 388 if (!gl_context_->MakeCurrent(gl_surface)) { | 389 if (!gl_context_->MakeCurrent(gl_surface)) { |
| 389 MarkServiceContextLost(); | 390 MarkServiceContextLost(); |
| 390 return false; | 391 return false; |
| 391 } | 392 } |
| 392 client_gl_context_->Flush(); | 393 client_gl_context_->Flush(); |
| 393 return true; | 394 return true; |
| 394 } | 395 } |
| 395 | 396 |
| 396 } // namespace egl | 397 } // namespace egl |
| OLD | NEW |