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

Unified Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 1885903002: Revert of 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/in_process_command_buffer.cc
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc
index 5936b97c9ab8a9b8a8963bbee0d7a2d1bb8587b1..27824398429933e1a0d14ac2ef2034f4577776fd 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.cc
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc
@@ -22,7 +22,6 @@
#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
-#include "gpu/command_buffer/client/gpu_control_client.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/common/sync_token.h"
@@ -213,10 +212,6 @@
CommandBufferId::FromUnsafeValue(g_next_command_buffer_id.GetNext())),
delayed_work_pending_(false),
image_factory_(nullptr),
- gpu_control_client_(nullptr),
-#if DCHECK_IS_ON()
- context_lost_(false),
-#endif
last_put_offset_(-1),
gpu_memory_buffer_manager_(nullptr),
next_fence_sync_release_(1),
@@ -224,7 +219,6 @@
flush_event_(false, false),
service_(GetInitialService(service)),
fence_sync_wait_event_(false, false),
- client_thread_weak_ptr_factory_(this),
gpu_thread_weak_ptr_factory_(this) {
DCHECK(service_.get());
next_image_id_.GetNext();
@@ -251,7 +245,7 @@
return true;
}
-void InProcessCommandBuffer::PumpCommandsOnGpuThread() {
+void InProcessCommandBuffer::PumpCommands() {
CheckSequencedThread();
command_buffer_lock_.AssertAcquired();
@@ -259,6 +253,13 @@
return;
executor_->PutChanged();
+}
+
+bool InProcessCommandBuffer::GetBufferChanged(int32_t transfer_buffer_id) {
+ CheckSequencedThread();
+ command_buffer_lock_.AssertAcquired();
+ command_buffer_->SetGetBuffer(transfer_buffer_id);
+ return true;
}
bool InProcessCommandBuffer::Initialize(
@@ -268,19 +269,18 @@
const gfx::Size& size,
const std::vector<int32_t>& attribs,
gfx::GpuPreference gpu_preference,
+ const base::Closure& context_lost_callback,
InProcessCommandBuffer* share_group,
GpuMemoryBufferManager* gpu_memory_buffer_manager,
ImageFactory* image_factory) {
DCHECK(!share_group || service_.get() == share_group->service_.get());
-
- if (surface) {
+ context_lost_callback_ = WrapCallback(context_lost_callback);
+
+ if (surface.get()) {
// GPU thread must be the same as client thread due to GLSurface not being
// thread safe.
sequence_checker_.reset(new base::SequenceChecker);
surface_ = surface;
- } else {
- origin_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- client_thread_weak_ptr_ = client_thread_weak_ptr_factory_.GetWeakPtr();
}
gpu::Capabilities capabilities;
@@ -328,9 +328,9 @@
scoped_ptr<CommandBufferService> command_buffer(
new CommandBufferService(transfer_buffer_manager_.get()));
command_buffer->SetPutOffsetChangeCallback(base::Bind(
- &InProcessCommandBuffer::PumpCommandsOnGpuThread, gpu_thread_weak_ptr_));
+ &InProcessCommandBuffer::PumpCommands, gpu_thread_weak_ptr_));
command_buffer->SetParseErrorCallback(base::Bind(
- &InProcessCommandBuffer::OnContextLostOnGpuThread, gpu_thread_weak_ptr_));
+ &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_));
if (!command_buffer->Initialize()) {
LOG(ERROR) << "Could not initialize command buffer.";
@@ -455,8 +455,7 @@
void InProcessCommandBuffer::Destroy() {
CheckSequencedThread();
- client_thread_weak_ptr_factory_.InvalidateWeakPtrs();
- gpu_control_client_ = nullptr;
+
base::WaitableEvent completion(true, false);
bool result = false;
base::Callback<bool(void)> destroy_task = base::Bind(
@@ -476,14 +475,14 @@
decoder_->Destroy(have_context);
decoder_.reset();
}
- context_ = nullptr;
- surface_ = nullptr;
- sync_point_client_ = nullptr;
+ context_ = NULL;
+ surface_ = NULL;
+ sync_point_client_ = NULL;
if (sync_point_order_data_) {
sync_point_order_data_->Destroy();
sync_point_order_data_ = nullptr;
}
- gl_share_group_ = nullptr;
+ gl_share_group_ = NULL;
#if defined(OS_ANDROID)
stream_texture_manager_.reset();
#endif
@@ -496,25 +495,12 @@
sequence_checker_->CalledOnValidSequencedThread());
}
-void InProcessCommandBuffer::OnContextLostOnGpuThread() {
- if (!origin_task_runner_)
- return OnContextLost(); // Just kidding, we're on the client thread.
- origin_task_runner_->PostTask(
- FROM_HERE, base::Bind(&InProcessCommandBuffer::OnContextLost,
- client_thread_weak_ptr_));
-}
-
void InProcessCommandBuffer::OnContextLost() {
CheckSequencedThread();
-
-#if DCHECK_IS_ON()
- // This method shouldn't be called more than once.
- DCHECK(!context_lost_);
- context_lost_ = true;
-#endif
-
- if (gpu_control_client_)
- gpu_control_client_->OnGpuControlLostContext();
+ if (!context_lost_callback_.is_null()) {
+ context_lost_callback_.Run();
+ context_lost_callback_.Reset();
+ }
}
CommandBuffer::State InProcessCommandBuffer::GetStateFast() {
@@ -568,7 +554,7 @@
}
}
-void InProcessCommandBuffer::PerformDelayedWorkOnGpuThread() {
+void InProcessCommandBuffer::PerformDelayedWork() {
CheckSequencedThread();
delayed_work_pending_ = false;
base::AutoLock lock(command_buffer_lock_);
@@ -586,9 +572,8 @@
if (delayed_work_pending_)
return;
delayed_work_pending_ = true;
- service_->ScheduleDelayedWork(
- base::Bind(&InProcessCommandBuffer::PerformDelayedWorkOnGpuThread,
- gpu_thread_weak_ptr_));
+ service_->ScheduleDelayedWork(base::Bind(
+ &InProcessCommandBuffer::PerformDelayedWork, gpu_thread_weak_ptr_));
}
void InProcessCommandBuffer::Flush(int32_t put_offset) {
@@ -683,10 +668,6 @@
void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32_t id) {
base::AutoLock lock(command_buffer_lock_);
command_buffer_->DestroyTransferBuffer(id);
-}
-
-void InProcessCommandBuffer::SetGpuControlClient(GpuControlClient* client) {
- gpu_control_client_ = client;
}
gpu::Capabilities InProcessCommandBuffer::GetCapabilities() {
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698