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

Side by Side Diff: gpu/command_buffer/service/query_manager.cc

Issue 500243002: Remove implicit conversions from scoped_refptr to T* in gpu/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert silliness Created 6 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service/query_manager.h" 5 #include "gpu/command_buffer/service/query_manager.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool AsyncPixelTransfersCompletedQuery::Begin() { 81 bool AsyncPixelTransfersCompletedQuery::Begin() {
82 return true; 82 return true;
83 } 83 }
84 84
85 bool AsyncPixelTransfersCompletedQuery::End( 85 bool AsyncPixelTransfersCompletedQuery::End(
86 base::subtle::Atomic32 submit_count) { 86 base::subtle::Atomic32 submit_count) {
87 // Get the real shared memory since it might need to be duped to prevent 87 // Get the real shared memory since it might need to be duped to prevent
88 // use-after-free of the memory. 88 // use-after-free of the memory.
89 scoped_refptr<Buffer> buffer = 89 scoped_refptr<Buffer> buffer =
90 manager()->decoder()->GetSharedMemoryBuffer(shm_id()); 90 manager()->decoder()->GetSharedMemoryBuffer(shm_id());
91 if (!buffer) 91 if (!buffer.get())
92 return false; 92 return false;
93 AsyncMemoryParams mem_params(buffer, shm_offset(), sizeof(QuerySync)); 93 AsyncMemoryParams mem_params(buffer, shm_offset(), sizeof(QuerySync));
94 if (!mem_params.GetDataAddress()) 94 if (!mem_params.GetDataAddress())
95 return false; 95 return false;
96 96
97 observer_ = new AsyncPixelTransferCompletionObserverImpl(submit_count); 97 observer_ = new AsyncPixelTransferCompletionObserverImpl(submit_count);
98 98
99 // Ask AsyncPixelTransferDelegate to run completion callback after all 99 // Ask AsyncPixelTransferDelegate to run completion callback after all
100 // previous async transfers are done. No guarantee that callback is run 100 // previous async transfers are done. No guarantee that callback is run
101 // on the current thread. 101 // on the current thread.
102 manager()->decoder()->GetAsyncPixelTransferManager() 102 manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion(
103 ->AsyncNotifyCompletion(mem_params, observer_); 103 mem_params, observer_.get());
104 104
105 return AddToPendingTransferQueue(submit_count); 105 return AddToPendingTransferQueue(submit_count);
106 } 106 }
107 107
108 bool AsyncPixelTransfersCompletedQuery::Process() { 108 bool AsyncPixelTransfersCompletedQuery::Process() {
109 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>( 109 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>(
110 shm_id(), shm_offset(), sizeof(*sync)); 110 shm_id(), shm_offset(), sizeof(*sync));
111 if (!sync) 111 if (!sync)
112 return false; 112 return false;
113 113
114 // Check if completion callback has been run. sync->process_count atomicity 114 // Check if completion callback has been run. sync->process_count atomicity
115 // is guaranteed as this is already used to notify client of a completed 115 // is guaranteed as this is already used to notify client of a completed
116 // query. 116 // query.
117 if (base::subtle::Acquire_Load(&sync->process_count) != submit_count()) 117 if (base::subtle::Acquire_Load(&sync->process_count) != submit_count())
118 return true; 118 return true;
119 119
120 UnmarkAsPending(); 120 UnmarkAsPending();
121 return true; 121 return true;
122 } 122 }
123 123
124 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { 124 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) {
125 if (!IsDeleted()) { 125 if (!IsDeleted()) {
126 MarkAsDeleted(); 126 MarkAsDeleted();
127 } 127 }
128 } 128 }
129 129
130 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() { 130 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() {
131 if (observer_) 131 if (observer_.get())
132 observer_->Cancel(); 132 observer_->Cancel();
133 } 133 }
134 134
135 } // namespace 135 } // namespace
136 136
137 class AllSamplesPassedQuery : public QueryManager::Query { 137 class AllSamplesPassedQuery : public QueryManager::Query {
138 public: 138 public:
139 AllSamplesPassedQuery( 139 AllSamplesPassedQuery(
140 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, 140 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset,
141 GLuint service_id); 141 GLuint service_id);
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { 738 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) {
739 DCHECK(query); 739 DCHECK(query);
740 if (!RemovePendingQuery(query)) { 740 if (!RemovePendingQuery(query)) {
741 return false; 741 return false;
742 } 742 }
743 return query->End(submit_count); 743 return query->End(submit_count);
744 } 744 }
745 745
746 } // namespace gles2 746 } // namespace gles2
747 } // namespace gpu 747 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | gpu/command_buffer/service/texture_definition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698