| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_local.h" | 5 #include "components/mus/gles2/command_buffer_local.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "components/mus/gles2/command_buffer_local_client.h" | 9 #include "components/mus/gles2/command_buffer_local_client.h" |
| 10 #include "components/mus/gles2/gpu_memory_tracker.h" | 10 #include "components/mus/gles2/gpu_memory_tracker.h" |
| 11 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" | 11 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" |
| 12 #include "gpu/command_buffer/service/command_buffer_service.h" | 12 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 13 #include "gpu/command_buffer/service/context_group.h" | 13 #include "gpu/command_buffer/service/context_group.h" |
| 14 #include "gpu/command_buffer/service/gpu_scheduler.h" | 14 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 15 #include "gpu/command_buffer/service/image_factory.h" | 15 #include "gpu/command_buffer/service/image_factory.h" |
| 16 #include "gpu/command_buffer/service/image_manager.h" | 16 #include "gpu/command_buffer/service/image_manager.h" |
| 17 #include "gpu/command_buffer/service/memory_tracking.h" | 17 #include "gpu/command_buffer/service/memory_tracking.h" |
| 18 #include "gpu/command_buffer/service/shader_translator_cache.h" | 18 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 19 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 19 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 20 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 20 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 21 #include "ui/gfx/buffer_format_util.h" | |
| 22 #include "ui/gfx/vsync_provider.h" | 21 #include "ui/gfx/vsync_provider.h" |
| 23 #include "ui/gl/gl_context.h" | 22 #include "ui/gl/gl_context.h" |
| 24 #include "ui/gl/gl_image_shared_memory.h" | 23 #include "ui/gl/gl_image_shared_memory.h" |
| 25 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
| 26 | 25 |
| 27 namespace mus { | 26 namespace mus { |
| 28 | 27 |
| 29 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; | 28 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; |
| 30 | 29 |
| 31 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, | 30 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 size_t height, | 132 size_t height, |
| 134 unsigned internalformat) { | 133 unsigned internalformat) { |
| 135 MojoGpuMemoryBufferImpl* gpu_memory_buffer = | 134 MojoGpuMemoryBufferImpl* gpu_memory_buffer = |
| 136 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); | 135 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); |
| 137 | 136 |
| 138 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); | 137 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); |
| 139 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( | 138 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( |
| 140 gfx::Size(static_cast<int>(width), static_cast<int>(height)), | 139 gfx::Size(static_cast<int>(width), static_cast<int>(height)), |
| 141 internalformat)); | 140 internalformat)); |
| 142 if (!image->Initialize(base::SharedMemory::DuplicateHandle(handle.handle), | 141 if (!image->Initialize(base::SharedMemory::DuplicateHandle(handle.handle), |
| 143 handle.id, gpu_memory_buffer->GetFormat(), 0, | 142 handle.id, gpu_memory_buffer->GetFormat(), 0)) { |
| 144 gfx::RowSizeForBufferFormat( | |
| 145 width, gpu_memory_buffer->GetFormat(), 0))) { | |
| 146 return -1; | 143 return -1; |
| 147 } | 144 } |
| 148 | 145 |
| 149 static int32 next_id = 1; | 146 static int32 next_id = 1; |
| 150 int32 new_id = next_id++; | 147 int32 new_id = next_id++; |
| 151 | 148 |
| 152 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 149 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| 153 DCHECK(image_manager); | 150 DCHECK(image_manager); |
| 154 image_manager->AddImage(image.get(), new_id); | 151 image_manager->AddImage(image.get(), new_id); |
| 155 return new_id; | 152 return new_id; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 void CommandBufferLocal::OnContextLost(uint32_t reason) { | 328 void CommandBufferLocal::OnContextLost(uint32_t reason) { |
| 332 if (client_) | 329 if (client_) |
| 333 client_->DidLoseContext(); | 330 client_->DidLoseContext(); |
| 334 } | 331 } |
| 335 | 332 |
| 336 void CommandBufferLocal::OnSyncPointRetired() { | 333 void CommandBufferLocal::OnSyncPointRetired() { |
| 337 scheduler_->SetScheduled(true); | 334 scheduler_->SetScheduled(true); |
| 338 } | 335 } |
| 339 | 336 |
| 340 } // namespace mus | 337 } // namespace mus |
| OLD | NEW |