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 "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" | 7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa
ce.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "gpu/command_buffer/client/gl_in_process_context.h" | 9 #include "gpu/command_buffer/client/gl_in_process_context.h" |
10 #include "ui/gl/android/surface_texture.h" | 10 #include "ui/gl/android/surface_texture.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 if (failed) { | 173 if (failed) { |
174 offscreen_context_for_main_thread_ = NULL; | 174 offscreen_context_for_main_thread_ = NULL; |
175 } | 175 } |
176 return offscreen_context_for_main_thread_; | 176 return offscreen_context_for_main_thread_; |
177 } | 177 } |
178 | 178 |
179 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: | 179 scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl:: |
180 CreateOnscreenContextProviderForCompositorThread( | 180 CreateOnscreenContextProviderForCompositorThread( |
181 scoped_refptr<gfx::GLSurface> surface) { | 181 scoped_refptr<gfx::GLSurface> surface) { |
182 DCHECK(surface); | |
183 DCHECK(service_); | 182 DCHECK(service_); |
184 | 183 |
185 if (!share_context_.get()) | 184 |
186 share_context_ = CreateContext(NULL, service_, NULL); | 185 // TODO(boliu): This sucks. Find a better way. |
| 186 gpu::GLInProcessContext* share_context = NULL; |
| 187 { |
| 188 base::AutoLock lock(num_hardware_compositor_lock_); |
| 189 share_context = share_context_.get(); |
| 190 } |
| 191 if (!share_context) { |
| 192 scoped_ptr<gpu::GLInProcessContext> context = CreateContext(NULL, service_,
NULL); |
| 193 { |
| 194 base::AutoLock lock(num_hardware_compositor_lock_); |
| 195 if (!share_context_.get()) |
| 196 share_context_ = context.Pass(); |
| 197 share_context = share_context_.get(); |
| 198 } |
| 199 } |
| 200 |
187 return webkit::gpu::ContextProviderInProcess::Create( | 201 return webkit::gpu::ContextProviderInProcess::Create( |
188 WrapContext(CreateContext(surface, service_, share_context_.get())), | 202 WrapContext(CreateContext(surface, service_, share_context)), |
189 "Compositor-Onscreen"); | 203 "Compositor-Onscreen"); |
190 } | 204 } |
191 | 205 |
192 scoped_refptr<StreamTextureFactory> | 206 scoped_refptr<StreamTextureFactory> |
193 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int view_id) { | 207 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int view_id) { |
194 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( | 208 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( |
195 StreamTextureFactorySynchronousImpl::Create( | 209 StreamTextureFactorySynchronousImpl::Create( |
196 base::Bind( | 210 base::Bind( |
197 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, | 211 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, |
198 base::Unretained(this)), | 212 base::Unretained(this)), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 return video_context_provider_; | 254 return video_context_provider_; |
241 } | 255 } |
242 | 256 |
243 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( | 257 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( |
244 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { | 258 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { |
245 DCHECK(!service_); | 259 DCHECK(!service_); |
246 service_ = service; | 260 service_ = service; |
247 } | 261 } |
248 | 262 |
249 } // namespace content | 263 } // namespace content |
OLD | NEW |