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

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.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: . 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/in_process_command_buffer.h" 5 #include "gpu/command_buffer/service/in_process_command_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/location.h" 18 #include "base/location.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/numerics/safe_conversions.h" 21 #include "base/numerics/safe_conversions.h"
22 #include "base/sequence_checker.h" 22 #include "base/sequence_checker.h"
23 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
24 #include "base/thread_task_runner_handle.h" 24 #include "base/thread_task_runner_handle.h"
25 #include "gpu/command_buffer/client/gpu_control_client.h"
25 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 26 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
26 #include "gpu/command_buffer/common/sync_token.h" 27 #include "gpu/command_buffer/common/sync_token.h"
27 #include "gpu/command_buffer/common/value_state.h" 28 #include "gpu/command_buffer/common/value_state.h"
28 #include "gpu/command_buffer/service/command_buffer_service.h" 29 #include "gpu/command_buffer/service/command_buffer_service.h"
29 #include "gpu/command_buffer/service/command_executor.h" 30 #include "gpu/command_buffer/service/command_executor.h"
30 #include "gpu/command_buffer/service/context_group.h" 31 #include "gpu/command_buffer/service/context_group.h"
31 #include "gpu/command_buffer/service/gl_context_virtual.h" 32 #include "gpu/command_buffer/service/gl_context_virtual.h"
32 #include "gpu/command_buffer/service/gpu_preferences.h" 33 #include "gpu/command_buffer/service/gpu_preferences.h"
33 #include "gpu/command_buffer/service/image_factory.h" 34 #include "gpu/command_buffer/service/image_factory.h"
34 #include "gpu/command_buffer/service/image_manager.h" 35 #include "gpu/command_buffer/service/image_manager.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return true; 258 return true;
258 } 259 }
259 260
260 bool InProcessCommandBuffer::Initialize( 261 bool InProcessCommandBuffer::Initialize(
261 scoped_refptr<gfx::GLSurface> surface, 262 scoped_refptr<gfx::GLSurface> surface,
262 bool is_offscreen, 263 bool is_offscreen,
263 gfx::AcceleratedWidget window, 264 gfx::AcceleratedWidget window,
264 const gfx::Size& size, 265 const gfx::Size& size,
265 const std::vector<int32_t>& attribs, 266 const std::vector<int32_t>& attribs,
266 gfx::GpuPreference gpu_preference, 267 gfx::GpuPreference gpu_preference,
267 const base::Closure& context_lost_callback,
268 InProcessCommandBuffer* share_group, 268 InProcessCommandBuffer* share_group,
269 GpuMemoryBufferManager* gpu_memory_buffer_manager, 269 GpuMemoryBufferManager* gpu_memory_buffer_manager,
270 ImageFactory* image_factory) { 270 ImageFactory* image_factory) {
271 DCHECK(!share_group || service_.get() == share_group->service_.get()); 271 DCHECK(!share_group || service_.get() == share_group->service_.get());
272 context_lost_callback_ = WrapCallback(context_lost_callback);
273 272
274 if (surface.get()) { 273 if (surface.get()) {
275 // GPU thread must be the same as client thread due to GLSurface not being 274 // GPU thread must be the same as client thread due to GLSurface not being
276 // thread safe. 275 // thread safe.
277 sequence_checker_.reset(new base::SequenceChecker); 276 sequence_checker_.reset(new base::SequenceChecker);
278 surface_ = surface; 277 surface_ = surface;
279 } 278 }
280 279
281 gpu::Capabilities capabilities; 280 gpu::Capabilities capabilities;
282 InitializeOnGpuThreadParams params(is_offscreen, 281 InitializeOnGpuThreadParams params(is_offscreen,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 return true; 484 return true;
486 } 485 }
487 486
488 void InProcessCommandBuffer::CheckSequencedThread() { 487 void InProcessCommandBuffer::CheckSequencedThread() {
489 DCHECK(!sequence_checker_ || 488 DCHECK(!sequence_checker_ ||
490 sequence_checker_->CalledOnValidSequencedThread()); 489 sequence_checker_->CalledOnValidSequencedThread());
491 } 490 }
492 491
493 void InProcessCommandBuffer::OnContextLost() { 492 void InProcessCommandBuffer::OnContextLost() {
494 CheckSequencedThread(); 493 CheckSequencedThread();
495 if (!context_lost_callback_.is_null()) { 494 if (context_lost_)
496 context_lost_callback_.Run(); 495 return;
497 context_lost_callback_.Reset(); 496 DCHECK(gpu_control_client_);
498 } 497 gpu_control_client_->OnGpuControlLostContext();
499
500 context_lost_ = true; 498 context_lost_ = true;
501 } 499 }
502 500
503 CommandBuffer::State InProcessCommandBuffer::GetStateFast() { 501 CommandBuffer::State InProcessCommandBuffer::GetStateFast() {
504 CheckSequencedThread(); 502 CheckSequencedThread();
505 base::AutoLock lock(state_after_last_flush_lock_); 503 base::AutoLock lock(state_after_last_flush_lock_);
506 if (state_after_last_flush_.generation - last_state_.generation < 0x80000000U) 504 if (state_after_last_flush_.generation - last_state_.generation < 0x80000000U)
507 last_state_ = state_after_last_flush_; 505 last_state_ = state_after_last_flush_;
508 return last_state_; 506 return last_state_;
509 } 507 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 id); 659 id);
662 660
663 QueueTask(task); 661 QueueTask(task);
664 } 662 }
665 663
666 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32_t id) { 664 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32_t id) {
667 base::AutoLock lock(command_buffer_lock_); 665 base::AutoLock lock(command_buffer_lock_);
668 command_buffer_->DestroyTransferBuffer(id); 666 command_buffer_->DestroyTransferBuffer(id);
669 } 667 }
670 668
669 void InProcessCommandBuffer::SetGpuControlClient(GpuControlClient* client) {
670 gpu_control_client_ = client;
671 }
672
671 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() { 673 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() {
672 return capabilities_; 674 return capabilities_;
673 } 675 }
674 676
675 int32_t InProcessCommandBuffer::CreateImage(ClientBuffer buffer, 677 int32_t InProcessCommandBuffer::CreateImage(ClientBuffer buffer,
676 size_t width, 678 size_t width,
677 size_t height, 679 size_t height,
678 unsigned internalformat) { 680 unsigned internalformat) {
679 CheckSequencedThread(); 681 CheckSequencedThread();
680 682
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 framebuffer_completeness_cache_ = 1093 framebuffer_completeness_cache_ =
1092 new gpu::gles2::FramebufferCompletenessCache; 1094 new gpu::gles2::FramebufferCompletenessCache;
1093 return framebuffer_completeness_cache_; 1095 return framebuffer_completeness_cache_;
1094 } 1096 }
1095 1097
1096 SyncPointManager* GpuInProcessThread::sync_point_manager() { 1098 SyncPointManager* GpuInProcessThread::sync_point_manager() {
1097 return sync_point_manager_; 1099 return sync_point_manager_;
1098 } 1100 }
1099 1101
1100 } // namespace gpu 1102 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698