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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 DestroyDecoder(); | 76 DestroyDecoder(); |
77 } | 77 } |
78 | 78 |
79 bool CommandBufferDriver::Initialize( | 79 bool CommandBufferDriver::Initialize( |
80 mojo::ScopedSharedBufferHandle shared_state, | 80 mojo::ScopedSharedBufferHandle shared_state, |
81 mojo::Array<int32_t> attribs) { | 81 mojo::Array<int32_t> attribs) { |
82 DCHECK(CalledOnValidThread()); | 82 DCHECK(CalledOnValidThread()); |
83 gpu::gles2::ContextCreationAttribHelper attrib_helper; | 83 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
84 if (!attrib_helper.Parse(attribs.storage())) | 84 if (!attrib_helper.Parse(attribs.storage())) |
85 return false; | 85 return false; |
| 86 // TODO(piman): attribs can't currently represent gpu_preference. |
86 | 87 |
87 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; | 88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; |
88 if (offscreen) { | 89 if (offscreen) { |
89 surface_ = gl::init::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<gl::GLSurface> underlying_surface = | 93 scoped_refptr<gl::GLSurface> underlying_surface = |
93 gl::init::CreateSurfacelessViewGLSurface(widget_); | 94 gl::init::CreateSurfacelessViewGLSurface(widget_); |
94 if (!underlying_surface) | 95 if (!underlying_surface) |
95 underlying_surface = gl::init::CreateViewGLSurface(widget_); | 96 underlying_surface = gl::init::CreateViewGLSurface(widget_); |
(...skipping 13 matching lines...) Expand all Loading... |
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. |
120 context_ = gl::init::CreateGLContext(gpu_state_->share_group(), | 121 context_ = gl::init::CreateGLContext( |
121 surface_.get(), gl::PreferIntegratedGpu); | 122 gpu_state_->share_group(), surface_.get(), attrib_helper.gpu_preference); |
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; |
131 scoped_refptr<gpu::gles2::FeatureInfo> feature_info = | 132 scoped_refptr<gpu::gles2::FeatureInfo> feature_info = |
(...skipping 22 matching lines...) Expand all Loading... |
154 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); | 155 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); |
155 decoder_->SetWaitFenceSyncCallback(base::Bind( | 156 decoder_->SetWaitFenceSyncCallback(base::Bind( |
156 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); | 157 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); |
157 decoder_->SetDescheduleUntilFinishedCallback(base::Bind( | 158 decoder_->SetDescheduleUntilFinishedCallback(base::Bind( |
158 &CommandBufferDriver::OnDescheduleUntilFinished, base::Unretained(this))); | 159 &CommandBufferDriver::OnDescheduleUntilFinished, base::Unretained(this))); |
159 decoder_->SetRescheduleAfterFinishedCallback(base::Bind( | 160 decoder_->SetRescheduleAfterFinishedCallback(base::Bind( |
160 &CommandBufferDriver::OnRescheduleAfterFinished, base::Unretained(this))); | 161 &CommandBufferDriver::OnRescheduleAfterFinished, base::Unretained(this))); |
161 | 162 |
162 gpu::gles2::DisallowedFeatures disallowed_features; | 163 gpu::gles2::DisallowedFeatures disallowed_features; |
163 | 164 |
164 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), | 165 if (!decoder_->Initialize(surface_, context_, offscreen, disallowed_features, |
165 disallowed_features, attrib_helper)) | 166 attrib_helper)) |
166 return false; | 167 return false; |
167 | 168 |
168 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 169 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
169 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); | 170 &gpu::CommandExecutor::PutChanged, base::Unretained(executor_.get()))); |
170 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 171 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
171 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get()))); | 172 &gpu::CommandExecutor::SetGetBuffer, base::Unretained(executor_.get()))); |
172 command_buffer_->SetParseErrorCallback( | 173 command_buffer_->SetParseErrorCallback( |
173 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); | 174 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); |
174 | 175 |
175 // TODO(piman): other callbacks | 176 // TODO(piman): other callbacks |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 559 } |
559 | 560 |
560 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | 561 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { |
561 DCHECK(CalledOnValidThread()); | 562 DCHECK(CalledOnValidThread()); |
562 if (client_) { | 563 if (client_) { |
563 client_->OnGpuCompletedSwapBuffers(result); | 564 client_->OnGpuCompletedSwapBuffers(result); |
564 } | 565 } |
565 } | 566 } |
566 | 567 |
567 } // namespace mus | 568 } // namespace mus |
OLD | NEW |