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 "gpu/ipc/service/gpu_command_buffer_stub.h" | 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 523 |
524 bool have_context = false; | 524 bool have_context = false; |
525 if (decoder_ && decoder_->GetGLContext()) { | 525 if (decoder_ && decoder_->GetGLContext()) { |
526 // Try to make the context current regardless of whether it was lost, so we | 526 // Try to make the context current regardless of whether it was lost, so we |
527 // don't leak resources. | 527 // don't leak resources. |
528 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); | 528 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); |
529 } | 529 } |
530 for (auto& observer : destruction_observers_) | 530 for (auto& observer : destruction_observers_) |
531 observer.OnWillDestroyStub(); | 531 observer.OnWillDestroyStub(); |
532 | 532 |
| 533 // Remove this after crbug.com/248395 is sorted out. |
| 534 // Destroy the surface before the context, some surface destructors make GL |
| 535 // calls. |
| 536 surface_ = nullptr; |
| 537 |
533 if (decoder_) { | 538 if (decoder_) { |
534 decoder_->Destroy(have_context); | 539 decoder_->Destroy(have_context); |
535 decoder_.reset(); | 540 decoder_.reset(); |
536 } | 541 } |
537 | 542 |
538 command_buffer_.reset(); | 543 command_buffer_.reset(); |
539 | |
540 // Remove this after crbug.com/248395 is sorted out. | |
541 surface_ = NULL; | |
542 } | 544 } |
543 | 545 |
544 bool GpuCommandBufferStub::Initialize( | 546 bool GpuCommandBufferStub::Initialize( |
545 GpuCommandBufferStub* share_command_buffer_stub, | 547 GpuCommandBufferStub* share_command_buffer_stub, |
546 const GPUCreateCommandBufferConfig& init_params, | 548 const GPUCreateCommandBufferConfig& init_params, |
547 std::unique_ptr<base::SharedMemory> shared_state_shm) { | 549 std::unique_ptr<base::SharedMemory> shared_state_shm) { |
548 TRACE_EVENT0("gpu", "GpuCommandBufferStub::Initialize"); | 550 TRACE_EVENT0("gpu", "GpuCommandBufferStub::Initialize"); |
549 FastSetActiveURL(active_url_, active_url_hash_, channel_); | 551 FastSetActiveURL(active_url_, active_url_hash_, channel_); |
550 | 552 |
551 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 553 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 DLOG(ERROR) << "Failed to create shared context for virtualization."; | 649 DLOG(ERROR) << "Failed to create shared context for virtualization."; |
648 return false; | 650 return false; |
649 } | 651 } |
650 // Ensure that context creation did not lose track of the intended | 652 // Ensure that context creation did not lose track of the intended |
651 // gl_share_group. | 653 // gl_share_group. |
652 DCHECK(context->share_group() == gl_share_group); | 654 DCHECK(context->share_group() == gl_share_group); |
653 gl_share_group->SetSharedContext(surface_.get(), context.get()); | 655 gl_share_group->SetSharedContext(surface_.get(), context.get()); |
654 } | 656 } |
655 // This should be either: | 657 // This should be either: |
656 // (1) a non-virtual GL context, or | 658 // (1) a non-virtual GL context, or |
657 // (2) a mock context. | 659 // (2) a mock/stub context. |
658 DCHECK(context->GetHandle() || | 660 DCHECK(context->GetHandle() || |
659 gl::GetGLImplementation() == gl::kGLImplementationMockGL); | 661 gl::GetGLImplementation() == gl::kGLImplementationMockGL || |
| 662 gl::GetGLImplementation() == gl::kGLImplementationStubGL); |
660 context = new GLContextVirtual( | 663 context = new GLContextVirtual( |
661 gl_share_group, context.get(), decoder_->AsWeakPtr()); | 664 gl_share_group, context.get(), decoder_->AsWeakPtr()); |
662 if (!context->Initialize( | 665 if (!context->Initialize( |
663 surface_.get(), | 666 surface_.get(), |
664 GenerateGLContextAttribs(init_params.attribs, | 667 GenerateGLContextAttribs(init_params.attribs, |
665 context_group_->gpu_preferences()))) { | 668 context_group_->gpu_preferences()))) { |
666 // The real context created above for the default offscreen surface | 669 // The real context created above for the default offscreen surface |
667 // might not be compatible with this surface. | 670 // might not be compatible with this surface. |
668 context = NULL; | 671 context = NULL; |
669 DLOG(ERROR) << "Failed to initialize virtual GL context."; | 672 DLOG(ERROR) << "Failed to initialize virtual GL context."; |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 command_buffer_->GetLastState().error == error::kLostContext) | 1205 command_buffer_->GetLastState().error == error::kLostContext) |
1203 return; | 1206 return; |
1204 | 1207 |
1205 command_buffer_->SetContextLostReason(error::kUnknown); | 1208 command_buffer_->SetContextLostReason(error::kUnknown); |
1206 if (decoder_) | 1209 if (decoder_) |
1207 decoder_->MarkContextLost(error::kUnknown); | 1210 decoder_->MarkContextLost(error::kUnknown); |
1208 command_buffer_->SetParseError(error::kLostContext); | 1211 command_buffer_->SetParseError(error::kLostContext); |
1209 } | 1212 } |
1210 | 1213 |
1211 } // namespace gpu | 1214 } // namespace gpu |
OLD | NEW |