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 "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/mus/gles2/command_buffer_type_conversions.h" | 10 #include "components/mus/gles2/command_buffer_type_conversions.h" |
(...skipping 14 matching lines...) Expand all Loading... |
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 mus { |
36 | 36 |
37 CommandBufferDriver::Client::~Client() {} | 37 CommandBufferDriver::Client::~Client() {} |
38 | 38 |
39 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) | 39 CommandBufferDriver::CommandBufferDriver(scoped_refptr<GpuState> gpu_state) |
40 : client_(nullptr), gpu_state_(gpu_state), weak_factory_(this) {} | 40 : client_(nullptr), gpu_state_(gpu_state), weak_factory_(this) {} |
41 | 41 |
42 CommandBufferDriver::~CommandBufferDriver() { | 42 CommandBufferDriver::~CommandBufferDriver() { |
43 DestroyDecoder(); | 43 DestroyDecoder(); |
44 } | 44 } |
45 | 45 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); | 124 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); |
125 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 125 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
126 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); | 126 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); |
127 command_buffer_->SetParseErrorCallback( | 127 command_buffer_->SetParseErrorCallback( |
128 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); | 128 base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); |
129 | 129 |
130 // TODO(piman): other callbacks | 130 // TODO(piman): other callbacks |
131 | 131 |
132 const size_t kSize = sizeof(gpu::CommandBufferSharedState); | 132 const size_t kSize = sizeof(gpu::CommandBufferSharedState); |
133 scoped_ptr<gpu::BufferBacking> backing( | 133 scoped_ptr<gpu::BufferBacking> backing( |
134 gles2::MojoBufferBacking::Create(shared_state.Pass(), kSize)); | 134 MojoBufferBacking::Create(shared_state.Pass(), kSize)); |
135 if (!backing) | 135 if (!backing) |
136 return false; | 136 return false; |
137 | 137 |
138 command_buffer_->SetSharedStateBuffer(backing.Pass()); | 138 command_buffer_->SetSharedStateBuffer(backing.Pass()); |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 void CommandBufferDriver::SetGetBuffer(int32_t buffer) { | 142 void CommandBufferDriver::SetGetBuffer(int32_t buffer) { |
143 command_buffer_->SetGetBuffer(buffer); | 143 command_buffer_->SetGetBuffer(buffer); |
144 } | 144 } |
(...skipping 15 matching lines...) Expand all Loading... |
160 mojo::CommandBufferState::From(command_buffer_->GetLastState())); | 160 mojo::CommandBufferState::From(command_buffer_->GetLastState())); |
161 } | 161 } |
162 | 162 |
163 void CommandBufferDriver::RegisterTransferBuffer( | 163 void CommandBufferDriver::RegisterTransferBuffer( |
164 int32_t id, | 164 int32_t id, |
165 mojo::ScopedSharedBufferHandle transfer_buffer, | 165 mojo::ScopedSharedBufferHandle transfer_buffer, |
166 uint32_t size) { | 166 uint32_t size) { |
167 // Take ownership of the memory and map it into this process. | 167 // Take ownership of the memory and map it into this process. |
168 // This validates the size. | 168 // This validates the size. |
169 scoped_ptr<gpu::BufferBacking> backing( | 169 scoped_ptr<gpu::BufferBacking> backing( |
170 gles2::MojoBufferBacking::Create(transfer_buffer.Pass(), size)); | 170 MojoBufferBacking::Create(transfer_buffer.Pass(), size)); |
171 if (!backing) { | 171 if (!backing) { |
172 DVLOG(0) << "Failed to map shared memory."; | 172 DVLOG(0) << "Failed to map shared memory."; |
173 return; | 173 return; |
174 } | 174 } |
175 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); | 175 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); |
176 } | 176 } |
177 | 177 |
178 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { | 178 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { |
179 command_buffer_->DestroyTransferBuffer(id); | 179 command_buffer_->DestroyTransferBuffer(id); |
180 } | 180 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 void CommandBufferDriver::DestroyDecoder() { | 297 void CommandBufferDriver::DestroyDecoder() { |
298 if (decoder_) { | 298 if (decoder_) { |
299 bool have_context = decoder_->MakeCurrent(); | 299 bool have_context = decoder_->MakeCurrent(); |
300 decoder_->Destroy(have_context); | 300 decoder_->Destroy(have_context); |
301 decoder_.reset(); | 301 decoder_.reset(); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 } // namespace gles2 | 305 } // namespace mus |
OLD | NEW |