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 "cc/resources/platform_color.h" | 11 #include "cc/resources/platform_color.h" |
12 #include "gpu/GLES2/gl2extchromium.h" | 12 #include "gpu/GLES2/gl2extchromium.h" |
13 #include "gpu/command_buffer/client/gl_in_process_context.h" | 13 #include "gpu/command_buffer/client/gl_in_process_context.h" |
14 #include "gpu/command_buffer/client/gles2_implementation.h" | 14 #include "gpu/command_buffer/client/gles2_implementation.h" |
15 #include "gpu/command_buffer/client/gles2_lib.h" | 15 #include "gpu/command_buffer/client/gles2_lib.h" |
16 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 16 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
17 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 17 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
19 #include "third_party/khronos/GLES2/gl2ext.h" | 19 #include "third_party/khronos/GLES2/gl2ext.h" |
20 #include "third_party/skia/include/gpu/GrContext.h" | 20 #include "third_party/skia/include/gpu/GrContext.h" |
21 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 21 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
22 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 | 25 |
26 // static | 26 // static |
27 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( | 27 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( |
28 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, | 28 TestGpuMemoryBufferManager* gpu_memory_buffer_manager, |
29 TestImageFactory* image_factory) { | 29 TestImageFactory* image_factory, |
| 30 gpu::GLInProcessContext* shared_context) { |
30 const bool is_offscreen = true; | 31 const bool is_offscreen = true; |
31 const bool share_resources = true; | |
32 gpu::gles2::ContextCreationAttribHelper attribs; | 32 gpu::gles2::ContextCreationAttribHelper attribs; |
33 attribs.alpha_size = 8; | 33 attribs.alpha_size = 8; |
34 attribs.blue_size = 8; | 34 attribs.blue_size = 8; |
35 attribs.green_size = 8; | 35 attribs.green_size = 8; |
36 attribs.red_size = 8; | 36 attribs.red_size = 8; |
37 attribs.depth_size = 24; | 37 attribs.depth_size = 24; |
38 attribs.stencil_size = 8; | 38 attribs.stencil_size = 8; |
39 attribs.samples = 0; | 39 attribs.samples = 0; |
40 attribs.sample_buffers = 0; | 40 attribs.sample_buffers = 0; |
41 attribs.fail_if_major_perf_caveat = false; | 41 attribs.fail_if_major_perf_caveat = false; |
42 attribs.bind_generates_resource = false; | 42 attribs.bind_generates_resource = false; |
43 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 43 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
44 | 44 |
45 scoped_ptr<gpu::GLInProcessContext> context = | 45 scoped_ptr<gpu::GLInProcessContext> context = |
46 make_scoped_ptr(gpu::GLInProcessContext::Create( | 46 make_scoped_ptr(gpu::GLInProcessContext::Create( |
47 NULL, | 47 nullptr, nullptr, is_offscreen, gfx::kNullAcceleratedWidget, |
48 NULL, | 48 gfx::Size(1, 1), shared_context, attribs, gpu_preference, |
49 is_offscreen, | |
50 gfx::kNullAcceleratedWidget, | |
51 gfx::Size(1, 1), | |
52 NULL, | |
53 share_resources, | |
54 attribs, | |
55 gpu_preference, | |
56 gpu::GLInProcessContextSharedMemoryLimits(), | 49 gpu::GLInProcessContextSharedMemoryLimits(), |
57 gpu_memory_buffer_manager, | 50 gpu_memory_buffer_manager, image_factory)); |
58 image_factory)); | |
59 | 51 |
60 DCHECK(context); | 52 DCHECK(context); |
61 return context; | 53 return context; |
62 } | 54 } |
63 | 55 |
64 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { | 56 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { |
65 return CreateTestInProcessContext(nullptr, nullptr); | 57 return CreateTestInProcessContext(nullptr, nullptr, nullptr); |
66 } | 58 } |
67 | 59 |
68 TestInProcessContextProvider::TestInProcessContextProvider() | 60 TestInProcessContextProvider::TestInProcessContextProvider( |
69 : context_(CreateTestInProcessContext(&gpu_memory_buffer_manager_, | 61 TestInProcessContextProvider* shared_context) |
70 &image_factory_)) { | 62 : context_(CreateTestInProcessContext( |
71 } | 63 &gpu_memory_buffer_manager_, |
| 64 &image_factory_, |
| 65 (shared_context ? shared_context->context_.get() : nullptr))) {} |
72 | 66 |
73 TestInProcessContextProvider::~TestInProcessContextProvider() { | 67 TestInProcessContextProvider::~TestInProcessContextProvider() { |
74 if (gr_context_) | 68 if (gr_context_) |
75 gr_context_->releaseResourcesAndAbandonContext(); | 69 gr_context_->releaseResourcesAndAbandonContext(); |
76 } | 70 } |
77 | 71 |
78 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } | 72 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } |
79 | 73 |
80 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { | 74 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { |
81 return context_->GetImplementation(); | 75 return context_->GetImplementation(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 125 |
132 void TestInProcessContextProvider::DeleteCachedResources() { | 126 void TestInProcessContextProvider::DeleteCachedResources() { |
133 if (gr_context_) | 127 if (gr_context_) |
134 gr_context_->freeGpuResources(); | 128 gr_context_->freeGpuResources(); |
135 } | 129 } |
136 | 130 |
137 void TestInProcessContextProvider::SetLostContextCallback( | 131 void TestInProcessContextProvider::SetLostContextCallback( |
138 const LostContextCallback& lost_context_callback) {} | 132 const LostContextCallback& lost_context_callback) {} |
139 | 133 |
140 } // namespace cc | 134 } // namespace cc |
OLD | NEW |