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

Unified Diff: components/gles2/command_buffer_driver.cc

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
Index: components/gles2/command_buffer_driver.cc
diff --git a/components/gles2/command_buffer_driver.cc b/components/gles2/command_buffer_driver.cc
index cfd2a7dd75f32516ba018bbac848e8a24a447a80..f1e913de8a2d3e9e9e142c5033bb70bd6012a270 100644
--- a/components/gles2/command_buffer_driver.cc
+++ b/components/gles2/command_buffer_driver.cc
@@ -57,27 +57,29 @@ CommandBufferDriver::CommandBufferDriver(
: CommandBufferDriver(gfx::kNullAcceleratedWidget,
share_group,
mailbox_manager,
- sync_point_manager) {
+ sync_point_manager,
+ base::Callback<void(CommandBufferDriver*)>()) {
}
CommandBufferDriver::CommandBufferDriver(
gfx::AcceleratedWidget widget,
gfx::GLShareGroup* share_group,
gpu::gles2::MailboxManager* mailbox_manager,
- gpu::SyncPointManager* sync_point_manager)
+ gpu::SyncPointManager* sync_point_manager,
+ const base::Callback<void(CommandBufferDriver*)>& destruct_callback)
: client_(nullptr),
widget_(widget),
share_group_(share_group),
mailbox_manager_(mailbox_manager),
sync_point_manager_(sync_point_manager),
+ destruct_callback_(destruct_callback),
weak_factory_(this) {
}
-CommandBufferDriver::~CommandBufferDriver() {
- if (decoder_) {
- bool have_context = decoder_->MakeCurrent();
- decoder_->Destroy(have_context);
- }
+CommandBufferDriver::~CommandBufferDriver() {
+ DestroyDecoder();
+ if (!destruct_callback_.is_null())
+ destruct_callback_.Run(this);
}
void CommandBufferDriver::Initialize(
@@ -174,6 +176,8 @@ void CommandBufferDriver::SetGetBuffer(int32_t buffer) {
}
void CommandBufferDriver::Flush(int32_t put_offset) {
+ if (!context_)
+ return;
if (!context_->MakeCurrent(surface_.get())) {
DLOG(WARNING) << "Context lost";
OnContextLost(gpu::error::kUnknown);
@@ -182,6 +186,13 @@ void CommandBufferDriver::Flush(int32_t put_offset) {
command_buffer_->Flush(put_offset);
}
+void CommandBufferDriver::DestroyWindow() {
+ DestroyDecoder();
+ surface_ = nullptr;
+ context_ = nullptr;
+ destruct_callback_.Reset();
+}
+
void CommandBufferDriver::MakeProgress(int32_t last_get_offset) {
// TODO(piman): handle out-of-order.
sync_client_->DidMakeProgress(
@@ -247,4 +258,12 @@ void CommandBufferDriver::OnUpdateVSyncParameters(
client_->UpdateVSyncParameters(timebase, interval);
}
+void CommandBufferDriver::DestroyDecoder() {
+ if (decoder_) {
+ bool have_context = decoder_->MakeCurrent();
+ decoder_->Destroy(have_context);
+ decoder_.reset();
+ }
+}
+
} // namespace gles2
« no previous file with comments | « components/gles2/command_buffer_driver.h ('k') | components/native_viewport/native_viewport_application_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698