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