| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() || | |
| 90 context_thread_checker_.CalledOnValidThread()); | |
| 91 } | 89 } |
| 92 | 90 |
| 93 bool InProcessContextProvider::BindToCurrentThread() { | 91 bool InProcessContextProvider::BindToCurrentThread() { |
| 94 // This is called on the thread the context will be used. | 92 // This is called on the thread the context will be used. |
| 95 DCHECK(context_thread_checker_.CalledOnValidThread()); | 93 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 96 | 94 |
| 97 if (!context_) { | 95 if (!context_) { |
| 98 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 96 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 99 context_.reset(gpu::GLInProcessContext::Create( | 97 context_.reset(gpu::GLInProcessContext::Create( |
| 100 nullptr, /* service */ | 98 nullptr, /* service */ |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (destroyed_) | 222 if (destroyed_) |
| 225 return; | 223 return; |
| 226 destroyed_ = true; | 224 destroyed_ = true; |
| 227 } | 225 } |
| 228 if (!lost_context_callback_.is_null()) | 226 if (!lost_context_callback_.is_null()) |
| 229 base::ResetAndReturn(&lost_context_callback_).Run(); | 227 base::ResetAndReturn(&lost_context_callback_).Run(); |
| 230 if (gr_context_) | 228 if (gr_context_) |
| 231 gr_context_->abandonContext(); | 229 gr_context_->abandonContext(); |
| 232 } | 230 } |
| 233 | 231 |
| 232 bool InProcessContextProvider::HasBeenDestroyed() { |
| 233 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 234 return destroyed_; |
| 235 } |
| 236 |
| 234 } // namespace ui | 237 } // namespace ui |
| OLD | NEW |