| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/ipc/client/gpu_channel_host.h" | 5 #include "gpu/ipc/client/gpu_channel_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 void GpuChannelHost::RemoveRoute(int route_id) { | 214 void GpuChannelHost::RemoveRoute(int route_id) { |
| 215 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 215 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
| 216 factory_->GetIOThreadTaskRunner(); | 216 factory_->GetIOThreadTaskRunner(); |
| 217 io_task_runner->PostTask( | 217 io_task_runner->PostTask( |
| 218 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, | 218 FROM_HERE, base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, |
| 219 channel_filter_, route_id)); | 219 channel_filter_, route_id)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess( | 222 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess( |
| 223 base::SharedMemoryHandle source_handle) { | 223 const base::SharedMemoryHandle& source_handle) { |
| 224 if (IsLost()) | 224 if (IsLost()) |
| 225 return base::SharedMemory::NULLHandle(); | 225 return base::SharedMemory::NULLHandle(); |
| 226 | 226 |
| 227 return base::SharedMemory::DuplicateHandle(source_handle); | 227 return base::SharedMemory::DuplicateHandle(source_handle); |
| 228 } | 228 } |
| 229 | 229 |
| 230 int32_t GpuChannelHost::ReserveTransferBufferId() { | 230 int32_t GpuChannelHost::ReserveTransferBufferId() { |
| 231 // 0 is a reserved value. | 231 // 0 is a reserved value. |
| 232 return g_next_transfer_buffer_id.GetNext() + 1; | 232 return g_next_transfer_buffer_id.GetNext() + 1; |
| 233 } | 233 } |
| 234 | 234 |
| 235 gfx::GpuMemoryBufferHandle GpuChannelHost::ShareGpuMemoryBufferToGpuProcess( | |
| 236 const gfx::GpuMemoryBufferHandle& source_handle, | |
| 237 bool* requires_sync_point) { | |
| 238 switch (source_handle.type) { | |
| 239 case gfx::SHARED_MEMORY_BUFFER: { | |
| 240 gfx::GpuMemoryBufferHandle handle; | |
| 241 handle.type = gfx::SHARED_MEMORY_BUFFER; | |
| 242 handle.handle = ShareToGpuProcess(source_handle.handle); | |
| 243 handle.offset = source_handle.offset; | |
| 244 handle.stride = source_handle.stride; | |
| 245 *requires_sync_point = false; | |
| 246 return handle; | |
| 247 } | |
| 248 #if defined(USE_OZONE) | |
| 249 case gfx::OZONE_NATIVE_PIXMAP: { | |
| 250 std::vector<base::ScopedFD> scoped_fds; | |
| 251 for (auto& fd : source_handle.native_pixmap_handle.fds) { | |
| 252 base::ScopedFD scoped_fd(HANDLE_EINTR(dup(fd.fd))); | |
| 253 if (!scoped_fd.is_valid()) { | |
| 254 PLOG(ERROR) << "dup"; | |
| 255 return gfx::GpuMemoryBufferHandle(); | |
| 256 } | |
| 257 scoped_fds.emplace_back(std::move(scoped_fd)); | |
| 258 } | |
| 259 gfx::GpuMemoryBufferHandle handle; | |
| 260 handle.type = gfx::OZONE_NATIVE_PIXMAP; | |
| 261 handle.id = source_handle.id; | |
| 262 for (auto& scoped_fd : scoped_fds) { | |
| 263 handle.native_pixmap_handle.fds.emplace_back(scoped_fd.release(), | |
| 264 true /* auto_close */); | |
| 265 } | |
| 266 handle.native_pixmap_handle.planes = | |
| 267 source_handle.native_pixmap_handle.planes; | |
| 268 *requires_sync_point = false; | |
| 269 return handle; | |
| 270 } | |
| 271 #endif | |
| 272 case gfx::IO_SURFACE_BUFFER: | |
| 273 *requires_sync_point = true; | |
| 274 return source_handle; | |
| 275 default: | |
| 276 NOTREACHED(); | |
| 277 return gfx::GpuMemoryBufferHandle(); | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 int32_t GpuChannelHost::ReserveImageId() { | 235 int32_t GpuChannelHost::ReserveImageId() { |
| 282 return next_image_id_.GetNext(); | 236 return next_image_id_.GetNext(); |
| 283 } | 237 } |
| 284 | 238 |
| 285 int32_t GpuChannelHost::GenerateRouteID() { | 239 int32_t GpuChannelHost::GenerateRouteID() { |
| 286 return next_route_id_.GetNext(); | 240 return next_route_id_.GetNext(); |
| 287 } | 241 } |
| 288 | 242 |
| 289 int32_t GpuChannelHost::GenerateStreamID() { | 243 int32_t GpuChannelHost::GenerateStreamID() { |
| 290 const int32_t stream_id = next_stream_id_.GetNext(); | 244 const int32_t stream_id = next_stream_id_.GetNext(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 376 |
| 423 listeners_.clear(); | 377 listeners_.clear(); |
| 424 } | 378 } |
| 425 | 379 |
| 426 bool GpuChannelHost::MessageFilter::IsLost() const { | 380 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 427 AutoLock lock(lock_); | 381 AutoLock lock(lock_); |
| 428 return lost_; | 382 return lost_; |
| 429 } | 383 } |
| 430 | 384 |
| 431 } // namespace gpu | 385 } // namespace gpu |
| OLD | NEW |