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

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

Issue 1854953002: Plumb GpuSwapBuffers completion from Mus GPU thread to WS thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nits 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void CommandBufferLocal::UpdateVSyncParameters(int64_t timebase, 399 void CommandBufferLocal::UpdateVSyncParameters(int64_t timebase,
400 int64_t interval) { 400 int64_t interval) {
401 if (client_) { 401 if (client_) {
402 client_thread_task_runner_->PostTask( 402 client_thread_task_runner_->PostTask(
403 FROM_HERE, 403 FROM_HERE,
404 base::Bind(&CommandBufferLocal::UpdateVSyncParametersOnClientThread, 404 base::Bind(&CommandBufferLocal::UpdateVSyncParametersOnClientThread,
405 weak_ptr_, timebase, interval)); 405 weak_ptr_, timebase, interval));
406 } 406 }
407 } 407 }
408 408
409 void CommandBufferLocal::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {
410 if (client_) {
411 client_thread_task_runner_->PostTask(
412 FROM_HERE,
413 base::Bind(&CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread,
414 weak_ptr_, result));
415 }
416 }
417
409 CommandBufferLocal::~CommandBufferLocal() {} 418 CommandBufferLocal::~CommandBufferLocal() {}
410 419
411 void CommandBufferLocal::TryUpdateState() { 420 void CommandBufferLocal::TryUpdateState() {
412 if (last_state_.error == gpu::error::kNoError) 421 if (last_state_.error == gpu::error::kNoError)
413 shared_state()->Read(&last_state_); 422 shared_state()->Read(&last_state_);
414 } 423 }
415 424
416 void CommandBufferLocal::MakeProgressAndUpdateState() { 425 void CommandBufferLocal::MakeProgressAndUpdateState() {
417 base::ThreadRestrictions::ScopedAllowWait allow_wait; 426 base::ThreadRestrictions::ScopedAllowWait allow_wait;
418 base::WaitableEvent event(true, false); 427 base::WaitableEvent event(true, false);
419 gpu::CommandBuffer::State state; 428 gpu::CommandBuffer::State state;
420 gpu_state_->command_buffer_task_runner()->PostTask( 429 gpu_state_->command_buffer_task_runner()->PostTask(
421 driver_.get(), 430 driver_.get(),
422 base::Bind(&CommandBufferLocal::MakeProgressOnGpuThread, 431 base::Bind(&CommandBufferLocal::MakeProgressOnGpuThread,
423 base::Unretained(this), base::Unretained(&event), 432 base::Unretained(this), base::Unretained(&event),
424 base::Unretained(&state))); 433 base::Unretained(&state)));
425 event.Wait(); 434 event.Wait();
426 if (state.generation - last_state_.generation < 0x80000000U) 435 if (state.generation - last_state_.generation < 0x80000000U)
427 last_state_ = state; 436 last_state_ = state;
428 } 437 }
429 438
430 void CommandBufferLocal::InitializeOnGpuThread(base::WaitableEvent* event, 439 void CommandBufferLocal::InitializeOnGpuThread(base::WaitableEvent* event,
431 bool* result) { 440 bool* result) {
432 driver_.reset(new CommandBufferDriver( 441 driver_.reset(new CommandBufferDriver(
433 gpu::CommandBufferNamespace::MOJO_LOCAL, 442 gpu::CommandBufferNamespace::MOJO_LOCAL,
434 gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id), 443 gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id),
435 widget_, gpu_state_)); 444 widget_, gpu_state_));
445 driver_->set_client(this);
436 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); 446 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState);
437 void* memory = nullptr; 447 void* memory = nullptr;
438 mojo::ScopedSharedBufferHandle duped; 448 mojo::ScopedSharedBufferHandle duped;
439 *result = CreateMapAndDupSharedBuffer(kSharedStateSize, &memory, 449 *result = CreateMapAndDupSharedBuffer(kSharedStateSize, &memory,
440 &shared_state_handle_, &duped); 450 &shared_state_handle_, &duped);
441 451
442 if (!*result) { 452 if (!*result) {
443 event->Signal(); 453 event->Signal();
444 return; 454 return;
445 } 455 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 if (client_) 544 if (client_)
535 client_->DidLoseContext(); 545 client_->DidLoseContext();
536 } 546 }
537 547
538 void CommandBufferLocal::UpdateVSyncParametersOnClientThread(int64_t timebase, 548 void CommandBufferLocal::UpdateVSyncParametersOnClientThread(int64_t timebase,
539 int64_t interval) { 549 int64_t interval) {
540 if (client_) 550 if (client_)
541 client_->UpdateVSyncParameters(timebase, interval); 551 client_->UpdateVSyncParameters(timebase, interval);
542 } 552 }
543 553
554 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread(
555 gfx::SwapResult result) {
556 if (client_)
557 client_->GpuCompletedSwapBuffers(result);
558 }
559
544 } // namespace mus 560 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698