OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/ipc/service/gpu_command_buffer_stub.h" | 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 command_buffer_id_.GetUnsafeValue()), | 463 command_buffer_id_.GetUnsafeValue()), |
464 manager->shader_translator_cache(), | 464 manager->shader_translator_cache(), |
465 manager->framebuffer_completeness_cache(), feature_info, | 465 manager->framebuffer_completeness_cache(), feature_info, |
466 init_params.attribs.bind_generates_resource); | 466 init_params.attribs.bind_generates_resource); |
467 } | 467 } |
468 | 468 |
469 #if defined(OS_MACOSX) | 469 #if defined(OS_MACOSX) |
470 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent | 470 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent |
471 // performance regressions when enabling FCM. | 471 // performance regressions when enabling FCM. |
472 // http://crbug.com/180463 | 472 // http://crbug.com/180463 |
473 if (init_params.gpu_preference == gfx::PreferIntegratedGpu) | 473 if (init_params.gpu_preference == gl::PreferIntegratedGpu) |
474 use_virtualized_gl_context_ = true; | 474 use_virtualized_gl_context_ = true; |
475 #endif | 475 #endif |
476 | 476 |
477 use_virtualized_gl_context_ |= | 477 use_virtualized_gl_context_ |= |
478 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts; | 478 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts; |
479 | 479 |
480 // MailboxManagerSync synchronization correctness currently depends on having | 480 // MailboxManagerSync synchronization correctness currently depends on having |
481 // only a single context. See crbug.com/510243 for details. | 481 // only a single context. See crbug.com/510243 for details. |
482 use_virtualized_gl_context_ |= channel_->mailbox_manager()->UsesSync(); | 482 use_virtualized_gl_context_ |= channel_->mailbox_manager()->UsesSync(); |
483 | 483 |
484 gfx::GLSurface::Format surface_format = gfx::GLSurface::SURFACE_DEFAULT; | 484 gl::GLSurface::Format surface_format = gl::GLSurface::SURFACE_DEFAULT; |
485 bool offscreen = (surface_handle_ == kNullSurfaceHandle); | 485 bool offscreen = (surface_handle_ == kNullSurfaceHandle); |
486 #if defined(OS_ANDROID) | 486 #if defined(OS_ANDROID) |
487 if (init_params.attribs.red_size <= 5 && | 487 if (init_params.attribs.red_size <= 5 && |
488 init_params.attribs.green_size <= 6 && | 488 init_params.attribs.green_size <= 6 && |
489 init_params.attribs.blue_size <= 5 && | 489 init_params.attribs.blue_size <= 5 && |
490 init_params.attribs.alpha_size == 0) | 490 init_params.attribs.alpha_size == 0) |
491 surface_format = gfx::GLSurface::SURFACE_RGB565; | 491 surface_format = gl::GLSurface::SURFACE_RGB565; |
492 gfx::GLSurface* default_surface = manager->GetDefaultOffscreenSurface(); | 492 gl::GLSurface* default_surface = manager->GetDefaultOffscreenSurface(); |
493 // We can only use virtualized contexts for onscreen command buffers if their | 493 // We can only use virtualized contexts for onscreen command buffers if their |
494 // config is compatible with the offscreen ones - otherwise MakeCurrent fails. | 494 // config is compatible with the offscreen ones - otherwise MakeCurrent fails. |
495 if (surface_format != default_surface->GetFormat() && !offscreen) | 495 if (surface_format != default_surface->GetFormat() && !offscreen) |
496 use_virtualized_gl_context_ = false; | 496 use_virtualized_gl_context_ = false; |
497 #endif | 497 #endif |
498 | 498 |
499 gfx::Size initial_size = init_params.size; | 499 gfx::Size initial_size = init_params.size; |
500 if (offscreen && initial_size.IsEmpty()) { | 500 if (offscreen && initial_size.IsEmpty()) { |
501 // If we're an offscreen surface with zero width and/or height, set to a | 501 // If we're an offscreen surface with zero width and/or height, set to a |
502 // non-zero size so that we have a complete framebuffer for operations like | 502 // non-zero size so that we have a complete framebuffer for operations like |
(...skipping 21 matching lines...) Expand all Loading... |
524 } else { | 524 } else { |
525 surface_ = ImageTransportSurface::CreateNativeSurface( | 525 surface_ = ImageTransportSurface::CreateNativeSurface( |
526 manager, this, surface_handle_, surface_format); | 526 manager, this, surface_handle_, surface_format); |
527 if (!surface_ || !surface_->Initialize(surface_format)) { | 527 if (!surface_ || !surface_->Initialize(surface_format)) { |
528 surface_ = nullptr; | 528 surface_ = nullptr; |
529 DLOG(ERROR) << "Failed to create surface."; | 529 DLOG(ERROR) << "Failed to create surface."; |
530 return false; | 530 return false; |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 scoped_refptr<gfx::GLContext> context; | 534 scoped_refptr<gl::GLContext> context; |
535 gfx::GLShareGroup* gl_share_group = channel_->share_group(); | 535 gl::GLShareGroup* gl_share_group = channel_->share_group(); |
536 if (use_virtualized_gl_context_ && gl_share_group) { | 536 if (use_virtualized_gl_context_ && gl_share_group) { |
537 context = gl_share_group->GetSharedContext(); | 537 context = gl_share_group->GetSharedContext(); |
538 if (!context.get()) { | 538 if (!context.get()) { |
539 context = gl::init::CreateGLContext( | 539 context = gl::init::CreateGLContext( |
540 gl_share_group, | 540 gl_share_group, |
541 manager->GetDefaultOffscreenSurface(), | 541 manager->GetDefaultOffscreenSurface(), |
542 init_params.gpu_preference); | 542 init_params.gpu_preference); |
543 if (!context.get()) { | 543 if (!context.get()) { |
544 DLOG(ERROR) << "Failed to create shared context for virtualization."; | 544 DLOG(ERROR) << "Failed to create shared context for virtualization."; |
545 return false; | 545 return false; |
546 } | 546 } |
547 // Ensure that context creation did not lose track of the intended | 547 // Ensure that context creation did not lose track of the intended |
548 // gl_share_group. | 548 // gl_share_group. |
549 DCHECK(context->share_group() == gl_share_group); | 549 DCHECK(context->share_group() == gl_share_group); |
550 gl_share_group->SetSharedContext(context.get()); | 550 gl_share_group->SetSharedContext(context.get()); |
551 } | 551 } |
552 // This should be either: | 552 // This should be either: |
553 // (1) a non-virtual GL context, or | 553 // (1) a non-virtual GL context, or |
554 // (2) a mock context. | 554 // (2) a mock context. |
555 DCHECK(context->GetHandle() || | 555 DCHECK(context->GetHandle() || |
556 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL); | 556 gl::GetGLImplementation() == gl::kGLImplementationMockGL); |
557 context = new GLContextVirtual( | 557 context = new GLContextVirtual( |
558 gl_share_group, context.get(), decoder_->AsWeakPtr()); | 558 gl_share_group, context.get(), decoder_->AsWeakPtr()); |
559 if (!context->Initialize(surface_.get(), init_params.gpu_preference)) { | 559 if (!context->Initialize(surface_.get(), init_params.gpu_preference)) { |
560 // The real context created above for the default offscreen surface | 560 // The real context created above for the default offscreen surface |
561 // might not be compatible with this surface. | 561 // might not be compatible with this surface. |
562 context = NULL; | 562 context = NULL; |
563 DLOG(ERROR) << "Failed to initialize virtual GL context."; | 563 DLOG(ERROR) << "Failed to initialize virtual GL context."; |
564 return false; | 564 return false; |
565 } | 565 } |
566 } | 566 } |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1057 |
1058 // Work around issues with recovery by allowing a new GPU process to launch. | 1058 // Work around issues with recovery by allowing a new GPU process to launch. |
1059 if ((was_lost_by_robustness || | 1059 if ((was_lost_by_robustness || |
1060 context_group_->feature_info()->workarounds().exit_on_context_lost)) { | 1060 context_group_->feature_info()->workarounds().exit_on_context_lost)) { |
1061 channel_->gpu_channel_manager()->MaybeExitOnContextLost(); | 1061 channel_->gpu_channel_manager()->MaybeExitOnContextLost(); |
1062 } | 1062 } |
1063 | 1063 |
1064 // Lose all other contexts if the reset was triggered by the robustness | 1064 // Lose all other contexts if the reset was triggered by the robustness |
1065 // extension instead of being synthetic. | 1065 // extension instead of being synthetic. |
1066 if (was_lost_by_robustness && | 1066 if (was_lost_by_robustness && |
1067 (gfx::GLContext::LosesAllContextsOnContextLost() || | 1067 (gl::GLContext::LosesAllContextsOnContextLost() || |
1068 use_virtualized_gl_context_)) { | 1068 use_virtualized_gl_context_)) { |
1069 channel_->LoseAllContexts(); | 1069 channel_->LoseAllContexts(); |
1070 } | 1070 } |
1071 } | 1071 } |
1072 | 1072 |
1073 CheckCompleteWaits(); | 1073 CheckCompleteWaits(); |
1074 return was_lost; | 1074 return was_lost; |
1075 } | 1075 } |
1076 | 1076 |
1077 void GpuCommandBufferStub::MarkContextLost() { | 1077 void GpuCommandBufferStub::MarkContextLost() { |
(...skipping 12 matching lines...) Expand all Loading... |
1090 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); | 1090 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); |
1091 } | 1091 } |
1092 | 1092 |
1093 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1093 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1094 base::TimeDelta interval) { | 1094 base::TimeDelta interval) { |
1095 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1095 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1096 interval)); | 1096 interval)); |
1097 } | 1097 } |
1098 | 1098 |
1099 } // namespace gpu | 1099 } // namespace gpu |
OLD | NEW |