OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/compositor/test/in_process_context_provider.h" | 5 #include "ui/compositor/test/in_process_context_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 : attribs_(attribs), | 78 : attribs_(attribs), |
79 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 79 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
80 image_factory_(image_factory), | 80 image_factory_(image_factory), |
81 window_(window), | 81 window_(window), |
82 debug_name_(debug_name), | 82 debug_name_(debug_name), |
83 destroyed_(false) { | 83 destroyed_(false) { |
84 DCHECK(main_thread_checker_.CalledOnValidThread()); | 84 DCHECK(main_thread_checker_.CalledOnValidThread()); |
85 context_thread_checker_.DetachFromThread(); | 85 context_thread_checker_.DetachFromThread(); |
86 } | 86 } |
87 | 87 |
88 InProcessContextProvider::~InProcessContextProvider() { | 88 InProcessContextProvider::~InProcessContextProvider() {} |
89 DCHECK(main_thread_checker_.CalledOnValidThread() || | 89 |
90 context_thread_checker_.CalledOnValidThread()); | 90 void InProcessContextProvider::Destroy() { |
| 91 base::AutoLock lock(destroyed_lock_); |
| 92 if (context_) |
| 93 context_->SetContextLostCallback(base::Closure()); |
| 94 destroyed_ = true; |
91 } | 95 } |
92 | 96 |
93 bool InProcessContextProvider::BindToCurrentThread() { | 97 bool InProcessContextProvider::BindToCurrentThread() { |
94 // This is called on the thread the context will be used. | 98 // This is called on the thread the context will be used. |
95 DCHECK(context_thread_checker_.CalledOnValidThread()); | 99 DCHECK(context_thread_checker_.CalledOnValidThread()); |
96 | 100 |
97 if (!context_) { | 101 if (!context_) { |
98 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 102 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
99 context_.reset(gpu::GLInProcessContext::Create( | 103 context_.reset(gpu::GLInProcessContext::Create( |
100 nullptr, /* service */ | 104 nullptr, /* service */ |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return; | 229 return; |
226 destroyed_ = true; | 230 destroyed_ = true; |
227 } | 231 } |
228 if (!lost_context_callback_.is_null()) | 232 if (!lost_context_callback_.is_null()) |
229 base::ResetAndReturn(&lost_context_callback_).Run(); | 233 base::ResetAndReturn(&lost_context_callback_).Run(); |
230 if (gr_context_) | 234 if (gr_context_) |
231 gr_context_->abandonContext(); | 235 gr_context_->abandonContext(); |
232 } | 236 } |
233 | 237 |
234 } // namespace ui | 238 } // namespace ui |
OLD | NEW |