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