Chromium Code Reviews| 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 "content/common/gpu/gpu_command_buffer_stub.h" | 5 #include "content/common/gpu/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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 } | 157 } |
| 158 | 158 |
| 159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) { | 159 uint64_t GetCommandBufferID(int channel_id, int32_t route_id) { |
| 160 return (static_cast<uint64_t>(channel_id) << 32) | route_id; | 160 return (static_cast<uint64_t>(channel_id) << 32) | route_id; |
| 161 } | 161 } |
| 162 | 162 |
| 163 gfx::GLSurface::Format GetSurfaceFormatFromAttribute( | 163 gfx::GLSurface::Format GetSurfaceFormatFromAttribute( |
| 164 const gpu::gles2::ContextCreationAttribHelper& attrib, | 164 const gpu::gles2::ContextCreationAttribHelper& attrib, |
| 165 bool use_virtualized_gl_context) { | 165 bool use_virtualized_gl_context) { |
| 166 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 | 166 gfx::GLSurface::Format format = gfx::GLSurface::SURFACE_DEFAULT; // ARGB8888 |
| 167 if (!use_virtualized_gl_context && | 167 if (attrib.red_size <= 5 && |
| 168 attrib.red_size <= 5 && | |
| 169 attrib.green_size <= 6 && | 168 attrib.green_size <= 6 && |
| 170 attrib.blue_size <= 5 && | 169 attrib.blue_size <= 5 && |
| 171 attrib.alpha_size == 0) { | 170 attrib.alpha_size == 0) { |
| 172 format = gfx::GLSurface::SURFACE_RGB565; | 171 format = gfx::GLSurface::SURFACE_RGB565; |
| 173 } | 172 } |
| 174 return format; | 173 return format; |
| 175 } | 174 } |
| 176 } // namespace | 175 } // namespace |
| 177 | 176 |
| 178 GpuCommandBufferStub::GpuCommandBufferStub( | 177 GpuCommandBufferStub::GpuCommandBufferStub( |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 surface_ = manager->GetDefaultOffscreenSurface(); | 553 surface_ = manager->GetDefaultOffscreenSurface(); |
| 555 } | 554 } |
| 556 | 555 |
| 557 if (!surface_.get()) { | 556 if (!surface_.get()) { |
| 558 DLOG(ERROR) << "Failed to create surface."; | 557 DLOG(ERROR) << "Failed to create surface."; |
| 559 OnInitializeFailed(reply_message); | 558 OnInitializeFailed(reply_message); |
| 560 return; | 559 return; |
| 561 } | 560 } |
| 562 | 561 |
| 563 scoped_refptr<gfx::GLContext> context; | 562 scoped_refptr<gfx::GLContext> context; |
| 564 if (use_virtualized_gl_context_ && channel_->share_group()) { | 563 gfx::GLShareGroup* share_group = channel_->share_group(); |
| 565 context = channel_->share_group()->GetSharedContext(); | 564 if (use_virtualized_gl_context_ && share_group) { |
|
no sievers
2016/02/17 00:56:26
Is it simpler to just treat |is_onscreen && is_low
Jinsuk Kim
2016/02/17 07:23:32
Good to know that virtualization can be done for s
| |
| 565 context = share_group->GetSharedContext(); | |
| 566 if (!context.get()) { | 566 if (!context.get()) { |
| 567 context = gfx::GLContext::CreateGLContext( | 567 share_group->UpdateActiveSharedContext(surface_.get(), gpu_preference_); |
| 568 channel_->share_group(), | 568 context = share_group->GetSharedContext(); |
| 569 channel_->gpu_channel_manager()->GetDefaultOffscreenSurface(), | |
| 570 gpu_preference_); | |
| 571 if (!context.get()) { | 569 if (!context.get()) { |
| 572 DLOG(ERROR) << "Failed to create shared context for virtualization."; | |
| 573 OnInitializeFailed(reply_message); | 570 OnInitializeFailed(reply_message); |
| 574 return; | 571 return; |
| 575 } | 572 } |
| 576 channel_->share_group()->SetSharedContext(context.get()); | |
| 577 } | 573 } |
| 578 // This should be a non-virtual GL context. | 574 // This should be a non-virtual GL context. |
| 579 DCHECK(context->GetHandle()); | 575 DCHECK(context->GetHandle()); |
| 580 context = new gpu::GLContextVirtual( | 576 context = new gpu::GLContextVirtual( |
| 581 channel_->share_group(), context.get(), decoder_->AsWeakPtr()); | 577 share_group, context.get(), decoder_->AsWeakPtr()); |
| 582 if (!context->Initialize(surface_.get(), gpu_preference_)) { | 578 if (!context->Initialize(surface_.get(), gpu_preference_)) { |
| 583 // TODO(sievers): The real context created above for the default | 579 // Context with incompatible configuration was attempted to be made |
| 584 // offscreen surface might not be compatible with this surface. | 580 // current. Update the shared context to a compatible one and init again. |
| 585 // Need to adjust at least GLX to be able to create the initial context | 581 share_group->UpdateActiveSharedContext(surface_.get(), gpu_preference_); |
| 586 // with a config that is compatible with onscreen and offscreen surfaces. | 582 context->UpdateSharedContext(share_group->GetSharedContext()); |
| 587 context = NULL; | 583 if (!context->Initialize(surface_.get(), gpu_preference_)) { |
| 588 | 584 DLOG(ERROR) << "Failed to initialize virtual GL context."; |
| 589 DLOG(ERROR) << "Failed to initialize virtual GL context."; | 585 OnInitializeFailed(reply_message); |
| 590 OnInitializeFailed(reply_message); | 586 return; |
| 591 return; | 587 } |
| 592 } | 588 } |
| 593 } | 589 } |
| 594 if (!context.get()) { | 590 if (!context.get()) { |
| 595 context = gfx::GLContext::CreateGLContext( | 591 context = gfx::GLContext::CreateGLContext( |
| 596 channel_->share_group(), surface_.get(), gpu_preference_); | 592 share_group, surface_.get(), gpu_preference_); |
| 597 } | 593 } |
| 598 if (!context.get()) { | 594 if (!context.get()) { |
| 599 DLOG(ERROR) << "Failed to create context."; | 595 DLOG(ERROR) << "Failed to create context."; |
| 600 OnInitializeFailed(reply_message); | 596 OnInitializeFailed(reply_message); |
| 601 return; | 597 return; |
| 602 } | 598 } |
| 603 | 599 |
| 604 if (!context->MakeCurrent(surface_.get())) { | 600 if (!context->MakeCurrent(surface_.get())) { |
| 605 LOG(ERROR) << "Failed to make context current."; | 601 LOG(ERROR) << "Failed to make context current."; |
| 606 OnInitializeFailed(reply_message); | 602 OnInitializeFailed(reply_message); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 result)); | 1174 result)); |
| 1179 } | 1175 } |
| 1180 | 1176 |
| 1181 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1177 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1182 base::TimeDelta interval) { | 1178 base::TimeDelta interval) { |
| 1183 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1179 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1184 interval)); | 1180 interval)); |
| 1185 } | 1181 } |
| 1186 | 1182 |
| 1187 } // namespace content | 1183 } // namespace content |
| OLD | NEW |