OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_factory_impl
.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
12 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
13 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
14 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
15 #include "content/browser/android/in_process/context_provider_in_process.h" | 17 #include "content/browser/android/in_process/context_provider_in_process.h" |
16 #include "content/browser/android/in_process/synchronous_compositor_impl.h" | 18 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
17 #include "content/browser/android/in_process/synchronous_compositor_registry_in_
proc.h" | 19 #include "content/browser/android/in_process/synchronous_compositor_registry_in_
proc.h" |
18 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 20 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
19 #include "content/common/gpu/client/context_provider_command_buffer.h" | 21 #include "content/common/gpu/client/context_provider_command_buffer.h" |
20 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 22 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
21 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
(...skipping 13 matching lines...) Expand all Loading... |
35 | 37 |
36 using cc_blink::ContextProviderWebContext; | 38 using cc_blink::ContextProviderWebContext; |
37 using gpu_blink::WebGraphicsContext3DImpl; | 39 using gpu_blink::WebGraphicsContext3DImpl; |
38 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 40 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
39 | 41 |
40 namespace content { | 42 namespace content { |
41 | 43 |
42 namespace { | 44 namespace { |
43 | 45 |
44 struct ContextHolder { | 46 struct ContextHolder { |
45 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> command_buffer; | 47 std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> |
| 48 command_buffer; |
46 gpu::GLInProcessContext* gl_in_process_context; | 49 gpu::GLInProcessContext* gl_in_process_context; |
47 }; | 50 }; |
48 | 51 |
49 ContextHolder CreateContextHolder( | 52 ContextHolder CreateContextHolder( |
50 const gpu::gles2::ContextCreationAttribHelper& attributes, | 53 const gpu::gles2::ContextCreationAttribHelper& attributes, |
51 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 54 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
52 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { | 55 const gpu::GLInProcessContextSharedMemoryLimits& mem_limits) { |
53 bool is_offscreen = true; | 56 bool is_offscreen = true; |
54 scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create( | 57 std::unique_ptr<gpu::GLInProcessContext> context( |
55 service, nullptr /* surface */, is_offscreen, gfx::kNullAcceleratedWidget, | 58 gpu::GLInProcessContext::Create( |
56 gfx::Size(1, 1), nullptr /* share_context */, attributes, | 59 service, nullptr /* surface */, is_offscreen, |
57 gfx::PreferDiscreteGpu, mem_limits, | 60 gfx::kNullAcceleratedWidget, gfx::Size(1, 1), |
58 BrowserGpuMemoryBufferManager::current(), nullptr)); | 61 nullptr /* share_context */, attributes, gfx::PreferDiscreteGpu, |
| 62 mem_limits, BrowserGpuMemoryBufferManager::current(), nullptr)); |
59 | 63 |
60 gpu::GLInProcessContext* context_ptr = context.get(); | 64 gpu::GLInProcessContext* context_ptr = context.get(); |
61 | 65 |
62 ContextHolder holder; | 66 ContextHolder holder; |
63 holder.command_buffer = | 67 holder.command_buffer = |
64 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( | 68 std::unique_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( |
65 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( | 69 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
66 std::move(context), attributes)); | 70 std::move(context), attributes)); |
67 holder.gl_in_process_context = context_ptr; | 71 holder.gl_in_process_context = context_ptr; |
68 | 72 |
69 return holder; | 73 return holder; |
70 } | 74 } |
71 | 75 |
72 } // namespace | 76 } // namespace |
73 | 77 |
74 SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl() { | 78 SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl() { |
75 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 79 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
76 switches::kSingleProcess)) { | 80 switches::kSingleProcess)) { |
77 // TODO(boliu): Figure out how to deal with this more nicely. | 81 // TODO(boliu): Figure out how to deal with this more nicely. |
78 SynchronousCompositorFactory::SetInstance(this); | 82 SynchronousCompositorFactory::SetInstance(this); |
79 } | 83 } |
80 } | 84 } |
81 | 85 |
82 SynchronousCompositorFactoryImpl::~SynchronousCompositorFactoryImpl() {} | 86 SynchronousCompositorFactoryImpl::~SynchronousCompositorFactoryImpl() {} |
83 | 87 |
84 scoped_refptr<base::SingleThreadTaskRunner> | 88 scoped_refptr<base::SingleThreadTaskRunner> |
85 SynchronousCompositorFactoryImpl::GetCompositorTaskRunner() { | 89 SynchronousCompositorFactoryImpl::GetCompositorTaskRunner() { |
86 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 90 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
87 } | 91 } |
88 | 92 |
89 scoped_ptr<cc::OutputSurface> | 93 std::unique_ptr<cc::OutputSurface> |
90 SynchronousCompositorFactoryImpl::CreateOutputSurface( | 94 SynchronousCompositorFactoryImpl::CreateOutputSurface( |
91 int routing_id, | 95 int routing_id, |
92 uint32_t output_surface_id, | 96 uint32_t output_surface_id, |
93 const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, | 97 const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, |
94 const scoped_refptr<cc::ContextProvider>& onscreen_context, | 98 const scoped_refptr<cc::ContextProvider>& onscreen_context, |
95 const scoped_refptr<cc::ContextProvider>& worker_context) { | 99 const scoped_refptr<cc::ContextProvider>& worker_context) { |
96 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 100 return base::WrapUnique(new SynchronousCompositorOutputSurface( |
97 onscreen_context, worker_context, routing_id, output_surface_id, | 101 onscreen_context, worker_context, routing_id, output_surface_id, |
98 SynchronousCompositorRegistryInProc::GetInstance(), | 102 SynchronousCompositorRegistryInProc::GetInstance(), |
99 frame_swap_message_queue)); | 103 frame_swap_message_queue)); |
100 } | 104 } |
101 | 105 |
102 InputHandlerManagerClient* | 106 InputHandlerManagerClient* |
103 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { | 107 SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { |
104 return synchronous_input_event_filter(); | 108 return synchronous_input_event_filter(); |
105 } | 109 } |
106 | 110 |
107 SynchronousInputHandlerProxyClient* | 111 SynchronousInputHandlerProxyClient* |
108 SynchronousCompositorFactoryImpl::GetSynchronousInputHandlerProxyClient() { | 112 SynchronousCompositorFactoryImpl::GetSynchronousInputHandlerProxyClient() { |
109 return synchronous_input_event_filter(); | 113 return synchronous_input_event_filter(); |
110 } | 114 } |
111 | 115 |
112 scoped_ptr<cc::BeginFrameSource> | 116 std::unique_ptr<cc::BeginFrameSource> |
113 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( | 117 SynchronousCompositorFactoryImpl::CreateExternalBeginFrameSource( |
114 int routing_id) { | 118 int routing_id) { |
115 return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource( | 119 return base::WrapUnique(new SynchronousCompositorExternalBeginFrameSource( |
116 routing_id, SynchronousCompositorRegistryInProc::GetInstance())); | 120 routing_id, SynchronousCompositorRegistryInProc::GetInstance())); |
117 } | 121 } |
118 | 122 |
119 // SynchronousCompositorStreamTextureFactoryImpl. | 123 // SynchronousCompositorStreamTextureFactoryImpl. |
120 | 124 |
121 class SynchronousCompositorStreamTextureFactoryImpl::VideoContextProvider | 125 class SynchronousCompositorStreamTextureFactoryImpl::VideoContextProvider |
122 : public StreamTextureFactorySynchronousImpl::ContextProvider { | 126 : public StreamTextureFactorySynchronousImpl::ContextProvider { |
123 public: | 127 public: |
124 VideoContextProvider(scoped_refptr<cc::ContextProvider> context_provider, | 128 VideoContextProvider(scoped_refptr<cc::ContextProvider> context_provider, |
125 gpu::GLInProcessContext* gl_in_process_context) | 129 gpu::GLInProcessContext* gl_in_process_context) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 DCHECK(!android_view_service_.get()); | 271 DCHECK(!android_view_service_.get()); |
268 android_view_service_ = service; | 272 android_view_service_ = service; |
269 | 273 |
270 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 274 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
271 switches::kSingleProcess)) { | 275 switches::kSingleProcess)) { |
272 RenderThreadImpl::SetStreamTextureFactory(CreateStreamTextureFactory()); | 276 RenderThreadImpl::SetStreamTextureFactory(CreateStreamTextureFactory()); |
273 } | 277 } |
274 } | 278 } |
275 | 279 |
276 } // namespace content | 280 } // namespace content |
OLD | NEW |