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

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

Issue 2028193002: Migrate WaitableEvent to enum-based constructor in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: rm comment explaining true/false Created 4 years, 6 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
« no previous file with comments | « components/leveldb/leveldb_mojo_proxy.cc ('k') | components/mus/gles2/gpu_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // and it will be deleted on the GPU thread. So we have to detach it from the 94 // and it will be deleted on the GPU thread. So we have to detach it from the
95 // client thread first. 95 // client thread first.
96 DetachFromThread(); 96 DetachFromThread();
97 97
98 weak_factory_.InvalidateWeakPtrs(); 98 weak_factory_.InvalidateWeakPtrs();
99 // CommandBufferLocal is initialized on the GPU thread with 99 // CommandBufferLocal is initialized on the GPU thread with
100 // InitializeOnGpuThread(), so we need delete memebers on the GPU thread 100 // InitializeOnGpuThread(), so we need delete memebers on the GPU thread
101 // too. Additionally we need to make sure we are deleted before returning, 101 // too. Additionally we need to make sure we are deleted before returning,
102 // otherwise we may attempt to use the AcceleratedWidget which has since been 102 // otherwise we may attempt to use the AcceleratedWidget which has since been
103 // destroyed. 103 // destroyed.
104 base::WaitableEvent event(true, false); 104 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
105 base::WaitableEvent::InitialState::NOT_SIGNALED);
105 gpu_state_->command_buffer_task_runner()->PostTask( 106 gpu_state_->command_buffer_task_runner()->PostTask(
106 driver_.get(), base::Bind(&CommandBufferLocal::DeleteOnGpuThread, 107 driver_.get(), base::Bind(&CommandBufferLocal::DeleteOnGpuThread,
107 base::Unretained(this), &event)); 108 base::Unretained(this), &event));
108 event.Wait(); 109 event.Wait();
109 } 110 }
110 111
111 bool CommandBufferLocal::Initialize() { 112 bool CommandBufferLocal::Initialize() {
112 DCHECK(CalledOnValidThread()); 113 DCHECK(CalledOnValidThread());
113 base::ThreadRestrictions::ScopedAllowWait allow_wait; 114 base::ThreadRestrictions::ScopedAllowWait allow_wait;
114 base::WaitableEvent event(true, false); 115 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
116 base::WaitableEvent::InitialState::NOT_SIGNALED);
115 bool result = false; 117 bool result = false;
116 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask( 118 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask(
117 FROM_HERE, 119 FROM_HERE,
118 base::Bind(&CommandBufferLocal::InitializeOnGpuThread, 120 base::Bind(&CommandBufferLocal::InitializeOnGpuThread,
119 base::Unretained(this), base::Unretained(&event), 121 base::Unretained(this), base::Unretained(&event),
120 base::Unretained(&result))); 122 base::Unretained(&result)));
121 event.Wait(); 123 event.Wait();
122 return result; 124 return result;
123 } 125 }
124 126
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 426
425 CommandBufferLocal::~CommandBufferLocal() {} 427 CommandBufferLocal::~CommandBufferLocal() {}
426 428
427 void CommandBufferLocal::TryUpdateState() { 429 void CommandBufferLocal::TryUpdateState() {
428 if (last_state_.error == gpu::error::kNoError) 430 if (last_state_.error == gpu::error::kNoError)
429 shared_state()->Read(&last_state_); 431 shared_state()->Read(&last_state_);
430 } 432 }
431 433
432 void CommandBufferLocal::MakeProgressAndUpdateState() { 434 void CommandBufferLocal::MakeProgressAndUpdateState() {
433 base::ThreadRestrictions::ScopedAllowWait allow_wait; 435 base::ThreadRestrictions::ScopedAllowWait allow_wait;
434 base::WaitableEvent event(true, false); 436 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
437 base::WaitableEvent::InitialState::NOT_SIGNALED);
435 gpu::CommandBuffer::State state; 438 gpu::CommandBuffer::State state;
436 gpu_state_->command_buffer_task_runner()->PostTask( 439 gpu_state_->command_buffer_task_runner()->PostTask(
437 driver_.get(), 440 driver_.get(),
438 base::Bind(&CommandBufferLocal::MakeProgressOnGpuThread, 441 base::Bind(&CommandBufferLocal::MakeProgressOnGpuThread,
439 base::Unretained(this), base::Unretained(&event), 442 base::Unretained(this), base::Unretained(&event),
440 base::Unretained(&state))); 443 base::Unretained(&state)));
441 event.Wait(); 444 event.Wait();
442 if (state.generation - last_state_.generation < 0x80000000U) 445 if (state.generation - last_state_.generation < 0x80000000U)
443 last_state_ = state; 446 last_state_ = state;
444 } 447 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 client_->UpdateVSyncParameters(timebase, interval); 576 client_->UpdateVSyncParameters(timebase, interval);
574 } 577 }
575 578
576 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread( 579 void CommandBufferLocal::OnGpuCompletedSwapBuffersOnClientThread(
577 gfx::SwapResult result) { 580 gfx::SwapResult result) {
578 if (client_) 581 if (client_)
579 client_->GpuCompletedSwapBuffers(result); 582 client_->GpuCompletedSwapBuffers(result);
580 } 583 }
581 584
582 } // namespace mus 585 } // namespace mus
OLDNEW
« no previous file with comments | « components/leveldb/leveldb_mojo_proxy.cc ('k') | components/mus/gles2/gpu_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698