| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // destroy it before those. | 352 // destroy it before those. |
| 353 scheduler_.reset(); | 353 scheduler_.reset(); |
| 354 | 354 |
| 355 bool have_context = false; | 355 bool have_context = false; |
| 356 if (decoder_) | 356 if (decoder_) |
| 357 have_context = decoder_->MakeCurrent(); | 357 have_context = decoder_->MakeCurrent(); |
| 358 FOR_EACH_OBSERVER(DestructionObserver, | 358 FOR_EACH_OBSERVER(DestructionObserver, |
| 359 destruction_observers_, | 359 destruction_observers_, |
| 360 OnWillDestroyStub()); | 360 OnWillDestroyStub()); |
| 361 | 361 |
| 362 scoped_refptr<gfx::GLContext> context; | |
| 363 if (decoder_) { | 362 if (decoder_) { |
| 364 context = decoder_->GetGLContext(); | |
| 365 decoder_->Destroy(have_context); | 363 decoder_->Destroy(have_context); |
| 366 decoder_.reset(); | 364 decoder_.reset(); |
| 367 } | 365 } |
| 368 | 366 |
| 369 command_buffer_.reset(); | 367 command_buffer_.reset(); |
| 370 | 368 |
| 371 // Make sure that context_ is current while we destroy surface_, because | 369 // Remove this after crbug.com/248395 is sorted out. |
| 372 // surface_ may have GL resources that it needs to destroy, and will need | |
| 373 // context_ to be current in order to not leak these resources. | |
| 374 if (context.get()) | |
| 375 context->MakeCurrent(surface_.get()); | |
| 376 surface_ = NULL; | 370 surface_ = NULL; |
| 377 if (context.get()) | |
| 378 context->ReleaseCurrent(NULL); | |
| 379 } | 371 } |
| 380 | 372 |
| 381 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { | 373 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { |
| 382 Destroy(); | 374 Destroy(); |
| 383 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 375 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
| 384 Send(reply_message); | 376 Send(reply_message); |
| 385 } | 377 } |
| 386 | 378 |
| 387 void GpuCommandBufferStub::OnInitialize( | 379 void GpuCommandBufferStub::OnInitialize( |
| 388 base::SharedMemoryHandle shared_state_handle, | 380 base::SharedMemoryHandle shared_state_handle, |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 if (surface_.get() && MakeCurrent()) | 903 if (surface_.get() && MakeCurrent()) |
| 912 surface_->SetFrontbufferAllocation( | 904 surface_->SetFrontbufferAllocation( |
| 913 allocation.browser_allocation.suggest_have_frontbuffer); | 905 allocation.browser_allocation.suggest_have_frontbuffer); |
| 914 } | 906 } |
| 915 | 907 |
| 916 last_memory_allocation_valid_ = true; | 908 last_memory_allocation_valid_ = true; |
| 917 last_memory_allocation_ = allocation; | 909 last_memory_allocation_ = allocation; |
| 918 } | 910 } |
| 919 | 911 |
| 920 } // namespace content | 912 } // namespace content |
| OLD | NEW |