Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: cc/test/test_in_process_context_provider.cc

Issue 2286873003: Provide TaskRunner to ContextCacheController (Closed)
Patch Set: cleanup Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, nullptr);
56 } 58 }
57 59
58 TestInProcessContextProvider::TestInProcessContextProvider( 60 TestInProcessContextProvider::TestInProcessContextProvider(
59 TestInProcessContextProvider* shared_context) 61 TestInProcessContextProvider* shared_context) {
60 : context_(CreateTestInProcessContext( 62 auto task_runner = base::ThreadTaskRunnerHandle::Get();
61 &gpu_memory_buffer_manager_, 63 context_ = CreateTestInProcessContext(
62 &image_factory_, 64 &gpu_memory_buffer_manager_, &image_factory_,
63 (shared_context ? shared_context->context_.get() : nullptr))), 65 (shared_context ? shared_context->context_.get() : nullptr), task_runner);
64 cache_controller_( 66 cache_controller_.reset(new ContextCacheController(
65 new ContextCacheController(context_->GetImplementation())) {} 67 context_->GetImplementation(), std::move(task_runner)));
68 }
66 69
67 TestInProcessContextProvider::~TestInProcessContextProvider() { 70 TestInProcessContextProvider::~TestInProcessContextProvider() {
68 } 71 }
69 72
70 bool TestInProcessContextProvider::BindToCurrentThread() { 73 bool TestInProcessContextProvider::BindToCurrentThread() {
71 return true; 74 return true;
72 } 75 }
73 76
74 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { 77 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() {
75 return context_->GetImplementation(); 78 return context_->GetImplementation();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 capabilities.texture_format_bgra8888 = true; 117 capabilities.texture_format_bgra8888 = true;
115 break; 118 break;
116 } 119 }
117 return capabilities; 120 return capabilities;
118 } 121 }
119 122
120 void TestInProcessContextProvider::SetLostContextCallback( 123 void TestInProcessContextProvider::SetLostContextCallback(
121 const LostContextCallback& lost_context_callback) {} 124 const LostContextCallback& lost_context_callback) {}
122 125
123 } // namespace cc 126 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698