| 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; |
| 362 if (decoder_) { | 363 if (decoder_) { |
| 364 context = decoder_->GetGLContext(); |
| 363 decoder_->Destroy(have_context); | 365 decoder_->Destroy(have_context); |
| 364 decoder_.reset(); | 366 decoder_.reset(); |
| 365 } | 367 } |
| 366 | 368 |
| 367 command_buffer_.reset(); | 369 command_buffer_.reset(); |
| 368 | 370 |
| 369 // Remove this after crbug.com/248395 is sorted out. | 371 // Make sure that context_ is current while we destroy surface_, because |
| 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()); |
| 370 surface_ = NULL; | 376 surface_ = NULL; |
| 377 if (context.get()) |
| 378 context->ReleaseCurrent(NULL); |
| 371 } | 379 } |
| 372 | 380 |
| 373 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { | 381 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { |
| 374 Destroy(); | 382 Destroy(); |
| 375 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 383 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
| 376 Send(reply_message); | 384 Send(reply_message); |
| 377 } | 385 } |
| 378 | 386 |
| 379 void GpuCommandBufferStub::OnInitialize( | 387 void GpuCommandBufferStub::OnInitialize( |
| 380 base::SharedMemoryHandle shared_state_handle, | 388 base::SharedMemoryHandle shared_state_handle, |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 if (surface_.get() && MakeCurrent()) | 911 if (surface_.get() && MakeCurrent()) |
| 904 surface_->SetFrontbufferAllocation( | 912 surface_->SetFrontbufferAllocation( |
| 905 allocation.browser_allocation.suggest_have_frontbuffer); | 913 allocation.browser_allocation.suggest_have_frontbuffer); |
| 906 } | 914 } |
| 907 | 915 |
| 908 last_memory_allocation_valid_ = true; | 916 last_memory_allocation_valid_ = true; |
| 909 last_memory_allocation_ = allocation; | 917 last_memory_allocation_ = allocation; |
| 910 } | 918 } |
| 911 | 919 |
| 912 } // namespace content | 920 } // namespace content |
| OLD | NEW |