| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 internal_format, gpu_format)) { | 223 internal_format, gpu_format)) { |
| 224 LOG(ERROR) << "Incompatible image format."; | 224 LOG(ERROR) << "Incompatible image format."; |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 | 227 |
| 228 if (type != gfx::SHARED_MEMORY_BUFFER) { | 228 if (type != gfx::SHARED_MEMORY_BUFFER) { |
| 229 NOTIMPLEMENTED(); | 229 NOTIMPLEMENTED(); |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 | 232 |
| 233 gfx::GpuMemoryBufferHandle gfx_handle; | |
| 234 // TODO(jam): create mojo enum for this and converter | |
| 235 gfx_handle.type = static_cast<gfx::GpuMemoryBufferType>(type); | |
| 236 gfx_handle.id = gfx::GpuMemoryBufferId(id); | |
| 237 | |
| 238 MojoPlatformHandle platform_handle; | 233 MojoPlatformHandle platform_handle; |
| 239 MojoResult extract_result = MojoExtractPlatformHandle( | 234 MojoResult extract_result = MojoExtractPlatformHandle( |
| 240 memory_handle.release().value(), &platform_handle); | 235 memory_handle.release().value(), &platform_handle); |
| 241 if (extract_result != MOJO_RESULT_OK) { | 236 if (extract_result != MOJO_RESULT_OK) { |
| 242 NOTREACHED(); | 237 NOTREACHED(); |
| 243 return; | 238 return; |
| 244 } | 239 } |
| 245 | 240 |
| 241 base::SharedMemoryHandle handle; |
| 246 #if defined(OS_WIN) | 242 #if defined(OS_WIN) |
| 247 gfx_handle.handle = | 243 handle = base::SharedMemoryHandle(platform_handle, base::GetCurrentProcId()); |
| 248 base::SharedMemoryHandle(platform_handle, base::GetCurrentProcId()); | |
| 249 #else | 244 #else |
| 250 gfx_handle.handle = base::FileDescriptor(platform_handle, false); | 245 handle = base::FileDescriptor(platform_handle, false); |
| 251 #endif | 246 #endif |
| 252 | 247 |
| 253 scoped_refptr<gfx::GLImageSharedMemory> image = | 248 scoped_refptr<gfx::GLImageSharedMemory> image = |
| 254 new gfx::GLImageSharedMemory(gfx_size, internal_format); | 249 new gfx::GLImageSharedMemory(gfx_size, internal_format); |
| 255 // TODO(jam): also need a mojo enum for this enum | 250 // TODO(jam): also need a mojo enum for this enum |
| 256 if (!image->Initialize(gfx_handle, gpu_format)) { | 251 if (!image->Initialize(handle, gfx::GpuMemoryBufferId(id), gpu_format)) { |
| 257 NOTREACHED(); | 252 NOTREACHED(); |
| 258 return; | 253 return; |
| 259 } | 254 } |
| 260 | 255 |
| 261 image_manager->AddImage(image.get(), id); | 256 image_manager->AddImage(image.get(), id); |
| 262 } | 257 } |
| 263 | 258 |
| 264 void CommandBufferDriver::DestroyImage(int32_t id) { | 259 void CommandBufferDriver::DestroyImage(int32_t id) { |
| 265 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 260 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| 266 if (!image_manager->LookupImage(id)) { | 261 if (!image_manager->LookupImage(id)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 299 |
| 305 void CommandBufferDriver::DestroyDecoder() { | 300 void CommandBufferDriver::DestroyDecoder() { |
| 306 if (decoder_) { | 301 if (decoder_) { |
| 307 bool have_context = decoder_->MakeCurrent(); | 302 bool have_context = decoder_->MakeCurrent(); |
| 308 decoder_->Destroy(have_context); | 303 decoder_->Destroy(have_context); |
| 309 decoder_.reset(); | 304 decoder_.reset(); |
| 310 } | 305 } |
| 311 } | 306 } |
| 312 | 307 |
| 313 } // namespace mus | 308 } // namespace mus |
| OLD | NEW |