| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "cc/output/managed_memory_policy.h" | 13 #include "cc/output/managed_memory_policy.h" |
| 14 #include "gpu/command_buffer/client/gl_in_process_context.h" | 14 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 15 #include "gpu/command_buffer/client/gles2_implementation.h" | 15 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 16 #include "gpu/command_buffer/client/gles2_lib.h" | 16 #include "gpu/command_buffer/client/gles2_lib.h" |
| 17 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 17 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 18 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
| 18 #include "third_party/skia/include/gpu/GrContext.h" | 19 #include "third_party/skia/include/gpu/GrContext.h" |
| 19 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 20 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 | 23 |
| 23 // static | 24 // static |
| 24 scoped_refptr<InProcessContextProvider> InProcessContextProvider::Create( | 25 scoped_refptr<InProcessContextProvider> InProcessContextProvider::Create( |
| 25 const gpu::gles2::ContextCreationAttribHelper& attribs, | 26 const gpu::gles2::ContextCreationAttribHelper& attribs, |
| 26 InProcessContextProvider* shared_context, | 27 InProcessContextProvider* shared_context, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 DCHECK(context_thread_checker_.CalledOnValidThread()); | 83 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 83 | 84 |
| 84 if (!context_) { | 85 if (!context_) { |
| 85 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 86 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 86 context_.reset(gpu::GLInProcessContext::Create( | 87 context_.reset(gpu::GLInProcessContext::Create( |
| 87 nullptr, /* service */ | 88 nullptr, /* service */ |
| 88 nullptr, /* surface */ | 89 nullptr, /* surface */ |
| 89 !window_, /* is_offscreen */ | 90 !window_, /* is_offscreen */ |
| 90 window_, gfx::Size(1, 1), | 91 window_, gfx::Size(1, 1), |
| 91 (shared_context_ ? shared_context_->context_.get() : nullptr), attribs_, | 92 (shared_context_ ? shared_context_->context_.get() : nullptr), attribs_, |
| 92 gpu_preference, gpu::GLInProcessContextSharedMemoryLimits(), | 93 gpu_preference, gpu::SharedMemoryLimits(), gpu_memory_buffer_manager_, |
| 93 gpu_memory_buffer_manager_, image_factory_)); | 94 image_factory_)); |
| 94 | 95 |
| 95 if (!context_) | 96 if (!context_) |
| 96 return false; | 97 return false; |
| 97 } | 98 } |
| 98 | 99 |
| 99 std::string unique_context_name = | 100 std::string unique_context_name = |
| 100 base::StringPrintf("%s-%p", debug_name_.c_str(), context_.get()); | 101 base::StringPrintf("%s-%p", debug_name_.c_str(), context_.get()); |
| 101 context_->GetImplementation()->TraceBeginCHROMIUM( | 102 context_->GetImplementation()->TraceBeginCHROMIUM( |
| 102 "gpu_toplevel", unique_context_name.c_str()); | 103 "gpu_toplevel", unique_context_name.c_str()); |
| 103 | 104 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (gr_context_) | 157 if (gr_context_) |
| 157 gr_context_->FreeGpuResources(); | 158 gr_context_->FreeGpuResources(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 void InProcessContextProvider::SetLostContextCallback( | 161 void InProcessContextProvider::SetLostContextCallback( |
| 161 const LostContextCallback& lost_context_callback) { | 162 const LostContextCallback& lost_context_callback) { |
| 162 // Pixel tests do not test lost context. | 163 // Pixel tests do not test lost context. |
| 163 } | 164 } |
| 164 | 165 |
| 165 } // namespace ui | 166 } // namespace ui |
| OLD | NEW |