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 "components/mus/gles2/command_buffer_driver.h" | 5 #include "components/mus/gles2/command_buffer_driver.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/mus/gles2/gl_surface_adapter.h" | |
| 14 #include "components/mus/gles2/gpu_memory_tracker.h" | 15 #include "components/mus/gles2/gpu_memory_tracker.h" |
| 15 #include "components/mus/gles2/gpu_state.h" | 16 #include "components/mus/gles2/gpu_state.h" |
| 16 #include "components/mus/gles2/mojo_buffer_backing.h" | 17 #include "components/mus/gles2/mojo_buffer_backing.h" |
| 17 #include "gpu/command_buffer/service/command_buffer_service.h" | 18 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 18 #include "gpu/command_buffer/service/command_executor.h" | 19 #include "gpu/command_buffer/service/command_executor.h" |
| 19 #include "gpu/command_buffer/service/context_group.h" | 20 #include "gpu/command_buffer/service/context_group.h" |
| 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 21 #include "gpu/command_buffer/service/image_factory.h" | 22 #include "gpu/command_buffer/service/image_factory.h" |
| 22 #include "gpu/command_buffer/service/image_manager.h" | 23 #include "gpu/command_buffer/service/image_manager.h" |
| 23 #include "gpu/command_buffer/service/mailbox_manager.h" | 24 #include "gpu/command_buffer/service/mailbox_manager.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 75 |
| 75 bool CommandBufferDriver::Initialize( | 76 bool CommandBufferDriver::Initialize( |
| 76 mojo::ScopedSharedBufferHandle shared_state, | 77 mojo::ScopedSharedBufferHandle shared_state, |
| 77 mojo::Array<int32_t> attribs) { | 78 mojo::Array<int32_t> attribs) { |
| 78 DCHECK(CalledOnValidThread()); | 79 DCHECK(CalledOnValidThread()); |
| 79 gpu::gles2::ContextCreationAttribHelper attrib_helper; | 80 gpu::gles2::ContextCreationAttribHelper attrib_helper; |
| 80 if (!attrib_helper.Parse(attribs.storage())) | 81 if (!attrib_helper.Parse(attribs.storage())) |
| 81 return false; | 82 return false; |
| 82 | 83 |
| 83 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; | 84 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; |
| 85 static scoped_refptr<gfx::GLSurface> underlying_surface; | |
| 84 if (offscreen) { | 86 if (offscreen) { |
| 85 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); | 87 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); |
| 86 } else { | 88 } else { |
| 87 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 89 scoped_refptr<GLSurfaceAdapterMus> s = |
|
Fady Samuel
2016/04/01 23:24:42
nit: better variable name than s please?
rjkroege
2016/04/01 23:58:44
Done. I may have been corrupted by viewing the pla
| |
| 90 new GLSurfaceAdapterMus(gfx::GLSurface::CreateViewGLSurface(widget_)); | |
| 91 s->SetGpuCompletedSwapBuffersCallback( | |
| 92 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, | |
| 93 weak_factory_.GetWeakPtr())); | |
| 94 surface_ = s; | |
| 95 | |
| 88 gfx::VSyncProvider* vsync_provider = | 96 gfx::VSyncProvider* vsync_provider = |
| 89 surface_ ? surface_->GetVSyncProvider() : nullptr; | 97 surface_ ? surface_->GetVSyncProvider() : nullptr; |
| 90 if (vsync_provider) { | 98 if (vsync_provider) { |
| 91 vsync_provider->GetVSyncParameters( | 99 vsync_provider->GetVSyncParameters( |
| 92 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, | 100 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, |
| 93 weak_factory_.GetWeakPtr())); | 101 weak_factory_.GetWeakPtr())); |
| 94 } | 102 } |
| 95 } | 103 } |
| 96 | 104 |
| 97 if (!surface_.get()) | 105 if (!surface_.get()) |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 DCHECK(CalledOnValidThread()); | 497 DCHECK(CalledOnValidThread()); |
| 490 | 498 |
| 491 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); | 499 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); |
| 492 gpu::gles2::QueryManager::Query* query = query_manager->GetQuery(query_id); | 500 gpu::gles2::QueryManager::Query* query = query_manager->GetQuery(query_id); |
| 493 if (query) | 501 if (query) |
| 494 query->AddCallback(callback); | 502 query->AddCallback(callback); |
| 495 else | 503 else |
| 496 callback.Run(); | 504 callback.Run(); |
| 497 } | 505 } |
| 498 | 506 |
| 507 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | |
| 508 DCHECK(CalledOnValidThread()); | |
| 509 if (client_) { | |
| 510 client_->OnGpuCompletedSwapBuffers(result); | |
| 511 } | |
| 512 } | |
| 513 | |
| 499 } // namespace mus | 514 } // namespace mus |
| OLD | NEW |