OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
11 #include "components/view_manager/gles2/command_buffer_type_conversions.h" | 11 #include "components/view_manager/gles2/command_buffer_type_conversions.h" |
12 #include "components/view_manager/gles2/mojo_buffer_backing.h" | 12 #include "components/view_manager/gles2/mojo_buffer_backing.h" |
13 #include "components/view_manager/gles2/mojo_gpu_memory_buffer.h" | |
14 #include "gpu/command_buffer/service/image_factory.h" | |
15 #include "mojo/platform_handle/platform_handle_functions.h" | |
13 | 16 |
14 namespace gles2 { | 17 namespace gles2 { |
15 | 18 |
16 namespace { | 19 namespace { |
17 | 20 |
18 bool CreateMapAndDupSharedBuffer(size_t size, | 21 bool CreateMapAndDupSharedBuffer(size_t size, |
19 void** memory, | 22 void** memory, |
20 mojo::ScopedSharedBufferHandle* handle, | 23 mojo::ScopedSharedBufferHandle* handle, |
21 mojo::ScopedSharedBufferHandle* duped) { | 24 mojo::ScopedSharedBufferHandle* duped) { |
22 MojoResult result = mojo::CreateSharedBuffer(NULL, size, handle); | 25 MojoResult result = mojo::CreateSharedBuffer(NULL, size, handle); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 } | 241 } |
239 | 242 |
240 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { | 243 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { |
241 return capabilities_; | 244 return capabilities_; |
242 } | 245 } |
243 | 246 |
244 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer, | 247 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer, |
245 size_t width, | 248 size_t width, |
246 size_t height, | 249 size_t height, |
247 unsigned internalformat) { | 250 unsigned internalformat) { |
248 // TODO(piman) | 251 int32 new_id = next_image_id_.GetNext(); |
249 NOTIMPLEMENTED(); | 252 |
250 return -1; | 253 mojo::SizePtr size = mojo::Size::New(); |
254 size->width = width; | |
yzshen1
2015/06/15 20:04:42
FYI, I tried to compile the patch on Windows and i
jam
2015/06/15 22:06:02
that's strange, i'm compiling on Windows and I don
yzshen1
2015/06/16 16:34:25
That is strange. I didn't explicitly set any gn ar
| |
255 size->height = height; | |
256 | |
257 MojoGpuMemoryBufferImpl* gpu_memory_buffer = | |
258 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); | |
259 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); | |
260 | |
261 bool requires_sync_point = false; | |
262 base::SharedMemoryHandle dupd_handle = | |
263 base::SharedMemory::DuplicateHandle(handle.handle); | |
264 #if defined(OS_WIN) | |
265 HANDLE platform_handle = dupd_handle; | |
266 #else | |
267 int platform_handle = dupd_handle.fd; | |
268 #endif | |
269 | |
270 if (handle.type != gfx::SHARED_MEMORY_BUFFER) { | |
271 requires_sync_point = true; | |
272 NOTIMPLEMENTED(); | |
273 return -1; | |
274 } | |
275 | |
276 MojoHandle mojo_handle = MOJO_HANDLE_INVALID; | |
277 MojoResult create_result = MojoCreatePlatformHandleWrapper( | |
278 platform_handle, &mojo_handle); | |
279 if (create_result != MOJO_RESULT_OK) { | |
280 NOTIMPLEMENTED(); | |
281 return -1; | |
282 } | |
283 mojo::ScopedHandle scoped_handle; | |
284 scoped_handle.reset(mojo::Handle(mojo_handle)); | |
285 command_buffer_->CreateImage(new_id, | |
286 scoped_handle.Pass(), | |
287 handle.type, | |
288 size.Pass(), | |
289 gpu_memory_buffer->GetFormat(), | |
290 internalformat); | |
291 if (requires_sync_point) { | |
292 NOTIMPLEMENTED(); | |
293 //gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, | |
danakj
2015/06/15 18:20:36
is a TODO needed?
jam
2015/06/15 22:06:01
Done.
| |
294 // InsertSyncPoint()); | |
piman
2015/06/15 18:14:33
nit: remove/add TODO?
jam
2015/06/15 22:06:01
Done.
| |
295 } | |
296 | |
297 return new_id; | |
251 } | 298 } |
252 | 299 |
253 void CommandBufferClientImpl::DestroyImage(int32 id) { | 300 void CommandBufferClientImpl::DestroyImage(int32 id) { |
254 // TODO(piman) | 301 command_buffer_->DestroyImage(id); |
255 NOTIMPLEMENTED(); | |
256 } | 302 } |
257 | 303 |
258 int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage( | 304 int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage( |
259 size_t width, | 305 size_t width, |
260 size_t height, | 306 size_t height, |
261 unsigned internalformat, | 307 unsigned internalformat, |
262 unsigned usage) { | 308 unsigned usage) { |
263 // TODO(piman) | 309 scoped_ptr<gfx::GpuMemoryBuffer> buffer(MojoGpuMemoryBufferImpl::Create( |
264 NOTIMPLEMENTED(); | 310 gfx::Size(width, height), |
265 return -1; | 311 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), |
312 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | |
313 if (!buffer) | |
314 return -1; | |
315 | |
316 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | |
266 } | 317 } |
267 | 318 |
268 uint32_t CommandBufferClientImpl::InsertSyncPoint() { | 319 uint32_t CommandBufferClientImpl::InsertSyncPoint() { |
269 command_buffer_->InsertSyncPoint(true); | 320 command_buffer_->InsertSyncPoint(true); |
270 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 321 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
271 } | 322 } |
272 | 323 |
273 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { | 324 uint32_t CommandBufferClientImpl::InsertFutureSyncPoint() { |
274 command_buffer_->InsertSyncPoint(false); | 325 command_buffer_->InsertSyncPoint(false); |
275 return sync_point_client_impl_->WaitForInsertSyncPoint(); | 326 return sync_point_client_impl_->WaitForInsertSyncPoint(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 385 |
335 void CommandBufferClientImpl::SetLock(base::Lock* lock) { | 386 void CommandBufferClientImpl::SetLock(base::Lock* lock) { |
336 } | 387 } |
337 | 388 |
338 bool CommandBufferClientImpl::IsGpuChannelLost() { | 389 bool CommandBufferClientImpl::IsGpuChannelLost() { |
339 // This is only possible for out-of-process command buffers. | 390 // This is only possible for out-of-process command buffers. |
340 return false; | 391 return false; |
341 } | 392 } |
342 | 393 |
343 } // namespace gles2 | 394 } // namespace gles2 |
OLD | NEW |