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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 internal_format, gpu_format)) { | 227 internal_format, gpu_format)) { |
228 LOG(ERROR) << "Incompatible image format."; | 228 LOG(ERROR) << "Incompatible image format."; |
229 return; | 229 return; |
230 } | 230 } |
231 | 231 |
232 if (type != gfx::SHARED_MEMORY_BUFFER) { | 232 if (type != gfx::SHARED_MEMORY_BUFFER) { |
233 NOTIMPLEMENTED(); | 233 NOTIMPLEMENTED(); |
234 return; | 234 return; |
235 } | 235 } |
236 | 236 |
237 gfx::GpuMemoryBufferHandle gfx_handle; | |
238 // TODO(jam): create mojo enum for this and converter | |
239 gfx_handle.type = static_cast<gfx::GpuMemoryBufferType>(type); | |
240 gfx_handle.id = gfx::GpuMemoryBufferId(id); | |
241 | |
242 MojoPlatformHandle platform_handle; | 237 MojoPlatformHandle platform_handle; |
243 MojoResult extract_result = MojoExtractPlatformHandle( | 238 MojoResult extract_result = MojoExtractPlatformHandle( |
244 memory_handle.release().value(), &platform_handle); | 239 memory_handle.release().value(), &platform_handle); |
245 if (extract_result != MOJO_RESULT_OK) { | 240 if (extract_result != MOJO_RESULT_OK) { |
246 NOTREACHED(); | 241 NOTREACHED(); |
247 return; | 242 return; |
248 } | 243 } |
249 | 244 |
| 245 base::SharedMemoryHandle handle; |
250 #if defined(OS_WIN) | 246 #if defined(OS_WIN) |
251 gfx_handle.handle = | 247 handle = base::SharedMemoryHandle(platform_handle, base::GetCurrentProcId()); |
252 base::SharedMemoryHandle(platform_handle, base::GetCurrentProcId()); | |
253 #else | 248 #else |
254 gfx_handle.handle = base::FileDescriptor(platform_handle, false); | 249 handle = base::FileDescriptor(platform_handle, false); |
255 #endif | 250 #endif |
256 | 251 |
257 scoped_refptr<gfx::GLImageSharedMemory> image = | 252 scoped_refptr<gfx::GLImageSharedMemory> image = |
258 new gfx::GLImageSharedMemory(gfx_size, internal_format); | 253 new gfx::GLImageSharedMemory(gfx_size, internal_format); |
259 // TODO(jam): also need a mojo enum for this enum | 254 // TODO(jam): also need a mojo enum for this enum |
260 if (!image->Initialize(gfx_handle, gpu_format)) { | 255 if (!image->Initialize(handle, gfx::GpuMemoryBufferId(id), gpu_format)) { |
261 NOTREACHED(); | 256 NOTREACHED(); |
262 return; | 257 return; |
263 } | 258 } |
264 | 259 |
265 image_manager->AddImage(image.get(), id); | 260 image_manager->AddImage(image.get(), id); |
266 } | 261 } |
267 | 262 |
268 void CommandBufferDriver::DestroyImage(int32_t id) { | 263 void CommandBufferDriver::DestroyImage(int32_t id) { |
269 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 264 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
270 if (!image_manager->LookupImage(id)) { | 265 if (!image_manager->LookupImage(id)) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 342 |
348 void CommandBufferDriver::DestroyDecoder() { | 343 void CommandBufferDriver::DestroyDecoder() { |
349 if (decoder_) { | 344 if (decoder_) { |
350 bool have_context = decoder_->MakeCurrent(); | 345 bool have_context = decoder_->MakeCurrent(); |
351 decoder_->Destroy(have_context); | 346 decoder_->Destroy(have_context); |
352 decoder_.reset(); | 347 decoder_.reset(); |
353 } | 348 } |
354 } | 349 } |
355 | 350 |
356 } // namespace mus | 351 } // namespace mus |
OLD | NEW |