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/view_manager/gles2/command_buffer_driver.h" | 5 #include "components/mus/gles2/command_buffer_driver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "components/view_manager/gles2/command_buffer_type_conversions.h" | 10 #include "components/mus/gles2/command_buffer_type_conversions.h" |
11 #include "components/view_manager/gles2/gpu_memory_tracker.h" | 11 #include "components/mus/gles2/gpu_memory_tracker.h" |
12 #include "components/view_manager/gles2/gpu_state.h" | 12 #include "components/mus/gles2/gpu_state.h" |
13 #include "components/view_manager/gles2/mojo_buffer_backing.h" | 13 #include "components/mus/gles2/mojo_buffer_backing.h" |
14 #include "gpu/command_buffer/common/constants.h" | 14 #include "gpu/command_buffer/common/constants.h" |
15 #include "gpu/command_buffer/common/value_state.h" | 15 #include "gpu/command_buffer/common/value_state.h" |
16 #include "gpu/command_buffer/service/command_buffer_service.h" | 16 #include "gpu/command_buffer/service/command_buffer_service.h" |
17 #include "gpu/command_buffer/service/context_group.h" | 17 #include "gpu/command_buffer/service/context_group.h" |
18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
19 #include "gpu/command_buffer/service/gpu_scheduler.h" | 19 #include "gpu/command_buffer/service/gpu_scheduler.h" |
20 #include "gpu/command_buffer/service/image_factory.h" | 20 #include "gpu/command_buffer/service/image_factory.h" |
21 #include "gpu/command_buffer/service/image_manager.h" | 21 #include "gpu/command_buffer/service/image_manager.h" |
22 #include "gpu/command_buffer/service/mailbox_manager.h" | 22 #include "gpu/command_buffer/service/mailbox_manager.h" |
23 #include "gpu/command_buffer/service/memory_tracking.h" | 23 #include "gpu/command_buffer/service/memory_tracking.h" |
24 #include "gpu/command_buffer/service/sync_point_manager.h" | 24 #include "gpu/command_buffer/service/sync_point_manager.h" |
25 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 25 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
26 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 26 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
27 #include "mojo/converters/geometry/geometry_type_converters.h" | 27 #include "mojo/converters/geometry/geometry_type_converters.h" |
28 #include "mojo/platform_handle/platform_handle_functions.h" | 28 #include "mojo/platform_handle/platform_handle_functions.h" |
29 #include "ui/gfx/gpu_memory_buffer.h" | 29 #include "ui/gfx/gpu_memory_buffer.h" |
30 #include "ui/gfx/vsync_provider.h" | 30 #include "ui/gfx/vsync_provider.h" |
31 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
32 #include "ui/gl/gl_image_shared_memory.h" | 32 #include "ui/gl/gl_image_shared_memory.h" |
33 #include "ui/gl/gl_surface.h" | 33 #include "ui/gl/gl_surface.h" |
34 | 34 |
35 namespace gles2 { | 35 namespace gles2 { |
36 | 36 |
37 CommandBufferDriver::Client::~Client() { | 37 CommandBufferDriver::Client::~Client() {} |
38 } | |
39 | 38 |
40 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) | 39 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) |
41 : client_(nullptr), | 40 : client_(nullptr), gpu_state_(gpu_state), weak_factory_(this) {} |
42 gpu_state_(gpu_state), | |
43 weak_factory_(this) { | |
44 } | |
45 | 41 |
46 CommandBufferDriver::~CommandBufferDriver() { | 42 CommandBufferDriver::~CommandBufferDriver() { |
47 DestroyDecoder(); | 43 DestroyDecoder(); |
48 } | 44 } |
49 | 45 |
50 void CommandBufferDriver::Initialize( | 46 void CommandBufferDriver::Initialize( |
51 mojo::CommandBufferSyncClientPtr sync_client, | 47 mojo::CommandBufferSyncClientPtr sync_client, |
52 mojo::CommandBufferLostContextObserverPtr loss_observer, | 48 mojo::CommandBufferLostContextObserverPtr loss_observer, |
53 mojo::ScopedSharedBufferHandle shared_state) { | 49 mojo::ScopedSharedBufferHandle shared_state) { |
54 sync_client_ = sync_client.Pass(); | 50 sync_client_ = sync_client.Pass(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 200 |
205 gfx::BufferFormat gpu_format = static_cast<gfx::BufferFormat>(format); | 201 gfx::BufferFormat gpu_format = static_cast<gfx::BufferFormat>(format); |
206 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( | 202 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( |
207 gpu_format, decoder_->GetCapabilities())) { | 203 gpu_format, decoder_->GetCapabilities())) { |
208 LOG(ERROR) << "Format is not supported."; | 204 LOG(ERROR) << "Format is not supported."; |
209 return; | 205 return; |
210 } | 206 } |
211 | 207 |
212 gfx::Size gfx_size = size.To<gfx::Size>(); | 208 gfx::Size gfx_size = size.To<gfx::Size>(); |
213 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 209 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( |
214 gfx_size, gpu_format)) { | 210 gfx_size, gpu_format)) { |
215 LOG(ERROR) << "Invalid image size for format."; | 211 LOG(ERROR) << "Invalid image size for format."; |
216 return; | 212 return; |
217 } | 213 } |
218 | 214 |
219 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 215 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
220 internal_format, gpu_format)) { | 216 internal_format, gpu_format)) { |
221 LOG(ERROR) << "Incompatible image format."; | 217 LOG(ERROR) << "Incompatible image format."; |
222 return; | 218 return; |
223 } | 219 } |
224 | 220 |
225 if (type != gfx::SHARED_MEMORY_BUFFER) { | 221 if (type != gfx::SHARED_MEMORY_BUFFER) { |
226 NOTIMPLEMENTED(); | 222 NOTIMPLEMENTED(); |
227 return; | 223 return; |
228 } | 224 } |
229 | 225 |
230 gfx::GpuMemoryBufferHandle gfx_handle; | 226 gfx::GpuMemoryBufferHandle gfx_handle; |
231 // TODO(jam): create mojo enum for this and converter | 227 // TODO(jam): create mojo enum for this and converter |
232 gfx_handle.type = static_cast<gfx::GpuMemoryBufferType>(type); | 228 gfx_handle.type = static_cast<gfx::GpuMemoryBufferType>(type); |
233 gfx_handle.id = gfx::GpuMemoryBufferId(id); | 229 gfx_handle.id = gfx::GpuMemoryBufferId(id); |
234 | 230 |
235 MojoPlatformHandle platform_handle; | 231 MojoPlatformHandle platform_handle; |
236 MojoResult extract_result = MojoExtractPlatformHandle( | 232 MojoResult extract_result = MojoExtractPlatformHandle( |
237 memory_handle.release().value(), | 233 memory_handle.release().value(), &platform_handle); |
238 &platform_handle); | |
239 if (extract_result != MOJO_RESULT_OK) { | 234 if (extract_result != MOJO_RESULT_OK) { |
240 NOTREACHED(); | 235 NOTREACHED(); |
241 return; | 236 return; |
242 } | 237 } |
243 | 238 |
244 #if defined(OS_WIN) | 239 #if defined(OS_WIN) |
245 gfx_handle.handle = platform_handle; | 240 gfx_handle.handle = platform_handle; |
246 #else | 241 #else |
247 gfx_handle.handle = base::FileDescriptor(platform_handle, false); | 242 gfx_handle.handle = base::FileDescriptor(platform_handle, false); |
248 #endif | 243 #endif |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 296 |
302 void CommandBufferDriver::DestroyDecoder() { | 297 void CommandBufferDriver::DestroyDecoder() { |
303 if (decoder_) { | 298 if (decoder_) { |
304 bool have_context = decoder_->MakeCurrent(); | 299 bool have_context = decoder_->MakeCurrent(); |
305 decoder_->Destroy(have_context); | 300 decoder_->Destroy(have_context); |
306 decoder_.reset(); | 301 decoder_.reset(); |
307 } | 302 } |
308 } | 303 } |
309 | 304 |
310 } // namespace gles2 | 305 } // namespace gles2 |
OLD | NEW |