| 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 "components/view_manager/gles2/command_buffer_driver.h" | 5 #include "components/view_manager/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 "components/view_manager/gles2/command_buffer_type_conversions.h" | 10 #include "components/view_manager/gles2/command_buffer_type_conversions.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 static_cast<gpu::error::ContextLostReason>( | 101 static_cast<gpu::error::ContextLostReason>( |
| 102 decoder_->GetContextLostReason()); | 102 decoder_->GetContextLostReason()); |
| 103 command_buffer_->SetContextLostReason(reason); | 103 command_buffer_->SetContextLostReason(reason); |
| 104 command_buffer_->SetParseError(gpu::error::kLostContext); | 104 command_buffer_->SetParseError(gpu::error::kLostContext); |
| 105 OnContextLost(reason); | 105 OnContextLost(reason); |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool CommandBufferDriver::DoInitialize( | 109 bool CommandBufferDriver::DoInitialize( |
| 110 mojo::ScopedSharedBufferHandle shared_state) { | 110 mojo::ScopedSharedBufferHandle shared_state) { |
| 111 if (widget_ == gfx::kNullAcceleratedWidget) | 111 if (widget_ == gfx::kNullAcceleratedWidget) { |
| 112 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); | 112 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); |
| 113 else { | 113 } else { |
| 114 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 114 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); |
| 115 if (auto vsync_provider = surface_->GetVSyncProvider()) { | |
| 116 vsync_provider->GetVSyncParameters( | |
| 117 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, | |
| 118 weak_factory_.GetWeakPtr())); | |
| 119 } | |
| 120 } | 115 } |
| 121 | 116 |
| 122 if (!surface_.get()) | 117 if (!surface_.get()) |
| 123 return false; | 118 return false; |
| 124 | 119 |
| 125 // TODO(piman): virtual contexts, gpu preference. | 120 // TODO(piman): virtual contexts, gpu preference. |
| 126 context_ = gfx::GLContext::CreateGLContext( | 121 context_ = gfx::GLContext::CreateGLContext( |
| 127 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); | 122 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); |
| 128 if (!context_.get()) | 123 if (!context_.get()) |
| 129 return false; | 124 return false; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 334 |
| 340 void CommandBufferDriver::OnSyncPointRetired() { | 335 void CommandBufferDriver::OnSyncPointRetired() { |
| 341 scheduler_->SetScheduled(true); | 336 scheduler_->SetScheduled(true); |
| 342 } | 337 } |
| 343 | 338 |
| 344 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 339 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
| 345 loss_observer_->DidLoseContext(reason); | 340 loss_observer_->DidLoseContext(reason); |
| 346 client_->DidLoseContext(); | 341 client_->DidLoseContext(); |
| 347 } | 342 } |
| 348 | 343 |
| 349 void CommandBufferDriver::OnUpdateVSyncParameters( | |
| 350 const base::TimeTicks timebase, | |
| 351 const base::TimeDelta interval) { | |
| 352 client_->UpdateVSyncParameters(timebase, interval); | |
| 353 } | |
| 354 | |
| 355 void CommandBufferDriver::DestroyDecoder() { | 344 void CommandBufferDriver::DestroyDecoder() { |
| 356 if (decoder_) { | 345 if (decoder_) { |
| 357 bool have_context = decoder_->MakeCurrent(); | 346 bool have_context = decoder_->MakeCurrent(); |
| 358 decoder_->Destroy(have_context); | 347 decoder_->Destroy(have_context); |
| 359 decoder_.reset(); | 348 decoder_.reset(); |
| 360 } | 349 } |
| 361 } | 350 } |
| 362 | 351 |
| 363 } // namespace gles2 | 352 } // namespace gles2 |
| OLD | NEW |