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" |
21 #include "ui/gfx/vsync_provider.h" | 22 #include "ui/gfx/vsync_provider.h" |
22 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
23 #include "ui/gl/gl_image_shared_memory.h" | 24 #include "ui/gl/gl_image_shared_memory.h" |
24 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
25 | 26 |
26 namespace mus { | 27 namespace mus { |
27 | 28 |
28 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; | 29 const unsigned int GL_READ_WRITE_CHROMIUM = 0x78F2; |
29 | 30 |
30 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, | 31 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 size_t height, | 133 size_t height, |
133 unsigned internalformat) { | 134 unsigned internalformat) { |
134 MojoGpuMemoryBufferImpl* gpu_memory_buffer = | 135 MojoGpuMemoryBufferImpl* gpu_memory_buffer = |
135 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); | 136 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); |
136 | 137 |
137 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); | 138 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); |
138 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( | 139 scoped_refptr<gl::GLImageSharedMemory> image(new gl::GLImageSharedMemory( |
139 gfx::Size(static_cast<int>(width), static_cast<int>(height)), | 140 gfx::Size(static_cast<int>(width), static_cast<int>(height)), |
140 internalformat)); | 141 internalformat)); |
141 if (!image->Initialize(base::SharedMemory::DuplicateHandle(handle.handle), | 142 if (!image->Initialize(base::SharedMemory::DuplicateHandle(handle.handle), |
142 handle.id, gpu_memory_buffer->GetFormat(), 0)) { | 143 handle.id, gpu_memory_buffer->GetFormat(), 0, |
| 144 gfx::RowSizeForBufferFormat( |
| 145 width, gpu_memory_buffer->GetFormat(), 0))) { |
143 return -1; | 146 return -1; |
144 } | 147 } |
145 | 148 |
146 static int32 next_id = 1; | 149 static int32 next_id = 1; |
147 int32 new_id = next_id++; | 150 int32 new_id = next_id++; |
148 | 151 |
149 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 152 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
150 DCHECK(image_manager); | 153 DCHECK(image_manager); |
151 image_manager->AddImage(image.get(), new_id); | 154 image_manager->AddImage(image.get(), new_id); |
152 return new_id; | 155 return new_id; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 void CommandBufferLocal::OnContextLost(uint32_t reason) { | 331 void CommandBufferLocal::OnContextLost(uint32_t reason) { |
329 if (client_) | 332 if (client_) |
330 client_->DidLoseContext(); | 333 client_->DidLoseContext(); |
331 } | 334 } |
332 | 335 |
333 void CommandBufferLocal::OnSyncPointRetired() { | 336 void CommandBufferLocal::OnSyncPointRetired() { |
334 scheduler_->SetScheduled(true); | 337 scheduler_->SetScheduled(true); |
335 } | 338 } |
336 | 339 |
337 } // namespace mus | 340 } // namespace mus |
OLD | NEW |