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