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

Side by Side Diff: mojo/gles2/command_buffer_client_impl.cc

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: blimp2 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 "mojo/gles2/command_buffer_client_impl.h" 5 #include "mojo/gles2/command_buffer_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "components/mus/gles2/command_buffer_type_conversions.h" 16 #include "components/mus/gles2/command_buffer_type_conversions.h"
17 #include "components/mus/gles2/mojo_buffer_backing.h" 17 #include "components/mus/gles2/mojo_buffer_backing.h"
18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" 18 #include "components/mus/gles2/mojo_gpu_memory_buffer.h"
19 #include "gpu/command_buffer/client/gpu_control_client.h"
19 #include "gpu/command_buffer/common/command_buffer_id.h" 20 #include "gpu/command_buffer/common/command_buffer_id.h"
20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" 21 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
21 #include "gpu/command_buffer/common/sync_token.h" 22 #include "gpu/command_buffer/common/sync_token.h"
22 #include "mojo/platform_handle/platform_handle_functions.h" 23 #include "mojo/platform_handle/platform_handle_functions.h"
23 24
24 namespace gles2 { 25 namespace gles2 {
25 26
26 namespace { 27 namespace {
27 28
28 bool CreateMapAndDupSharedBuffer(size_t size, 29 bool CreateMapAndDupSharedBuffer(size_t size,
(...skipping 25 matching lines...) Expand all
54 *output = input; 55 *output = input;
55 } 56 }
56 57
57 void InitializeCallback(mus::mojom::CommandBufferInitializeResultPtr* output, 58 void InitializeCallback(mus::mojom::CommandBufferInitializeResultPtr* output,
58 mus::mojom::CommandBufferInitializeResultPtr input) { 59 mus::mojom::CommandBufferInitializeResultPtr input) {
59 *output = std::move(input); 60 *output = std::move(input);
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 CommandBufferDelegate::~CommandBufferDelegate() {}
65
66 void CommandBufferDelegate::ContextLost() {}
67
68 CommandBufferClientImpl::CommandBufferClientImpl( 65 CommandBufferClientImpl::CommandBufferClientImpl(
69 CommandBufferDelegate* delegate,
70 const std::vector<int32_t>& attribs, 66 const std::vector<int32_t>& attribs,
71 mojo::ScopedMessagePipeHandle command_buffer_handle) 67 mojo::ScopedMessagePipeHandle command_buffer_handle)
72 : delegate_(delegate), 68 : gpu_control_client_(nullptr),
69 destroyed_(false),
73 attribs_(attribs), 70 attribs_(attribs),
74 client_binding_(this), 71 client_binding_(this),
75 command_buffer_id_(), 72 command_buffer_id_(),
76 shared_state_(NULL), 73 shared_state_(NULL),
77 last_put_offset_(-1), 74 last_put_offset_(-1),
78 next_transfer_buffer_id_(0), 75 next_transfer_buffer_id_(0),
79 next_image_id_(0), 76 next_image_id_(0),
80 next_fence_sync_release_(1), 77 next_fence_sync_release_(1),
81 flushed_fence_sync_release_(0) { 78 flushed_fence_sync_release_(0) {
82 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( 79 command_buffer_.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 scoped_ptr<gpu::BufferBacking> backing( 193 scoped_ptr<gpu::BufferBacking> backing(
197 new mus::MojoBufferBacking(std::move(handle), memory, size)); 194 new mus::MojoBufferBacking(std::move(handle), memory, size));
198 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(std::move(backing))); 195 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(std::move(backing)));
199 return buffer; 196 return buffer;
200 } 197 }
201 198
202 void CommandBufferClientImpl::DestroyTransferBuffer(int32_t id) { 199 void CommandBufferClientImpl::DestroyTransferBuffer(int32_t id) {
203 command_buffer_->DestroyTransferBuffer(id); 200 command_buffer_->DestroyTransferBuffer(id);
204 } 201 }
205 202
203 void CommandBufferClientImpl::SetGpuControlClient(gpu::GpuControlClient* c) {
204 gpu_control_client_ = c;
205 }
206
206 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { 207 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() {
207 return capabilities_; 208 return capabilities_;
208 } 209 }
209 210
210 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer, 211 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer,
211 size_t width, 212 size_t width,
212 size_t height, 213 size_t height,
213 unsigned internalformat) { 214 unsigned internalformat) {
214 int32_t new_id = ++next_image_id_; 215 int32_t new_id = ++next_image_id_;
215 216
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); 279 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
279 } 280 }
280 281
281 void CommandBufferClientImpl::SignalQuery(uint32_t query, 282 void CommandBufferClientImpl::SignalQuery(uint32_t query,
282 const base::Closure& callback) { 283 const base::Closure& callback) {
283 // TODO(piman) 284 // TODO(piman)
284 NOTIMPLEMENTED(); 285 NOTIMPLEMENTED();
285 } 286 }
286 287
287 void CommandBufferClientImpl::Destroyed(int32_t lost_reason, int32_t error) { 288 void CommandBufferClientImpl::Destroyed(int32_t lost_reason, int32_t error) {
289 if (destroyed_)
290 return;
288 last_state_.context_lost_reason = 291 last_state_.context_lost_reason =
289 static_cast<gpu::error::ContextLostReason>(lost_reason); 292 static_cast<gpu::error::ContextLostReason>(lost_reason);
290 last_state_.error = static_cast<gpu::error::Error>(error); 293 last_state_.error = static_cast<gpu::error::Error>(error);
291 delegate_->ContextLost(); 294 DCHECK(gpu_control_client_);
295 gpu_control_client_->OnGpuControlLostContext();
296 destroyed_ = true;
292 } 297 }
293 298
294 void CommandBufferClientImpl::SignalAck(uint32_t id) { 299 void CommandBufferClientImpl::SignalAck(uint32_t id) {
295 } 300 }
296 301
297 void CommandBufferClientImpl::SwapBuffersCompleted(int32_t result) { 302 void CommandBufferClientImpl::SwapBuffersCompleted(int32_t result) {
298 } 303 }
299 304
300 void CommandBufferClientImpl::UpdateState( 305 void CommandBufferClientImpl::UpdateState(
301 const gpu::CommandBuffer::State& state) { 306 const gpu::CommandBuffer::State& state) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 388
384 // It is also safe to wait on the same context. 389 // It is also safe to wait on the same context.
385 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO && 390 if (sync_token->namespace_id() == gpu::CommandBufferNamespace::MOJO &&
386 sync_token->command_buffer_id() == GetCommandBufferID()) 391 sync_token->command_buffer_id() == GetCommandBufferID())
387 return true; 392 return true;
388 393
389 return false; 394 return false;
390 } 395 }
391 396
392 } // namespace gles2 397 } // namespace gles2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698