Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "services/gles2/command_buffer_driver.h" | 5 #include "services/gles2/command_buffer_driver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // anonymous namespace | 48 } // anonymous namespace |
| 49 | 49 |
| 50 CommandBufferDriver::Client::~Client() { | 50 CommandBufferDriver::Client::~Client() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 CommandBufferDriver::CommandBufferDriver( | 53 CommandBufferDriver::CommandBufferDriver( |
| 54 gfx::GLShareGroup* share_group, | 54 gfx::GLShareGroup* share_group, |
| 55 gpu::gles2::MailboxManager* mailbox_manager, | 55 gpu::gles2::MailboxManager* mailbox_manager, |
| 56 gpu::SyncPointManager* sync_point_manager) | 56 gpu::SyncPointManager* sync_point_manager, |
| 57 gfx::SurfaceConfiguration requested_configuration) | |
|
abarth-chromium
2015/06/09 00:30:21
gfx::SurfaceConfiguration -> const gfx::SurfaceCon
iansf
2015/06/09 01:52:04
Done.
| |
| 57 : CommandBufferDriver(gfx::kNullAcceleratedWidget, | 58 : CommandBufferDriver(gfx::kNullAcceleratedWidget, |
| 58 share_group, | 59 share_group, |
| 59 mailbox_manager, | 60 mailbox_manager, |
| 60 sync_point_manager) { | 61 sync_point_manager, |
| 62 requested_configuration) { | |
| 61 } | 63 } |
| 62 | 64 |
| 63 CommandBufferDriver::CommandBufferDriver( | 65 CommandBufferDriver::CommandBufferDriver( |
| 64 gfx::AcceleratedWidget widget, | 66 gfx::AcceleratedWidget widget, |
| 65 gfx::GLShareGroup* share_group, | 67 gfx::GLShareGroup* share_group, |
| 66 gpu::gles2::MailboxManager* mailbox_manager, | 68 gpu::gles2::MailboxManager* mailbox_manager, |
| 67 gpu::SyncPointManager* sync_point_manager) | 69 gpu::SyncPointManager* sync_point_manager, |
| 70 gfx::SurfaceConfiguration requested_configuration) | |
|
abarth-chromium
2015/06/09 00:30:21
gfx::SurfaceConfiguration -> const gfx::SurfaceCon
iansf
2015/06/09 01:52:04
Done.
| |
| 68 : client_(nullptr), | 71 : client_(nullptr), |
| 69 widget_(widget), | 72 widget_(widget), |
| 70 share_group_(share_group), | 73 share_group_(share_group), |
| 71 mailbox_manager_(mailbox_manager), | 74 mailbox_manager_(mailbox_manager), |
| 72 sync_point_manager_(sync_point_manager), | 75 sync_point_manager_(sync_point_manager), |
| 76 requested_configuration_(requested_configuration), | |
| 73 weak_factory_(this) { | 77 weak_factory_(this) { |
| 74 } | 78 } |
| 75 | 79 |
| 76 CommandBufferDriver::~CommandBufferDriver() { | 80 CommandBufferDriver::~CommandBufferDriver() { |
| 77 if (decoder_) { | 81 if (decoder_) { |
| 78 bool have_context = decoder_->MakeCurrent(); | 82 bool have_context = decoder_->MakeCurrent(); |
| 79 decoder_->Destroy(have_context); | 83 decoder_->Destroy(have_context); |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 83 void CommandBufferDriver::Initialize( | 87 void CommandBufferDriver::Initialize( |
| 84 mojo::CommandBufferSyncClientPtr sync_client, | 88 mojo::CommandBufferSyncClientPtr sync_client, |
| 85 mojo::CommandBufferLostContextObserverPtr loss_observer, | 89 mojo::CommandBufferLostContextObserverPtr loss_observer, |
| 86 mojo::ScopedSharedBufferHandle shared_state) { | 90 mojo::ScopedSharedBufferHandle shared_state) { |
| 87 sync_client_ = sync_client.Pass(); | 91 sync_client_ = sync_client.Pass(); |
| 88 loss_observer_ = loss_observer.Pass(); | 92 loss_observer_ = loss_observer.Pass(); |
| 89 bool success = DoInitialize(shared_state.Pass()); | 93 bool success = DoInitialize(shared_state.Pass()); |
| 90 mojo::GpuCapabilitiesPtr capabilities = | 94 mojo::GpuCapabilitiesPtr capabilities = |
| 91 success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) | 95 success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) |
| 92 : mojo::GpuCapabilities::New(); | 96 : mojo::GpuCapabilities::New(); |
| 93 sync_client_->DidInitialize(success, capabilities.Pass()); | 97 sync_client_->DidInitialize(success, capabilities.Pass()); |
| 94 } | 98 } |
| 95 | 99 |
| 96 bool CommandBufferDriver::DoInitialize( | 100 bool CommandBufferDriver::DoInitialize( |
| 97 mojo::ScopedSharedBufferHandle shared_state) { | 101 mojo::ScopedSharedBufferHandle shared_state) { |
| 98 if (widget_ == gfx::kNullAcceleratedWidget) | 102 if (widget_ == gfx::kNullAcceleratedWidget) |
| 99 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); | 103 surface_ = gfx::GLSurface::CreateOffscreenGLSurface( |
| 104 gfx::Size(1, 1), requested_configuration_); | |
| 100 else { | 105 else { |
| 101 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 106 surface_ = |
| 107 gfx::GLSurface::CreateViewGLSurface(widget_, requested_configuration_); | |
| 102 if (auto vsync_provider = surface_->GetVSyncProvider()) { | 108 if (auto vsync_provider = surface_->GetVSyncProvider()) { |
| 103 vsync_provider->GetVSyncParameters( | 109 vsync_provider->GetVSyncParameters( |
| 104 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, | 110 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, |
| 105 weak_factory_.GetWeakPtr())); | 111 weak_factory_.GetWeakPtr())); |
| 106 } | 112 } |
| 107 } | 113 } |
| 108 | 114 |
| 109 if (!surface_.get()) | 115 if (!surface_.get()) |
| 110 return false; | 116 return false; |
| 111 | 117 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 client_->DidLoseContext(); | 247 client_->DidLoseContext(); |
| 242 } | 248 } |
| 243 | 249 |
| 244 void CommandBufferDriver::OnUpdateVSyncParameters( | 250 void CommandBufferDriver::OnUpdateVSyncParameters( |
| 245 const base::TimeTicks timebase, | 251 const base::TimeTicks timebase, |
| 246 const base::TimeDelta interval) { | 252 const base::TimeDelta interval) { |
| 247 client_->UpdateVSyncParameters(timebase, interval); | 253 client_->UpdateVSyncParameters(timebase, interval); |
| 248 } | 254 } |
| 249 | 255 |
| 250 } // namespace gles2 | 256 } // namespace gles2 |
| OLD | NEW |