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

Side by Side Diff: gpu/command_buffer/common/discardable_handle.cc

Issue 2814583002: Service/ClientDiscardableManager (Closed)
Patch Set: rebase Created 3 years, 7 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 (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 "gpu/command_buffer/common/discardable_handle.h" 5 #include "gpu/command_buffer/common/discardable_handle.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "gpu/command_buffer/common/buffer.h" 8 #include "gpu/command_buffer/common/buffer.h"
9 9
10 namespace gpu { 10 namespace gpu {
(...skipping 12 matching lines...) Expand all
23 DiscardableHandleBase::DiscardableHandleBase( 23 DiscardableHandleBase::DiscardableHandleBase(
24 const DiscardableHandleBase& other) = default; 24 const DiscardableHandleBase& other) = default;
25 DiscardableHandleBase::DiscardableHandleBase(DiscardableHandleBase&& other) = 25 DiscardableHandleBase::DiscardableHandleBase(DiscardableHandleBase&& other) =
26 default; 26 default;
27 DiscardableHandleBase::~DiscardableHandleBase() = default; 27 DiscardableHandleBase::~DiscardableHandleBase() = default;
28 DiscardableHandleBase& DiscardableHandleBase::operator=( 28 DiscardableHandleBase& DiscardableHandleBase::operator=(
29 const DiscardableHandleBase& other) = default; 29 const DiscardableHandleBase& other) = default;
30 DiscardableHandleBase& DiscardableHandleBase::operator=( 30 DiscardableHandleBase& DiscardableHandleBase::operator=(
31 DiscardableHandleBase&& other) = default; 31 DiscardableHandleBase&& other) = default;
32 32
33 bool DiscardableHandleBase::IsLockedForTesting() { 33 bool DiscardableHandleBase::IsLockedForTesting() const {
34 return kHandleLockedStart <= base::subtle::NoBarrier_Load(AsAtomic()); 34 return kHandleLockedStart <= base::subtle::NoBarrier_Load(AsAtomic());
35 } 35 }
36 36
37 bool DiscardableHandleBase::IsDeletedForTesting() { 37 bool DiscardableHandleBase::IsDeletedForTesting() const {
38 return kHandleDeleted == base::subtle::NoBarrier_Load(AsAtomic()); 38 return kHandleDeleted == base::subtle::NoBarrier_Load(AsAtomic());
39 } 39 }
40 40
41 volatile base::subtle::Atomic32* DiscardableHandleBase::AsAtomic() const { 41 volatile base::subtle::Atomic32* DiscardableHandleBase::AsAtomic() const {
42 return reinterpret_cast<volatile base::subtle::Atomic32*>( 42 return reinterpret_cast<volatile base::subtle::Atomic32*>(
43 buffer_->GetDataAddress(byte_offset_, sizeof(base::subtle::Atomic32))); 43 buffer_->GetDataAddress(byte_offset_, sizeof(base::subtle::Atomic32)));
44 } 44 }
45 45
46 ClientDiscardableHandle::ClientDiscardableHandle(scoped_refptr<Buffer> buffer, 46 ClientDiscardableHandle::ClientDiscardableHandle(scoped_refptr<Buffer> buffer,
47 uint32_t byte_offset, 47 uint32_t byte_offset,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 bool ServiceDiscardableHandle::Delete() { 109 bool ServiceDiscardableHandle::Delete() {
110 // No barrier is needed as all GPU process access happens on a single thread, 110 // No barrier is needed as all GPU process access happens on a single thread,
111 // and communication of dependent data between the GPU process and the 111 // and communication of dependent data between the GPU process and the
112 // renderer process happens across the command buffer and includes barriers. 112 // renderer process happens across the command buffer and includes barriers.
113 return kHandleUnlocked == base::subtle::NoBarrier_CompareAndSwap( 113 return kHandleUnlocked == base::subtle::NoBarrier_CompareAndSwap(
114 AsAtomic(), kHandleUnlocked, kHandleDeleted); 114 AsAtomic(), kHandleUnlocked, kHandleDeleted);
115 } 115 }
116 116
117 void ServiceDiscardableHandle::ForceDelete() {
118 // No barrier is needed as all GPU process access happens on a single thread,
119 // and communication of dependent data between the GPU process and the
120 // renderer process happens across the command buffer and includes barriers.
121 base::subtle::NoBarrier_Store(AsAtomic(), kHandleDeleted);
122 }
123
117 } // namespace gpu 124 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/discardable_handle.h ('k') | gpu/command_buffer/common/gles2_cmd_format_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698