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

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

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "components/mus/gles2/command_buffer_driver.h" 9 #include "components/mus/gles2/command_buffer_driver.h"
10 #include "components/mus/gles2/command_buffer_impl_observer.h" 10 #include "components/mus/gles2/command_buffer_impl_observer.h"
(...skipping 18 matching lines...) Expand all
29 29
30 private: 30 private:
31 void DidLoseContext() override { command_buffer_->DidLoseContext(); } 31 void DidLoseContext() override { command_buffer_->DidLoseContext(); }
32 32
33 CommandBufferImpl* command_buffer_; 33 CommandBufferImpl* command_buffer_;
34 34
35 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl); 35 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl);
36 }; 36 };
37 37
38 CommandBufferImpl::CommandBufferImpl( 38 CommandBufferImpl::CommandBufferImpl(
39 mojo::InterfaceRequest<mojo::CommandBuffer> request, 39 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request,
40 scoped_refptr<GpuState> gpu_state, 40 scoped_refptr<GpuState> gpu_state,
41 scoped_ptr<CommandBufferDriver> driver) 41 scoped_ptr<CommandBufferDriver> driver)
42 : gpu_state_(gpu_state), 42 : gpu_state_(gpu_state),
43 driver_task_runner_(base::MessageLoop::current()->task_runner()), 43 driver_task_runner_(base::MessageLoop::current()->task_runner()),
44 driver_(driver.Pass()), 44 driver_(driver.Pass()),
45 observer_(nullptr), 45 observer_(nullptr),
46 weak_ptr_factory_(this) { 46 weak_ptr_factory_(this) {
47 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this))); 47 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this)));
48 48
49 gpu_state_->control_task_runner()->PostTask( 49 gpu_state_->control_task_runner()->PostTask(
50 FROM_HERE, 50 FROM_HERE,
51 base::Bind(&CommandBufferImpl::BindToRequest, 51 base::Bind(&CommandBufferImpl::BindToRequest,
52 weak_ptr_factory_.GetWeakPtr(), base::Passed(&request))); 52 weak_ptr_factory_.GetWeakPtr(), base::Passed(&request)));
53 } 53 }
54 54
55 void CommandBufferImpl::Initialize( 55 void CommandBufferImpl::Initialize(
56 mojo::CommandBufferSyncClientPtr sync_client, 56 mus::mojom::CommandBufferSyncClientPtr sync_client,
57 mojo::CommandBufferSyncPointClientPtr sync_point_client, 57 mus::mojom::CommandBufferSyncPointClientPtr sync_point_client,
58 mojo::CommandBufferLostContextObserverPtr loss_observer, 58 mus::mojom::CommandBufferLostContextObserverPtr loss_observer,
59 mojo::ScopedSharedBufferHandle shared_state, 59 mojo::ScopedSharedBufferHandle shared_state,
60 mojo::Array<int32_t> attribs) { 60 mojo::Array<int32_t> attribs) {
61 sync_point_client_ = sync_point_client.Pass(); 61 sync_point_client_ = sync_point_client.Pass();
62 driver_task_runner_->PostTask( 62 driver_task_runner_->PostTask(
63 FROM_HERE, 63 FROM_HERE,
64 base::Bind(&CommandBufferDriver::Initialize, 64 base::Bind(&CommandBufferDriver::Initialize,
65 base::Unretained(driver_.get()), 65 base::Unretained(driver_.get()),
66 base::Passed(sync_client.PassInterface()), 66 base::Passed(sync_client.PassInterface()),
67 base::Passed(loss_observer.PassInterface()), 67 base::Passed(loss_observer.PassInterface()),
68 base::Passed(&shared_state), base::Passed(&attribs))); 68 base::Passed(&shared_state), base::Passed(&attribs)));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 FROM_HERE, base::Bind(&CommandBufferDriver::DestroyImage, 144 FROM_HERE, base::Bind(&CommandBufferDriver::DestroyImage,
145 base::Unretained(driver_.get()), id)); 145 base::Unretained(driver_.get()), id));
146 } 146 }
147 147
148 CommandBufferImpl::~CommandBufferImpl() { 148 CommandBufferImpl::~CommandBufferImpl() {
149 if (observer_) 149 if (observer_)
150 observer_->OnCommandBufferImplDestroyed(); 150 observer_->OnCommandBufferImplDestroyed();
151 } 151 }
152 152
153 void CommandBufferImpl::BindToRequest( 153 void CommandBufferImpl::BindToRequest(
154 mojo::InterfaceRequest<mojo::CommandBuffer> request) { 154 mojo::InterfaceRequest<mus::mojom::CommandBuffer> request) {
155 binding_.reset(new mojo::Binding<mojo::CommandBuffer>(this, request.Pass())); 155 binding_.reset(
156 new mojo::Binding<mus::mojom::CommandBuffer>(this, request.Pass()));
156 binding_->set_connection_error_handler([this]() { OnConnectionError(); }); 157 binding_->set_connection_error_handler([this]() { OnConnectionError(); });
157 } 158 }
158 159
159 void CommandBufferImpl::OnConnectionError() { 160 void CommandBufferImpl::OnConnectionError() {
160 // OnConnectionError() is called on the control thread |control_task_runner|. 161 // OnConnectionError() is called on the control thread |control_task_runner|.
161 // sync_point_client_ is assigned and accessed on the control thread and so it 162 // sync_point_client_ is assigned and accessed on the control thread and so it
162 // should also be destroyed on the control because InterfacePtrs are thread- 163 // should also be destroyed on the control because InterfacePtrs are thread-
163 // hostile. 164 // hostile.
164 sync_point_client_.reset(); 165 sync_point_client_.reset();
165 166
166 // Before deleting, we need to delete |binding_| because it is bound to the 167 // Before deleting, we need to delete |binding_| because it is bound to the
167 // current thread (|control_task_runner|). 168 // current thread (|control_task_runner|).
168 binding_.reset(); 169 binding_.reset();
169 170
170 // Objects we own (such as CommandBufferDriver) need to be destroyed on the 171 // Objects we own (such as CommandBufferDriver) need to be destroyed on the
171 // thread we were created on. 172 // thread we were created on.
172 driver_task_runner_->DeleteSoon(FROM_HERE, this); 173 driver_task_runner_->DeleteSoon(FROM_HERE, this);
173 } 174 }
174 175
175 void CommandBufferImpl::DidLoseContext() { 176 void CommandBufferImpl::DidLoseContext() {
176 OnConnectionError(); 177 OnConnectionError();
177 } 178 }
178 179
179 } // namespace mus 180 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_impl.h ('k') | components/mus/gles2/command_buffer_type_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698