| 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/gl_surface_adapter.h" |
| 15 #include "components/mus/gles2/gpu_memory_tracker.h" | 15 #include "components/mus/gles2/gpu_memory_tracker.h" |
| 16 #include "components/mus/gles2/gpu_state.h" | 16 #include "components/mus/gles2/gpu_state.h" |
| 17 #include "components/mus/gles2/mojo_buffer_backing.h" | 17 #include "components/mus/gles2/mojo_buffer_backing.h" |
| 18 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| 18 #include "gpu/command_buffer/service/command_buffer_service.h" | 19 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 19 #include "gpu/command_buffer/service/command_executor.h" | 20 #include "gpu/command_buffer/service/command_executor.h" |
| 20 #include "gpu/command_buffer/service/context_group.h" | 21 #include "gpu/command_buffer/service/context_group.h" |
| 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 22 #include "gpu/command_buffer/service/image_factory.h" | |
| 23 #include "gpu/command_buffer/service/image_manager.h" | 23 #include "gpu/command_buffer/service/image_manager.h" |
| 24 #include "gpu/command_buffer/service/mailbox_manager.h" | 24 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 25 #include "gpu/command_buffer/service/query_manager.h" | 25 #include "gpu/command_buffer/service/query_manager.h" |
| 26 #include "gpu/command_buffer/service/sync_point_manager.h" | 26 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 28 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 28 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 29 #include "mojo/converters/geometry/geometry_type_converters.h" | 29 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 30 #include "mojo/platform_handle/platform_handle_functions.h" | 30 #include "mojo/platform_handle/platform_handle_functions.h" |
| 31 #include "ui/gfx/buffer_format_util.h" | 31 #include "ui/gfx/buffer_format_util.h" |
| 32 #include "ui/gfx/gpu_memory_buffer.h" | 32 #include "ui/gfx/gpu_memory_buffer.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (!MakeCurrent()) | 215 if (!MakeCurrent()) |
| 216 return; | 216 return; |
| 217 | 217 |
| 218 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 218 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| 219 if (image_manager->LookupImage(id)) { | 219 if (image_manager->LookupImage(id)) { |
| 220 LOG(ERROR) << "Image already exists with same ID."; | 220 LOG(ERROR) << "Image already exists with same ID."; |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 | 223 |
| 224 gfx::BufferFormat gpu_format = static_cast<gfx::BufferFormat>(format); | 224 gfx::BufferFormat gpu_format = static_cast<gfx::BufferFormat>(format); |
| 225 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( | 225 if (!gpu::IsGpuMemoryBufferFormatSupported(gpu_format, |
| 226 gpu_format, decoder_->GetCapabilities())) { | 226 decoder_->GetCapabilities())) { |
| 227 LOG(ERROR) << "Format is not supported."; | 227 LOG(ERROR) << "Format is not supported."; |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 gfx::Size gfx_size = size.To<gfx::Size>(); | 231 gfx::Size gfx_size = size.To<gfx::Size>(); |
| 232 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( | 232 if (!gpu::IsImageSizeValidForGpuMemoryBufferFormat(gfx_size, gpu_format)) { |
| 233 gfx_size, gpu_format)) { | |
| 234 LOG(ERROR) << "Invalid image size for format."; | 233 LOG(ERROR) << "Invalid image size for format."; |
| 235 return; | 234 return; |
| 236 } | 235 } |
| 237 | 236 |
| 238 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 237 if (!gpu::IsImageFormatCompatibleWithGpuMemoryBufferFormat(internal_format, |
| 239 internal_format, gpu_format)) { | 238 gpu_format)) { |
| 240 LOG(ERROR) << "Incompatible image format."; | 239 LOG(ERROR) << "Incompatible image format."; |
| 241 return; | 240 return; |
| 242 } | 241 } |
| 243 | 242 |
| 244 if (type != gfx::SHARED_MEMORY_BUFFER) { | 243 if (type != gfx::SHARED_MEMORY_BUFFER) { |
| 245 NOTIMPLEMENTED(); | 244 NOTIMPLEMENTED(); |
| 246 return; | 245 return; |
| 247 } | 246 } |
| 248 | 247 |
| 249 MojoPlatformHandle platform_handle; | 248 MojoPlatformHandle platform_handle; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 504 } |
| 506 | 505 |
| 507 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { | 506 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { |
| 508 DCHECK(CalledOnValidThread()); | 507 DCHECK(CalledOnValidThread()); |
| 509 if (client_) { | 508 if (client_) { |
| 510 client_->OnGpuCompletedSwapBuffers(result); | 509 client_->OnGpuCompletedSwapBuffers(result); |
| 511 } | 510 } |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace mus | 513 } // namespace mus |
| OLD | NEW |