OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/test/test_in_process_context_provider.h" | 5 #include "cc/test/test_in_process_context_provider.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
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/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
12 #include "cc/output/context_cache_controller.h" | 13 #include "cc/output/context_cache_controller.h" |
13 #include "cc/resources/platform_color.h" | 14 #include "cc/resources/platform_color.h" |
14 #include "gpu/GLES2/gl2extchromium.h" | 15 #include "gpu/GLES2/gl2extchromium.h" |
15 #include "gpu/command_buffer/client/gl_in_process_context.h" | 16 #include "gpu/command_buffer/client/gl_in_process_context.h" |
16 #include "gpu/command_buffer/client/gles2_implementation.h" | 17 #include "gpu/command_buffer/client/gles2_implementation.h" |
17 #include "gpu/command_buffer/client/gles2_lib.h" | 18 #include "gpu/command_buffer/client/gles2_lib.h" |
18 #include "gpu/command_buffer/client/shared_memory_limits.h" | 19 #include "gpu/command_buffer/client/shared_memory_limits.h" |
19 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 20 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
20 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 21 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
21 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
22 #include "third_party/khronos/GLES2/gl2ext.h" | 23 #include "third_party/khronos/GLES2/gl2ext.h" |
23 #include "third_party/skia/include/gpu/GrContext.h" | 24 #include "third_party/skia/include/gpu/GrContext.h" |
24 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 25 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
25 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
26 | 27 |
27 namespace cc { | 28 namespace cc { |
28 | 29 |
29 // static | 30 // static |
30 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( | 31 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( |
31 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, | 32 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, |
32 TestImageFactory* image_factory, | 33 TestImageFactory* image_factory, |
33 gpu::GLInProcessContext* shared_context) { | 34 gpu::GLInProcessContext* shared_context, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
34 const bool is_offscreen = true; | 36 const bool is_offscreen = true; |
35 gpu::gles2::ContextCreationAttribHelper attribs; | 37 gpu::gles2::ContextCreationAttribHelper attribs; |
36 attribs.alpha_size = -1; | 38 attribs.alpha_size = -1; |
37 attribs.depth_size = 24; | 39 attribs.depth_size = 24; |
38 attribs.stencil_size = 8; | 40 attribs.stencil_size = 8; |
39 attribs.samples = 0; | 41 attribs.samples = 0; |
40 attribs.sample_buffers = 0; | 42 attribs.sample_buffers = 0; |
41 attribs.fail_if_major_perf_caveat = false; | 43 attribs.fail_if_major_perf_caveat = false; |
42 attribs.bind_generates_resource = false; | 44 attribs.bind_generates_resource = false; |
43 | 45 |
44 std::unique_ptr<gpu::GLInProcessContext> context = | 46 std::unique_ptr<gpu::GLInProcessContext> context = |
45 base::WrapUnique(gpu::GLInProcessContext::Create( | 47 base::WrapUnique(gpu::GLInProcessContext::Create( |
46 nullptr, nullptr, is_offscreen, gfx::kNullAcceleratedWidget, | 48 nullptr, nullptr, is_offscreen, gfx::kNullAcceleratedWidget, |
47 shared_context, attribs, gpu::SharedMemoryLimits(), | 49 shared_context, attribs, gpu::SharedMemoryLimits(), |
48 gpu_memory_buffer_manager, image_factory)); | 50 gpu_memory_buffer_manager, image_factory, std::move(task_runner))); |
49 | 51 |
50 DCHECK(context); | 52 DCHECK(context); |
51 return context; | 53 return context; |
52 } | 54 } |
53 | 55 |
54 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { | 56 std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { |
55 return CreateTestInProcessContext(nullptr, nullptr, nullptr); | 57 return CreateTestInProcessContext(nullptr, nullptr, nullptr, |
| 58 base::ThreadTaskRunnerHandle::Get()); |
56 } | 59 } |
57 | 60 |
58 TestInProcessContextProvider::TestInProcessContextProvider( | 61 TestInProcessContextProvider::TestInProcessContextProvider( |
59 TestInProcessContextProvider* shared_context) | 62 TestInProcessContextProvider* shared_context) { |
60 : context_(CreateTestInProcessContext( | 63 context_ = CreateTestInProcessContext( |
61 &gpu_memory_buffer_manager_, | 64 &gpu_memory_buffer_manager_, &image_factory_, |
62 &image_factory_, | 65 (shared_context ? shared_context->context_.get() : nullptr), |
63 (shared_context ? shared_context->context_.get() : nullptr))), | 66 base::ThreadTaskRunnerHandle::Get()); |
64 cache_controller_( | 67 cache_controller_.reset(new ContextCacheController( |
65 new ContextCacheController(context_->GetImplementation())) {} | 68 context_->GetImplementation(), base::ThreadTaskRunnerHandle::Get())); |
| 69 } |
66 | 70 |
67 TestInProcessContextProvider::~TestInProcessContextProvider() { | 71 TestInProcessContextProvider::~TestInProcessContextProvider() { |
68 } | 72 } |
69 | 73 |
70 bool TestInProcessContextProvider::BindToCurrentThread() { | 74 bool TestInProcessContextProvider::BindToCurrentThread() { |
71 return true; | 75 return true; |
72 } | 76 } |
73 | 77 |
74 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { | 78 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { |
75 return context_->GetImplementation(); | 79 return context_->GetImplementation(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 capabilities.texture_format_bgra8888 = true; | 118 capabilities.texture_format_bgra8888 = true; |
115 break; | 119 break; |
116 } | 120 } |
117 return capabilities; | 121 return capabilities; |
118 } | 122 } |
119 | 123 |
120 void TestInProcessContextProvider::SetLostContextCallback( | 124 void TestInProcessContextProvider::SetLostContextCallback( |
121 const LostContextCallback& lost_context_callback) {} | 125 const LostContextCallback& lost_context_callback) {} |
122 | 126 |
123 } // namespace cc | 127 } // namespace cc |
OLD | NEW |