| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/mus/gles2/command_buffer_driver.h" | 5 #include "components/mus/gles2/command_buffer_driver.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "gpu/command_buffer/service/sync_point_manager.h" | 26 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 28 #include "mojo/converters/geometry/geometry_type_converters.h" | 28 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 29 #include "mojo/platform_handle/platform_handle_functions.h" | 29 #include "mojo/platform_handle/platform_handle_functions.h" |
| 30 #include "ui/gfx/buffer_format_util.h" | 30 #include "ui/gfx/buffer_format_util.h" |
| 31 #include "ui/gfx/gpu_memory_buffer.h" | 31 #include "ui/gfx/gpu_memory_buffer.h" |
| 32 #include "ui/gfx/vsync_provider.h" | 32 #include "ui/gfx/vsync_provider.h" |
| 33 #include "ui/gl/gl_context.h" | 33 #include "ui/gl/gl_context.h" |
| 34 #include "ui/gl/gl_image_shared_memory.h" | 34 #include "ui/gl/gl_image_shared_memory.h" |
| 35 #include "ui/gl/gl_surface.h" | 35 #include "ui/gl/gl_surface.h" |
| 36 #include "ui/gl/init/gl_factory.h" |
| 36 | 37 |
| 37 #if defined(USE_OZONE) | 38 #if defined(USE_OZONE) |
| 38 #include "ui/gl/gl_image_ozone_native_pixmap.h" | 39 #include "ui/gl/gl_image_ozone_native_pixmap.h" |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 namespace mus { | 42 namespace mus { |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 // The first time polling a fence, delay some extra time to allow other | 46 // The first time polling a fence, delay some extra time to allow other |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 bool CommandBufferDriver::Initialize( | 80 bool CommandBufferDriver::Initialize( |
| 80 mojo::ScopedSharedBufferHandle shared_state, | 81 mojo::ScopedSharedBufferHandle shared_state, |
| 81 mojo::Array<int32_t> attribs) { | 82 mojo::Array<int32_t> attribs) { |
| 82 DCHECK(CalledOnValidThread()); | 83 DCHECK(CalledOnValidThread()); |
| 83 gpu::gles2::ContextCreationAttribHelper attrib_helper; | 84 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
| 84 if (!attrib_helper.Parse(attribs.storage())) | 85 if (!attrib_helper.Parse(attribs.storage())) |
| 85 return false; | 86 return false; |
| 86 | 87 |
| 87 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; | 88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; |
| 88 if (offscreen) { | 89 if (offscreen) { |
| 89 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(0, 0)); | 90 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size(0, 0)); |
| 90 } else { | 91 } else { |
| 91 #if defined(USE_OZONE) | 92 #if defined(USE_OZONE) |
| 92 scoped_refptr<gfx::GLSurface> underlying_surface = | 93 scoped_refptr<gfx::GLSurface> underlying_surface = |
| 93 gfx::GLSurface::CreateSurfacelessViewGLSurface(widget_); | 94 gl::init::CreateSurfacelessViewGLSurface(widget_); |
| 94 if (!underlying_surface) | 95 if (!underlying_surface) |
| 95 underlying_surface = gfx::GLSurface::CreateViewGLSurface(widget_); | 96 underlying_surface = gl::init::CreateViewGLSurface(widget_); |
| 96 #else | 97 #else |
| 97 scoped_refptr<gfx::GLSurface> underlying_surface = | 98 scoped_refptr<gfx::GLSurface> underlying_surface = |
| 98 gfx::GLSurface::CreateViewGLSurface(widget_); | 99 gl::init::CreateViewGLSurface(widget_); |
| 99 #endif | 100 #endif |
| 100 scoped_refptr<GLSurfaceAdapterMus> surface_adapter = | 101 scoped_refptr<GLSurfaceAdapterMus> surface_adapter = |
| 101 new GLSurfaceAdapterMus(underlying_surface); | 102 new GLSurfaceAdapterMus(underlying_surface); |
| 102 surface_adapter->SetGpuCompletedSwapBuffersCallback( | 103 surface_adapter->SetGpuCompletedSwapBuffersCallback( |
| 103 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, | 104 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, |
| 104 weak_factory_.GetWeakPtr())); | 105 weak_factory_.GetWeakPtr())); |
| 105 surface_ = surface_adapter; | 106 surface_ = surface_adapter; |
| 106 | 107 |
| 107 gfx::VSyncProvider* vsync_provider = | 108 gfx::VSyncProvider* vsync_provider = |
| 108 surface_ ? surface_->GetVSyncProvider() : nullptr; | 109 surface_ ? surface_->GetVSyncProvider() : nullptr; |
| 109 if (vsync_provider) { | 110 if (vsync_provider) { |
| 110 vsync_provider->GetVSyncParameters( | 111 vsync_provider->GetVSyncParameters( |
| 111 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, | 112 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, |
| 112 weak_factory_.GetWeakPtr())); | 113 weak_factory_.GetWeakPtr())); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 if (!surface_.get()) | 117 if (!surface_.get()) |
| 117 return false; | 118 return false; |
| 118 | 119 |
| 119 // TODO(piman): virtual contexts, gpu preference. | 120 // TODO(piman): virtual contexts, gpu preference. |
| 120 context_ = gfx::GLContext::CreateGLContext( | 121 context_ = gl::init::CreateGLContext( |
| 121 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); | 122 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); |
| 122 if (!context_.get()) | 123 if (!context_.get()) |
| 123 return false; | 124 return false; |
| 124 | 125 |
| 125 if (!context_->MakeCurrent(surface_.get())) | 126 if (!context_->MakeCurrent(surface_.get())) |
| 126 return false; | 127 return false; |
| 127 | 128 |
| 128 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but | 129 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but |
| 129 // only needs to be per-thread. | 130 // only needs to be per-thread. |
| 130 const bool bind_generates_resource = attrib_helper.bind_generates_resource; | 131 const bool bind_generates_resource = attrib_helper.bind_generates_resource; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 543 } |
| 543 | 544 |
| 544 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | 545 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { |
| 545 DCHECK(CalledOnValidThread()); | 546 DCHECK(CalledOnValidThread()); |
| 546 if (client_) { | 547 if (client_) { |
| 547 client_->OnGpuCompletedSwapBuffers(result); | 548 client_->OnGpuCompletedSwapBuffers(result); |
| 548 } | 549 } |
| 549 } | 550 } |
| 550 | 551 |
| 551 } // namespace mus | 552 } // namespace mus |
| OLD | NEW |