Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: components/mus/gles2/command_buffer_local.cc

Issue 1857243005: Scan-out capable buffers (aka ui::NativePixmap) for Mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_local.h" 5 #include "components/mus/gles2/command_buffer_local.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 size_t height, 226 size_t height,
227 unsigned internal_format) { 227 unsigned internal_format) {
228 DCHECK(CalledOnValidThread()); 228 DCHECK(CalledOnValidThread());
229 int32_t new_id = ++next_image_id_; 229 int32_t new_id = ++next_image_id_;
230 mojo::SizePtr size = mojo::Size::New(); 230 mojo::SizePtr size = mojo::Size::New();
231 size->width = static_cast<int32_t>(width); 231 size->width = static_cast<int32_t>(width);
232 size->height = static_cast<int32_t>(height); 232 size->height = static_cast<int32_t>(height);
233 233
234 mus::MojoGpuMemoryBufferImpl* gpu_memory_buffer = 234 mus::MojoGpuMemoryBufferImpl* gpu_memory_buffer =
235 mus::MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); 235 mus::MojoGpuMemoryBufferImpl::FromClientBuffer(buffer);
236 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle();
237 236
238 bool requires_sync_point = false; 237 bool requires_sync_point = false;
239 if (handle.type != gfx::SHARED_MEMORY_BUFFER) { 238
240 requires_sync_point = true; 239 if (gpu_memory_buffer->GetBufferType() == gfx::SHARED_MEMORY_BUFFER) {
240 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle();
241 base::SharedMemoryHandle dupd_handle =
242 base::SharedMemory::DuplicateHandle(handle.handle);
Fady Samuel 2016/04/06 22:02:02 I don't think we need this. Please add a TODO to v
rjkroege 2016/04/06 22:45:45 Done.
243 #if defined(OS_WIN)
244 HANDLE platform_handle = dupd_handle.GetHandle();
245 #else
246 int platform_handle = dupd_handle.fd;
247 #endif
248
249 MojoHandle mojo_handle = MOJO_HANDLE_INVALID;
250 MojoResult create_result =
251 MojoCreatePlatformHandleWrapper(platform_handle, &mojo_handle);
252 // |MojoCreatePlatformHandleWrapper()| always takes the ownership of the
253 // |platform_handle|, so we don't need to close |platform_handle|.
254 if (create_result != MOJO_RESULT_OK) {
255 NOTIMPLEMENTED();
256 return -1;
257 }
258 mojo::ScopedHandle scoped_handle;
259 scoped_handle.reset(mojo::Handle(mojo_handle));
260
261 const int32_t format = static_cast<int32_t>(gpu_memory_buffer->GetFormat());
262 gpu_state_->command_buffer_task_runner()->PostTask(
263 driver_.get(),
264 base::Bind(&CommandBufferLocal::CreateImageOnGpuThread,
265 base::Unretained(this), new_id, base::Passed(&scoped_handle),
266 handle.type, base::Passed(&size), format, internal_format));
267 } else if (gpu_memory_buffer->GetBufferType() == gfx::OZONE_NATIVE_PIXMAP) {
268 gpu_state_->command_buffer_task_runner()->PostTask(
269 driver_.get(),
270 base::Bind(&CommandBufferLocal::CreateImageNativeOzoneOnGpuThread,
271 base::Unretained(this), new_id,
272 gpu_memory_buffer->GetBufferType(),
273 gpu_memory_buffer->GetSize(), gpu_memory_buffer->GetFormat(),
274 internal_format,
275 base::RetainedRef(gpu_memory_buffer->GetNativePixmap())));
276
277 } else {
241 NOTIMPLEMENTED(); 278 NOTIMPLEMENTED();
242 return -1; 279 return -1;
243 } 280 }
244 281
245 base::SharedMemoryHandle dupd_handle =
246 base::SharedMemory::DuplicateHandle(handle.handle);
247 #if defined(OS_WIN)
248 HANDLE platform_handle = dupd_handle.GetHandle();
249 #else
250 int platform_handle = dupd_handle.fd;
251 #endif
252
253 MojoHandle mojo_handle = MOJO_HANDLE_INVALID;
254 MojoResult create_result =
255 MojoCreatePlatformHandleWrapper(platform_handle, &mojo_handle);
256 // |MojoCreatePlatformHandleWrapper()| always takes the ownership of the
257 // |platform_handle|, so we don't need close |platform_handle|.
258 if (create_result != MOJO_RESULT_OK) {
259 NOTIMPLEMENTED();
260 return -1;
261 }
262 mojo::ScopedHandle scoped_handle;
263 scoped_handle.reset(mojo::Handle(mojo_handle));
264
265 const int32_t format = static_cast<int32_t>(gpu_memory_buffer->GetFormat());
266 gpu_state_->command_buffer_task_runner()->PostTask(
267 driver_.get(),
268 base::Bind(&CommandBufferLocal::CreateImageOnGpuThread,
269 base::Unretained(this), new_id, base::Passed(&scoped_handle),
270 handle.type, base::Passed(&size), format, internal_format));
271
272 if (requires_sync_point) { 282 if (requires_sync_point) {
273 NOTIMPLEMENTED(); 283 NOTIMPLEMENTED() << "Require sync points";
274 // TODO(jam): need to support this if we support types other than 284 // TODO(jam): need to support this if we support types other than
275 // SHARED_MEMORY_BUFFER. 285 // SHARED_MEMORY_BUFFER.
276 // gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, 286 // gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer,
277 // InsertSyncPoint()); 287 // InsertSyncPoint());
278 } 288 }
279 289
280 return new_id; 290 return new_id;
281 } 291 }
282 292
283 void CommandBufferLocal::DestroyImage(int32_t id) { 293 void CommandBufferLocal::DestroyImage(int32_t id) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 int32_t type, 514 int32_t type,
505 mojo::SizePtr size, 515 mojo::SizePtr size,
506 int32_t format, 516 int32_t format,
507 int32_t internal_format) { 517 int32_t internal_format) {
508 DCHECK(driver_->IsScheduled()); 518 DCHECK(driver_->IsScheduled());
509 driver_->CreateImage(id, std::move(memory_handle), type, std::move(size), 519 driver_->CreateImage(id, std::move(memory_handle), type, std::move(size),
510 format, internal_format); 520 format, internal_format);
511 return true; 521 return true;
512 } 522 }
513 523
524 bool CommandBufferLocal::CreateImageNativeOzoneOnGpuThread(
525 int32_t id,
526 int32_t type,
527 gfx::Size size,
528 gfx::BufferFormat format,
529 uint32_t internal_format,
530 ui::NativePixmap* pixmap) {
531 DCHECK(driver_->IsScheduled());
532 driver_->CreateImageNativeOzone(id, type, size, format, internal_format,
533 pixmap);
534 return true;
535 }
536
514 bool CommandBufferLocal::DestroyImageOnGpuThread(int32_t id) { 537 bool CommandBufferLocal::DestroyImageOnGpuThread(int32_t id) {
515 DCHECK(driver_->IsScheduled()); 538 DCHECK(driver_->IsScheduled());
516 driver_->DestroyImage(id); 539 driver_->DestroyImage(id);
517 return true; 540 return true;
518 } 541 }
519 542
520 bool CommandBufferLocal::MakeProgressOnGpuThread( 543 bool CommandBufferLocal::MakeProgressOnGpuThread(
521 base::WaitableEvent* event, 544 base::WaitableEvent* event,
522 gpu::CommandBuffer::State* state) { 545 gpu::CommandBuffer::State* state) {
523 DCHECK(driver_->IsScheduled()); 546 DCHECK(driver_->IsScheduled());
(...skipping 27 matching lines...) Expand all
551 client_->UpdateVSyncParameters(timebase, interval); 574 client_->UpdateVSyncParameters(timebase, interval);
552 } 575 }
553 576
554 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( 577 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread(
555 gfx::SwapResult result) { 578 gfx::SwapResult result) {
556 if (client_) 579 if (client_)
557 client_->GpuCompletedSwapBuffers(result); 580 client_->GpuCompletedSwapBuffers(result);
558 } 581 }
559 582
560 } // namespace mus 583 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698