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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 static_cast<gpu::error::ContextLostReason>( | 81 static_cast<gpu::error::ContextLostReason>( |
82 decoder_->GetContextLostReason()); | 82 decoder_->GetContextLostReason()); |
83 command_buffer_->SetContextLostReason(reason); | 83 command_buffer_->SetContextLostReason(reason); |
84 command_buffer_->SetParseError(gpu::error::kLostContext); | 84 command_buffer_->SetParseError(gpu::error::kLostContext); |
85 OnContextLost(reason); | 85 OnContextLost(reason); |
86 return false; | 86 return false; |
87 } | 87 } |
88 | 88 |
89 bool CommandBufferDriver::DoInitialize( | 89 bool CommandBufferDriver::DoInitialize( |
90 mojo::ScopedSharedBufferHandle shared_state) { | 90 mojo::ScopedSharedBufferHandle shared_state) { |
91 if (widget_ == gfx::kNullAcceleratedWidget) | 91 if (widget_ == gfx::kNullAcceleratedWidget) { |
sky
2015/08/18 17:42:26
nit: nuke all {} here.
Fady Samuel
2015/08/18 19:16:49
Hmm, CommandBufferDriver doesn't actually need wid
| |
92 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); | 92 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); |
93 else { | 93 } else { |
94 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 94 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); |
95 if (auto vsync_provider = surface_->GetVSyncProvider()) { | |
96 vsync_provider->GetVSyncParameters( | |
97 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, | |
98 weak_factory_.GetWeakPtr())); | |
99 } | |
100 } | 95 } |
101 | 96 |
102 if (!surface_.get()) | 97 if (!surface_.get()) |
103 return false; | 98 return false; |
104 | 99 |
105 // TODO(piman): virtual contexts, gpu preference. | 100 // TODO(piman): virtual contexts, gpu preference. |
106 context_ = gfx::GLContext::CreateGLContext( | 101 context_ = gfx::GLContext::CreateGLContext( |
107 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); | 102 gpu_state_->share_group(), surface_.get(), gfx::PreferIntegratedGpu); |
108 if (!context_.get()) | 103 if (!context_.get()) |
109 return false; | 104 return false; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 | 313 |
319 void CommandBufferDriver::OnSyncPointRetired() { | 314 void CommandBufferDriver::OnSyncPointRetired() { |
320 scheduler_->SetScheduled(true); | 315 scheduler_->SetScheduled(true); |
321 } | 316 } |
322 | 317 |
323 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 318 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
324 loss_observer_->DidLoseContext(reason); | 319 loss_observer_->DidLoseContext(reason); |
325 client_->DidLoseContext(); | 320 client_->DidLoseContext(); |
326 } | 321 } |
327 | 322 |
328 void CommandBufferDriver::OnUpdateVSyncParameters( | |
329 const base::TimeTicks timebase, | |
330 const base::TimeDelta interval) { | |
331 client_->UpdateVSyncParameters(timebase, interval); | |
332 } | |
333 | |
334 void CommandBufferDriver::DestroyDecoder() { | 323 void CommandBufferDriver::DestroyDecoder() { |
335 if (decoder_) { | 324 if (decoder_) { |
336 bool have_context = decoder_->MakeCurrent(); | 325 bool have_context = decoder_->MakeCurrent(); |
337 decoder_->Destroy(have_context); | 326 decoder_->Destroy(have_context); |
338 decoder_.reset(); | 327 decoder_.reset(); |
339 } | 328 } |
340 } | 329 } |
341 | 330 |
342 } // namespace gles2 | 331 } // namespace gles2 |
OLD | NEW |