Chromium Code Reviews| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 // destroy it before those. | 353 // destroy it before those. |
| 354 scheduler_.reset(); | 354 scheduler_.reset(); |
| 355 | 355 |
| 356 bool have_context = false; | 356 bool have_context = false; |
| 357 if (decoder_) | 357 if (decoder_) |
| 358 have_context = decoder_->MakeCurrent(); | 358 have_context = decoder_->MakeCurrent(); |
| 359 FOR_EACH_OBSERVER(DestructionObserver, | 359 FOR_EACH_OBSERVER(DestructionObserver, |
| 360 destruction_observers_, | 360 destruction_observers_, |
| 361 OnWillDestroyStub()); | 361 OnWillDestroyStub()); |
| 362 | 362 |
| 363 scoped_refptr<gfx::GLContext> context; | |
| 364 if (decoder_) { | 363 if (decoder_) { |
| 365 context = decoder_->GetGLContext(); | 364 // The surface destructor should be called with a current context. |
| 365 // Therefore release the stub's reference before destroying the decoder, | |
| 366 // because the latter will release the context. | |
| 367 surface_ = NULL; | |
|
epenner
2013/05/28 22:57:21
Are you sure this is the last valid reference to t
no sievers
2013/05/28 23:15:32
Ah good point, I forgot to release the decoder's r
| |
| 366 decoder_->Destroy(have_context); | 368 decoder_->Destroy(have_context); |
| 367 decoder_.reset(); | 369 decoder_.reset(); |
| 368 } | 370 } |
| 369 | 371 |
| 370 command_buffer_.reset(); | 372 command_buffer_.reset(); |
| 371 | |
| 372 // Make sure that context_ is current while we destroy surface_, because | |
| 373 // surface_ may have GL resources that it needs to destroy, and will need | |
| 374 // context_ to be current in order to not leak these resources. | |
| 375 if (context) | |
| 376 context->MakeCurrent(surface_.get()); | |
| 377 surface_ = NULL; | |
| 378 if (context) | |
| 379 context->ReleaseCurrent(NULL); | |
| 380 } | 373 } |
| 381 | 374 |
| 382 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { | 375 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { |
| 383 Destroy(); | 376 Destroy(); |
| 384 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 377 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
| 385 Send(reply_message); | 378 Send(reply_message); |
| 386 } | 379 } |
| 387 | 380 |
| 388 void GpuCommandBufferStub::OnInitialize( | 381 void GpuCommandBufferStub::OnInitialize( |
| 389 base::SharedMemoryHandle shared_state_handle, | 382 base::SharedMemoryHandle shared_state_handle, |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 if (surface_ && MakeCurrent()) | 932 if (surface_ && MakeCurrent()) |
| 940 surface_->SetFrontbufferAllocation( | 933 surface_->SetFrontbufferAllocation( |
| 941 allocation.browser_allocation.suggest_have_frontbuffer); | 934 allocation.browser_allocation.suggest_have_frontbuffer); |
| 942 } | 935 } |
| 943 | 936 |
| 944 last_memory_allocation_valid_ = true; | 937 last_memory_allocation_valid_ = true; |
| 945 last_memory_allocation_ = allocation; | 938 last_memory_allocation_ = allocation; |
| 946 } | 939 } |
| 947 | 940 |
| 948 } // namespace content | 941 } // namespace content |
| OLD | NEW |