| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // destroy it before those. | 351 // destroy it before those. |
| 352 scheduler_.reset(); | 352 scheduler_.reset(); |
| 353 | 353 |
| 354 bool have_context = false; | 354 bool have_context = false; |
| 355 if (decoder_) | 355 if (decoder_) |
| 356 have_context = decoder_->MakeCurrent(); | 356 have_context = decoder_->MakeCurrent(); |
| 357 FOR_EACH_OBSERVER(DestructionObserver, | 357 FOR_EACH_OBSERVER(DestructionObserver, |
| 358 destruction_observers_, | 358 destruction_observers_, |
| 359 OnWillDestroyStub()); | 359 OnWillDestroyStub()); |
| 360 | 360 |
| 361 scoped_refptr<gfx::GLContext> context; | |
| 362 if (decoder_) { | 361 if (decoder_) { |
| 363 context = decoder_->GetGLContext(); | |
| 364 decoder_->Destroy(have_context); | 362 decoder_->Destroy(have_context); |
| 365 decoder_.reset(); | 363 decoder_.reset(); |
| 366 } | 364 } |
| 367 | 365 |
| 368 command_buffer_.reset(); | 366 command_buffer_.reset(); |
| 369 | |
| 370 // Make sure that context_ is current while we destroy surface_, because | |
| 371 // surface_ may have GL resources that it needs to destroy, and will need | |
| 372 // context_ to be current in order to not leak these resources. | |
| 373 if (context) | |
| 374 context->MakeCurrent(surface_.get()); | |
| 375 surface_ = NULL; | |
| 376 if (context) | |
| 377 context->ReleaseCurrent(NULL); | |
| 378 } | 367 } |
| 379 | 368 |
| 380 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { | 369 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { |
| 381 Destroy(); | 370 Destroy(); |
| 382 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 371 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
| 383 Send(reply_message); | 372 Send(reply_message); |
| 384 } | 373 } |
| 385 | 374 |
| 386 void GpuCommandBufferStub::OnInitialize( | 375 void GpuCommandBufferStub::OnInitialize( |
| 387 base::SharedMemoryHandle shared_state_handle, | 376 base::SharedMemoryHandle shared_state_handle, |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 if (surface_ && MakeCurrent()) | 912 if (surface_ && MakeCurrent()) |
| 924 surface_->SetFrontbufferAllocation( | 913 surface_->SetFrontbufferAllocation( |
| 925 allocation.browser_allocation.suggest_have_frontbuffer); | 914 allocation.browser_allocation.suggest_have_frontbuffer); |
| 926 } | 915 } |
| 927 | 916 |
| 928 last_memory_allocation_valid_ = true; | 917 last_memory_allocation_valid_ = true; |
| 929 last_memory_allocation_ = allocation; | 918 last_memory_allocation_ = allocation; |
| 930 } | 919 } |
| 931 | 920 |
| 932 } // namespace content | 921 } // namespace content |
| OLD | NEW |