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

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

Issue 1686543004: mus: Modify mojo command buffer to match current chrome gpu ipc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review issues Created 4 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "components/mus/gles2/command_buffer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "components/mus/gles2/command_buffer_driver.h" 10 #include "components/mus/gles2/command_buffer_driver.h"
11 #include "components/mus/gles2/command_buffer_impl_observer.h"
12 #include "components/mus/gles2/command_buffer_type_conversions.h" 11 #include "components/mus/gles2/command_buffer_type_conversions.h"
13 #include "components/mus/gles2/gpu_state.h" 12 #include "components/mus/gles2/gpu_state.h"
14 #include "gpu/command_buffer/service/sync_point_manager.h" 13 #include "gpu/command_buffer/service/sync_point_manager.h"
15 14
16 namespace mus { 15 namespace mus {
17 16
18 namespace { 17 namespace {
19 18
20 uint64_t g_next_command_buffer_id = 0; 19 uint64_t g_next_command_buffer_id = 0;
21 20
(...skipping 24 matching lines...) Expand all
46 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override {} 45 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override {}
47 46
48 CommandBufferImpl* command_buffer_; 47 CommandBufferImpl* command_buffer_;
49 48
50 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl); 49 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl);
51 }; 50 };
52 51
53 CommandBufferImpl::CommandBufferImpl( 52 CommandBufferImpl::CommandBufferImpl(
54 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request, 53 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request,
55 scoped_refptr<GpuState> gpu_state) 54 scoped_refptr<GpuState> gpu_state)
56 : gpu_state_(gpu_state), observer_(nullptr) { 55 : gpu_state_(gpu_state) {
57 // Bind |CommandBufferImpl| to the |request| in the GPU control thread. 56 // Bind |CommandBufferImpl| to the |request| in the GPU control thread.
58 gpu_state_->control_task_runner()->PostTask( 57 gpu_state_->control_task_runner()->PostTask(
59 FROM_HERE, 58 FROM_HERE,
60 base::Bind(&CommandBufferImpl::BindToRequest, 59 base::Bind(&CommandBufferImpl::BindToRequest,
61 base::Unretained(this), base::Passed(&request))); 60 base::Unretained(this), base::Passed(&request)));
62 } 61 }
63 62
64 void CommandBufferImpl::DidLoseContext(uint32_t reason) { 63 void CommandBufferImpl::DidLoseContext(uint32_t reason) {
65 driver_->set_client(nullptr); 64 driver_->set_client(nullptr);
66 loss_observer_->DidLoseContext(reason); 65 client_->Destroyed(reason, gpu::error::kLostContext);
67 } 66 }
68 67
69 CommandBufferImpl::~CommandBufferImpl() { 68 CommandBufferImpl::~CommandBufferImpl() {
70 if (observer_)
71 observer_->OnCommandBufferImplDestroyed();
72 } 69 }
73 70
74 void CommandBufferImpl::Initialize( 71 void CommandBufferImpl::Initialize(
75 mus::mojom::CommandBufferLostContextObserverPtr loss_observer, 72 mus::mojom::CommandBufferClientPtr client,
76 mojo::ScopedSharedBufferHandle shared_state, 73 mojo::ScopedSharedBufferHandle shared_state,
77 mojo::Array<int32_t> attribs, 74 mojo::Array<int32_t> attribs,
78 const mojom::CommandBuffer::InitializeCallback& callback) { 75 const mojom::CommandBuffer::InitializeCallback& callback) {
79 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask( 76 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask(
80 FROM_HERE, 77 FROM_HERE,
81 base::Bind(&CommandBufferImpl::InitializeOnGpuThread, 78 base::Bind(&CommandBufferImpl::InitializeOnGpuThread,
82 base::Unretained(this), base::Passed(&loss_observer), 79 base::Unretained(this), base::Passed(&client),
83 base::Passed(&shared_state), base::Passed(&attribs), 80 base::Passed(&shared_state), base::Passed(&attribs),
84 base::Bind(&RunInitializeCallback, callback))); 81 base::Bind(&RunInitializeCallback, callback)));
85 } 82 }
86 83
87 void CommandBufferImpl::SetGetBuffer(int32_t buffer) { 84 void CommandBufferImpl::SetGetBuffer(int32_t buffer) {
88 gpu_state_->command_buffer_task_runner()->PostTask( 85 gpu_state_->command_buffer_task_runner()->PostTask(
89 driver_.get(), base::Bind(&CommandBufferImpl::SetGetBufferOnGpuThread, 86 driver_.get(), base::Bind(&CommandBufferImpl::SetGetBufferOnGpuThread,
90 base::Unretained(this), buffer)); 87 base::Unretained(this), buffer));
91 } 88 }
92 89
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 base::Unretained(this), id, base::Passed(&memory_handle), type, 136 base::Unretained(this), id, base::Passed(&memory_handle), type,
140 base::Passed(&size), format, internal_format)); 137 base::Passed(&size), format, internal_format));
141 } 138 }
142 139
143 void CommandBufferImpl::DestroyImage(int32_t id) { 140 void CommandBufferImpl::DestroyImage(int32_t id) {
144 gpu_state_->command_buffer_task_runner()->PostTask( 141 gpu_state_->command_buffer_task_runner()->PostTask(
145 driver_.get(), base::Bind(&CommandBufferImpl::DestroyImageOnGpuThread, 142 driver_.get(), base::Bind(&CommandBufferImpl::DestroyImageOnGpuThread,
146 base::Unretained(this), id)); 143 base::Unretained(this), id));
147 } 144 }
148 145
146 void CommandBufferImpl::CreateStreamTexture(
147 uint32_t client_texture_id,
148 const mojom::CommandBuffer::CreateStreamTextureCallback& callback) {
149 NOTIMPLEMENTED();
150 }
151
152 void CommandBufferImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) {
153 NOTIMPLEMENTED();
154 }
155
156 void CommandBufferImpl::SignalQuery(uint32_t query, uint32_t signal_id) {
157 NOTIMPLEMENTED();
158 }
159
160 void CommandBufferImpl::SignalSyncToken(const gpu::SyncToken& sync_token,
161 uint32_t signal_id) {
162 NOTIMPLEMENTED();
163 }
164
165 void CommandBufferImpl::WaitForGetOffsetInRange(
166 int32_t start, int32_t end,
167 const mojom::CommandBuffer::WaitForGetOffsetInRangeCallback& callback) {
168 NOTIMPLEMENTED();
169 }
170
171 void CommandBufferImpl::WaitForTokenInRange(
172 int32_t start, int32_t end,
173 const mojom::CommandBuffer::WaitForGetOffsetInRangeCallback& callback) {
174 NOTIMPLEMENTED();
175 }
176
149 void CommandBufferImpl::BindToRequest( 177 void CommandBufferImpl::BindToRequest(
150 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request) { 178 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request) {
151 binding_.reset( 179 binding_.reset(
152 new mojo::Binding<mus::mojom::CommandBuffer>(this, std::move(request))); 180 new mojo::Binding<mus::mojom::CommandBuffer>(this, std::move(request)));
153 binding_->set_connection_error_handler([this]() { OnConnectionError(); }); 181 binding_->set_connection_error_handler([this]() { OnConnectionError(); });
154 } 182 }
155 183
156 void CommandBufferImpl::InitializeOnGpuThread( 184 void CommandBufferImpl::InitializeOnGpuThread(
157 mojom::CommandBufferLostContextObserverPtr loss_observer, 185 mojom::CommandBufferClientPtr client,
158 mojo::ScopedSharedBufferHandle shared_state, 186 mojo::ScopedSharedBufferHandle shared_state,
159 mojo::Array<int32_t> attribs, 187 mojo::Array<int32_t> attribs,
160 const base::Callback< 188 const base::Callback<
161 void(mojom::CommandBufferInitializeResultPtr)>& callback) { 189 void(mojom::CommandBufferInitializeResultPtr)>& callback) {
162 DCHECK(!driver_); 190 DCHECK(!driver_);
163 driver_.reset(new CommandBufferDriver( 191 driver_.reset(new CommandBufferDriver(
164 gpu::CommandBufferNamespace::MOJO, ++g_next_command_buffer_id, 192 gpu::CommandBufferNamespace::MOJO, ++g_next_command_buffer_id,
165 gfx::kNullAcceleratedWidget, gpu_state_)); 193 gfx::kNullAcceleratedWidget, gpu_state_));
166 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this))); 194 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this)));
167 loss_observer_ = mojo::MakeProxy(loss_observer.PassInterface()); 195 client_ = mojo::MakeProxy(client.PassInterface());
168 bool result = 196 bool result =
169 driver_->Initialize(std::move(shared_state), std::move(attribs)); 197 driver_->Initialize(std::move(shared_state), std::move(attribs));
170 mojom::CommandBufferInitializeResultPtr initialize_result; 198 mojom::CommandBufferInitializeResultPtr initialize_result;
171 if (result) { 199 if (result) {
172 initialize_result = mojom::CommandBufferInitializeResult::New(); 200 initialize_result = mojom::CommandBufferInitializeResult::New();
173 initialize_result->command_buffer_namespace = driver_->GetNamespaceID(); 201 initialize_result->command_buffer_namespace = driver_->GetNamespaceID();
174 initialize_result->command_buffer_id = driver_->GetCommandBufferID(); 202 initialize_result->command_buffer_id = driver_->GetCommandBufferID();
175 initialize_result->capabilities = driver_->GetCapabilities(); 203 initialize_result->capabilities = driver_->GetCapabilities();
176 } 204 }
177 gpu_state_->control_task_runner()->PostTask( 205 gpu_state_->control_task_runner()->PostTask(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 driver_.get(), base::Bind(&CommandBufferImpl::DeleteOnGpuThread, 283 driver_.get(), base::Bind(&CommandBufferImpl::DeleteOnGpuThread,
256 base::Unretained(this))); 284 base::Unretained(this)));
257 } 285 }
258 286
259 bool CommandBufferImpl::DeleteOnGpuThread() { 287 bool CommandBufferImpl::DeleteOnGpuThread() {
260 delete this; 288 delete this;
261 return true; 289 return true;
262 } 290 }
263 291
264 } // namespace mus 292 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_impl.h ('k') | components/mus/gles2/command_buffer_impl_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698