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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 1230203007: Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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 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/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (num_attempts > kNumRetriesBeforeSoftwareFallback) { 234 if (num_attempts > kNumRetriesBeforeSoftwareFallback) {
235 #if defined(OS_CHROMEOS) 235 #if defined(OS_CHROMEOS)
236 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use " 236 LOG(FATAL) << "Unable to create a UI graphics context, and cannot use "
237 << "software compositing on ChromeOS."; 237 << "software compositing on ChromeOS.";
238 #endif 238 #endif
239 create_gpu_output_surface = false; 239 create_gpu_output_surface = false;
240 } 240 }
241 241
242 scoped_refptr<ContextProviderCommandBuffer> context_provider; 242 scoped_refptr<ContextProviderCommandBuffer> context_provider;
243 if (create_gpu_output_surface) { 243 if (create_gpu_output_surface) {
244 // Try to reuse existing worker context provider.
245 if (shared_worker_context_provider_) {
246 base::AutoLock lock(*shared_worker_context_provider_->GetLock());
247 if (shared_worker_context_provider_->ContextGL()
248 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
249 shared_worker_context_provider_ = nullptr;
250 }
244 scoped_refptr<GpuChannelHost> gpu_channel_host = 251 scoped_refptr<GpuChannelHost> gpu_channel_host =
245 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 252 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
246 if (gpu_channel_host.get()) { 253 if (gpu_channel_host.get()) {
247 context_provider = ContextProviderCommandBuffer::Create( 254 context_provider = ContextProviderCommandBuffer::Create(
248 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host, 255 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host,
249 data->surface_id), 256 data->surface_id),
250 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT); 257 BROWSER_COMPOSITOR_ONSCREEN_CONTEXT);
251 if (context_provider && !context_provider->BindToCurrentThread()) 258 if (context_provider && !context_provider->BindToCurrentThread())
252 context_provider = nullptr; 259 context_provider = nullptr;
260 if (!shared_worker_context_provider_) {
261 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create(
262 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host,
263 0),
264 BROWSER_WORKER_CONTEXT);
265 if (shared_worker_context_provider_ &&
266 !shared_worker_context_provider_->BindToCurrentThread())
267 shared_worker_context_provider_ = nullptr;
268 }
253 } 269 }
254 270
271 bool created_gpu_browser_compositor =
272 !!context_provider && !!shared_worker_context_provider_;
273
255 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 274 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
256 !!context_provider.get()); 275 created_gpu_browser_compositor);
257 276
258 if (!context_provider) { 277 if (!created_gpu_browser_compositor) {
259 // Try again. 278 // Try again.
260 CauseForGpuLaunch cause = 279 CauseForGpuLaunch cause =
261 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 280 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
262 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( 281 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
263 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 282 cause, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
264 callback_factory_.GetWeakPtr(), compositor, 283 callback_factory_.GetWeakPtr(), compositor,
265 create_gpu_output_surface, num_attempts + 1)); 284 create_gpu_output_surface, num_attempts + 1));
266 return; 285 return;
267 } 286 }
268 } 287 }
269 288
270 scoped_ptr<BrowserCompositorOutputSurface> surface; 289 scoped_ptr<BrowserCompositorOutputSurface> surface;
271 if (!create_gpu_output_surface) { 290 if (!create_gpu_output_surface) {
272 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface( 291 surface = make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface(
273 CreateSoftwareOutputDevice(compositor.get()), 292 CreateSoftwareOutputDevice(compositor.get()),
274 compositor->vsync_manager())); 293 compositor->vsync_manager()));
275 } else { 294 } else {
276 DCHECK(context_provider); 295 DCHECK(context_provider);
277 ContextProvider::Capabilities capabilities = 296 ContextProvider::Capabilities capabilities =
278 context_provider->ContextCapabilities(); 297 context_provider->ContextCapabilities();
279 if (!data->surface_id) { 298 if (!data->surface_id) {
280 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface( 299 surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface(
281 context_provider, compositor->vsync_manager(), 300 context_provider, shared_worker_context_provider_,
301 compositor->vsync_manager(),
282 scoped_ptr<BrowserCompositorOverlayCandidateValidator>())); 302 scoped_ptr<BrowserCompositorOverlayCandidateValidator>()));
283 } else if (capabilities.gpu.surfaceless) { 303 } else if (capabilities.gpu.surfaceless) {
284 GLenum target = GL_TEXTURE_2D; 304 GLenum target = GL_TEXTURE_2D;
285 GLenum format = GL_RGB; 305 GLenum format = GL_RGB;
286 #if defined(OS_MACOSX) 306 #if defined(OS_MACOSX)
287 target = GL_TEXTURE_RECTANGLE_ARB; 307 target = GL_TEXTURE_RECTANGLE_ARB;
288 format = GL_BGRA_EXT; 308 format = GL_BGRA_EXT;
289 #endif 309 #endif
290 surface = 310 surface =
291 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface( 311 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface(
292 context_provider, data->surface_id, compositor->vsync_manager(), 312 context_provider, shared_worker_context_provider_,
313 data->surface_id, compositor->vsync_manager(),
293 CreateOverlayCandidateValidator(compositor->widget()), target, 314 CreateOverlayCandidateValidator(compositor->widget()), target,
294 format, BrowserGpuMemoryBufferManager::current())); 315 format, BrowserGpuMemoryBufferManager::current()));
295 } else { 316 } else {
296 if (!surface) { 317 if (!surface) {
297 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface( 318 surface = make_scoped_ptr(new GpuBrowserCompositorOutputSurface(
298 context_provider, compositor->vsync_manager(), 319 context_provider, shared_worker_context_provider_,
320 compositor->vsync_manager(),
299 CreateOverlayCandidateValidator(compositor->widget()))); 321 CreateOverlayCandidateValidator(compositor->widget())));
300 } 322 }
301 } 323 }
302 } 324 }
303 325
304 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an 326 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
305 // output_surface_map_ here. 327 // output_surface_map_ here.
306 output_surface_map_.AddWithID(surface.get(), data->surface_id); 328 output_surface_map_.AddWithID(surface.get(), data->surface_id);
307 data->surface = surface.get(); 329 data->surface = surface.get();
308 if (data->reflector) 330 if (data->reflector)
(...skipping 10 matching lines...) Expand all
319 // SurfaceDisplayOutputSurface set up to draw to the display's surface. 341 // SurfaceDisplayOutputSurface set up to draw to the display's surface.
320 cc::SurfaceManager* manager = surface_manager_.get(); 342 cc::SurfaceManager* manager = surface_manager_.get();
321 scoped_ptr<cc::OnscreenDisplayClient> display_client( 343 scoped_ptr<cc::OnscreenDisplayClient> display_client(
322 new cc::OnscreenDisplayClient( 344 new cc::OnscreenDisplayClient(
323 surface.Pass(), manager, HostSharedBitmapManager::current(), 345 surface.Pass(), manager, HostSharedBitmapManager::current(),
324 BrowserGpuMemoryBufferManager::current(), 346 BrowserGpuMemoryBufferManager::current(),
325 compositor->GetRendererSettings(), compositor->task_runner())); 347 compositor->GetRendererSettings(), compositor->task_runner()));
326 348
327 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface( 349 scoped_ptr<cc::SurfaceDisplayOutputSurface> output_surface(
328 new cc::SurfaceDisplayOutputSurface( 350 new cc::SurfaceDisplayOutputSurface(
329 manager, compositor->surface_id_allocator(), context_provider)); 351 manager, compositor->surface_id_allocator(), context_provider,
352 shared_worker_context_provider_));
330 display_client->set_surface_output_surface(output_surface.get()); 353 display_client->set_surface_output_surface(output_surface.get());
331 output_surface->set_display_client(display_client.get()); 354 output_surface->set_display_client(display_client.get());
332 display_client->display()->Resize(compositor->size()); 355 display_client->display()->Resize(compositor->size());
333 data->display_client = display_client.Pass(); 356 data->display_client = display_client.Pass();
334 compositor->SetOutputSurface(output_surface.Pass()); 357 compositor->SetOutputSurface(output_surface.Pass());
335 } 358 }
336 359
337 scoped_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( 360 scoped_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector(
338 ui::Compositor* source_compositor, 361 ui::Compositor* source_compositor,
339 ui::Layer* target_layer) { 362 ui::Layer* target_layer) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 622 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
600 observer_list_, 623 observer_list_,
601 OnLostResources()); 624 OnLostResources());
602 625
603 // Kill things that use the shared context before killing the shared context. 626 // Kill things that use the shared context before killing the shared context.
604 lost_gl_helper.reset(); 627 lost_gl_helper.reset();
605 lost_shared_main_thread_contexts = NULL; 628 lost_shared_main_thread_contexts = NULL;
606 } 629 }
607 630
608 } // namespace content 631 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698