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

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

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

Powered by Google App Engine
This is Rietveld 408576698