| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 last_state_.error = gpu::error::kLostContext; | 231 last_state_.error = gpu::error::kLostContext; |
| 232 return NULL; | 232 return NULL; |
| 233 } | 233 } |
| 234 | 234 |
| 235 *id = ++next_transfer_buffer_id_; | 235 *id = ++next_transfer_buffer_id_; |
| 236 | 236 |
| 237 command_buffer_->RegisterTransferBuffer( | 237 command_buffer_->RegisterTransferBuffer( |
| 238 *id, duped.Pass(), static_cast<uint32_t>(size)); | 238 *id, duped.Pass(), static_cast<uint32_t>(size)); |
| 239 | 239 |
| 240 scoped_ptr<gpu::BufferBacking> backing( | 240 scoped_ptr<gpu::BufferBacking> backing( |
| 241 new mus::MojoBufferBacking(handle.Pass(), memory, size)); | 241 new MojoBufferBacking(handle.Pass(), memory, size)); |
| 242 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(backing.Pass())); | 242 scoped_refptr<gpu::Buffer> buffer(new gpu::Buffer(backing.Pass())); |
| 243 return buffer; | 243 return buffer; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void CommandBufferClientImpl::DestroyTransferBuffer(int32 id) { | 246 void CommandBufferClientImpl::DestroyTransferBuffer(int32 id) { |
| 247 command_buffer_->DestroyTransferBuffer(id); | 247 command_buffer_->DestroyTransferBuffer(id); |
| 248 } | 248 } |
| 249 | 249 |
| 250 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { | 250 gpu::Capabilities CommandBufferClientImpl::GetCapabilities() { |
| 251 return capabilities_; | 251 return capabilities_; |
| 252 } | 252 } |
| 253 | 253 |
| 254 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer, | 254 int32_t CommandBufferClientImpl::CreateImage(ClientBuffer buffer, |
| 255 size_t width, | 255 size_t width, |
| 256 size_t height, | 256 size_t height, |
| 257 unsigned internalformat) { | 257 unsigned internalformat) { |
| 258 int32 new_id = ++next_image_id_; | 258 int32 new_id = ++next_image_id_; |
| 259 | 259 |
| 260 mojo::SizePtr size = mojo::Size::New(); | 260 mojo::SizePtr size = mojo::Size::New(); |
| 261 size->width = static_cast<int32_t>(width); | 261 size->width = static_cast<int32_t>(width); |
| 262 size->height = static_cast<int32_t>(height); | 262 size->height = static_cast<int32_t>(height); |
| 263 | 263 |
| 264 mus::MojoGpuMemoryBufferImpl* gpu_memory_buffer = | 264 MojoGpuMemoryBufferImpl* gpu_memory_buffer = |
| 265 mus::MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); | 265 MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); |
| 266 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); | 266 gfx::GpuMemoryBufferHandle handle = gpu_memory_buffer->GetHandle(); |
| 267 | 267 |
| 268 bool requires_sync_point = false; | 268 bool requires_sync_point = false; |
| 269 base::SharedMemoryHandle dupd_handle = | 269 base::SharedMemoryHandle dupd_handle = |
| 270 base::SharedMemory::DuplicateHandle(handle.handle); | 270 base::SharedMemory::DuplicateHandle(handle.handle); |
| 271 #if defined(OS_WIN) | 271 #if defined(OS_WIN) |
| 272 HANDLE platform_handle = dupd_handle; | 272 HANDLE platform_handle = dupd_handle; |
| 273 #else | 273 #else |
| 274 int platform_handle = dupd_handle.fd; | 274 int platform_handle = dupd_handle.fd; |
| 275 #endif | 275 #endif |
| (...skipping 29 matching lines...) Expand all Loading... |
| 305 | 305 |
| 306 void CommandBufferClientImpl::DestroyImage(int32 id) { | 306 void CommandBufferClientImpl::DestroyImage(int32 id) { |
| 307 command_buffer_->DestroyImage(id); | 307 command_buffer_->DestroyImage(id); |
| 308 } | 308 } |
| 309 | 309 |
| 310 int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage( | 310 int32_t CommandBufferClientImpl::CreateGpuMemoryBufferImage( |
| 311 size_t width, | 311 size_t width, |
| 312 size_t height, | 312 size_t height, |
| 313 unsigned internalformat, | 313 unsigned internalformat, |
| 314 unsigned usage) { | 314 unsigned usage) { |
| 315 scoped_ptr<gfx::GpuMemoryBuffer> buffer(mus::MojoGpuMemoryBufferImpl::Create( | 315 scoped_ptr<gfx::GpuMemoryBuffer> buffer(MojoGpuMemoryBufferImpl::Create( |
| 316 gfx::Size(static_cast<int>(width), static_cast<int>(height)), | 316 gfx::Size(static_cast<int>(width), static_cast<int>(height)), |
| 317 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), | 317 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), |
| 318 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | 318 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
| 319 if (!buffer) | 319 if (!buffer) |
| 320 return -1; | 320 return -1; |
| 321 | 321 |
| 322 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 322 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); |
| 323 } | 323 } |
| 324 | 324 |
| 325 uint32_t CommandBufferClientImpl::InsertSyncPoint() { | 325 uint32_t CommandBufferClientImpl::InsertSyncPoint() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 void CommandBufferClientImpl::SetLock(base::Lock* lock) { | 388 void CommandBufferClientImpl::SetLock(base::Lock* lock) { |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool CommandBufferClientImpl::IsGpuChannelLost() { | 391 bool CommandBufferClientImpl::IsGpuChannelLost() { |
| 392 // This is only possible for out-of-process command buffers. | 392 // This is only possible for out-of-process command buffers. |
| 393 return false; | 393 return false; |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace gles2 | 396 } // namespace gles2 |
| OLD | NEW |