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

Side by Side Diff: components/mus/gles2/command_buffer_impl.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 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"
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 void RunMakeProgressCallback( 27 void RunMakeProgressCallback(
28 const mojom::CommandBuffer::MakeProgressCallback& callback, 28 const mojom::CommandBuffer::MakeProgressCallback& callback,
29 const gpu::CommandBuffer::State& state) { 29 const gpu::CommandBuffer::State& state) {
30 callback.Run(state); 30 callback.Run(state);
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 class CommandBufferImpl::CommandBufferDriverClientImpl
36 : public CommandBufferDriver::Client {
37 public:
38 explicit CommandBufferDriverClientImpl(CommandBufferImpl* command_buffer)
39 : command_buffer_(command_buffer) {}
40
41 private:
42 void DidLoseContext(uint32_t reason) override {
43 command_buffer_->DidLoseContext(reason);
44 }
45 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override {}
46
47 CommandBufferImpl* command_buffer_;
48
49 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl);
50 };
51
52 CommandBufferImpl::CommandBufferImpl( 35 CommandBufferImpl::CommandBufferImpl(
53 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request, 36 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request,
54 scoped_refptr<GpuState> gpu_state) 37 scoped_refptr<GpuState> gpu_state)
55 : gpu_state_(gpu_state) { 38 : gpu_state_(gpu_state) {
56 // Bind |CommandBufferImpl| to the |request| in the GPU control thread. 39 // Bind |CommandBufferImpl| to the |request| in the GPU control thread.
57 gpu_state_->control_task_runner()->PostTask( 40 gpu_state_->control_task_runner()->PostTask(
58 FROM_HERE, 41 FROM_HERE,
59 base::Bind(&CommandBufferImpl::BindToRequest, 42 base::Bind(&CommandBufferImpl::BindToRequest,
60 base::Unretained(this), base::Passed(&request))); 43 base::Unretained(this), base::Passed(&request)));
61 } 44 }
62 45
63 void CommandBufferImpl::DidLoseContext(uint32_t reason) { 46 void CommandBufferImpl::DidLoseContext(uint32_t reason) {
64 driver_->set_client(nullptr); 47 driver_->set_client(nullptr);
65 client_->Destroyed(reason, gpu::error::kLostContext); 48 client_->Destroyed(reason, gpu::error::kLostContext);
66 } 49 }
67 50
51 void CommandBufferImpl::UpdateVSyncParameters(int64_t timebase,
52 int64_t interval) {}
53
54 void CommandBufferImpl::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {}
55
68 CommandBufferImpl::~CommandBufferImpl() { 56 CommandBufferImpl::~CommandBufferImpl() {
69 } 57 }
70 58
71 void CommandBufferImpl::Initialize( 59 void CommandBufferImpl::Initialize(
72 mus::mojom::CommandBufferClientPtr client, 60 mus::mojom::CommandBufferClientPtr client,
73 mojo::ScopedSharedBufferHandle shared_state, 61 mojo::ScopedSharedBufferHandle shared_state,
74 mojo::Array<int32_t> attribs, 62 mojo::Array<int32_t> attribs,
75 const mojom::CommandBuffer::InitializeCallback& callback) { 63 const mojom::CommandBuffer::InitializeCallback& callback) {
76 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask( 64 gpu_state_->command_buffer_task_runner()->task_runner()->PostTask(
77 FROM_HERE, 65 FROM_HERE,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 mojom::CommandBufferClientPtr client, 173 mojom::CommandBufferClientPtr client,
186 mojo::ScopedSharedBufferHandle shared_state, 174 mojo::ScopedSharedBufferHandle shared_state,
187 mojo::Array<int32_t> attribs, 175 mojo::Array<int32_t> attribs,
188 const base::Callback< 176 const base::Callback<
189 void(mojom::CommandBufferInitializeResultPtr)>& callback) { 177 void(mojom::CommandBufferInitializeResultPtr)>& callback) {
190 DCHECK(!driver_); 178 DCHECK(!driver_);
191 driver_.reset(new CommandBufferDriver( 179 driver_.reset(new CommandBufferDriver(
192 gpu::CommandBufferNamespace::MOJO, 180 gpu::CommandBufferNamespace::MOJO,
193 gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id), 181 gpu::CommandBufferId::FromUnsafeValue(++g_next_command_buffer_id),
194 gfx::kNullAcceleratedWidget, gpu_state_)); 182 gfx::kNullAcceleratedWidget, gpu_state_));
195 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this))); 183 driver_->set_client(this);
196 client_ = mojo::MakeProxy(client.PassInterface()); 184 client_ = mojo::MakeProxy(client.PassInterface());
197 bool result = 185 bool result =
198 driver_->Initialize(std::move(shared_state), std::move(attribs)); 186 driver_->Initialize(std::move(shared_state), std::move(attribs));
199 mojom::CommandBufferInitializeResultPtr initialize_result; 187 mojom::CommandBufferInitializeResultPtr initialize_result;
200 if (result) { 188 if (result) {
201 initialize_result = mojom::CommandBufferInitializeResult::New(); 189 initialize_result = mojom::CommandBufferInitializeResult::New();
202 initialize_result->command_buffer_namespace = driver_->GetNamespaceID(); 190 initialize_result->command_buffer_namespace = driver_->GetNamespaceID();
203 initialize_result->command_buffer_id = 191 initialize_result->command_buffer_id =
204 driver_->GetCommandBufferID().GetUnsafeValue(); 192 driver_->GetCommandBufferID().GetUnsafeValue();
205 initialize_result->capabilities = driver_->GetCapabilities(); 193 initialize_result->capabilities = driver_->GetCapabilities();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 bool CommandBufferImpl::DeleteOnGpuThread() { 284 bool CommandBufferImpl::DeleteOnGpuThread() {
297 delete this; 285 delete this;
298 return true; 286 return true;
299 } 287 }
300 288
301 void CommandBufferImpl::DeleteOnGpuThread2() { 289 void CommandBufferImpl::DeleteOnGpuThread2() {
302 delete this; 290 delete this;
303 } 291 }
304 292
305 } // namespace mus 293 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698