Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: components/mus/gles2/command_buffer_driver.cc

Issue 1995753002: [mojo-edk] Expose portable API for platform handle wrapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/leveldb/leveldb_mojo_proxy.cc ('k') | components/mus/gles2/command_buffer_local.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "components/mus/gles2/gl_surface_adapter.h" 14 #include "components/mus/gles2/gl_surface_adapter.h"
15 #include "components/mus/gles2/gpu_memory_tracker.h" 15 #include "components/mus/gles2/gpu_memory_tracker.h"
16 #include "components/mus/gles2/gpu_state.h" 16 #include "components/mus/gles2/gpu_state.h"
17 #include "components/mus/gles2/mojo_buffer_backing.h" 17 #include "components/mus/gles2/mojo_buffer_backing.h"
18 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" 18 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
19 #include "gpu/command_buffer/service/command_buffer_service.h" 19 #include "gpu/command_buffer/service/command_buffer_service.h"
20 #include "gpu/command_buffer/service/command_executor.h" 20 #include "gpu/command_buffer/service/command_executor.h"
21 #include "gpu/command_buffer/service/context_group.h" 21 #include "gpu/command_buffer/service/context_group.h"
22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
23 #include "gpu/command_buffer/service/image_manager.h" 23 #include "gpu/command_buffer/service/image_manager.h"
24 #include "gpu/command_buffer/service/mailbox_manager.h" 24 #include "gpu/command_buffer/service/mailbox_manager.h"
25 #include "gpu/command_buffer/service/query_manager.h" 25 #include "gpu/command_buffer/service/query_manager.h"
26 #include "gpu/command_buffer/service/sync_point_manager.h" 26 #include "gpu/command_buffer/service/sync_point_manager.h"
27 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 27 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
28 #include "mojo/converters/geometry/geometry_type_converters.h" 28 #include "mojo/converters/geometry/geometry_type_converters.h"
29 #include "mojo/platform_handle/platform_handle_functions.h" 29 #include "mojo/public/cpp/system/platform_handle.h"
30 #include "ui/gfx/buffer_format_util.h" 30 #include "ui/gfx/buffer_format_util.h"
31 #include "ui/gfx/gpu_memory_buffer.h" 31 #include "ui/gfx/gpu_memory_buffer.h"
32 #include "ui/gfx/vsync_provider.h" 32 #include "ui/gfx/vsync_provider.h"
33 #include "ui/gl/gl_context.h" 33 #include "ui/gl/gl_context.h"
34 #include "ui/gl/gl_image_shared_memory.h" 34 #include "ui/gl/gl_image_shared_memory.h"
35 #include "ui/gl/gl_surface.h" 35 #include "ui/gl/gl_surface.h"
36 #include "ui/gl/init/gl_factory.h" 36 #include "ui/gl/init/gl_factory.h"
37 37
38 #if defined(USE_OZONE) 38 #if defined(USE_OZONE)
39 #include "ui/gl/gl_image_ozone_native_pixmap.h" 39 #include "ui/gl/gl_image_ozone_native_pixmap.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 gpu_format)) { 248 gpu_format)) {
249 LOG(ERROR) << "Incompatible image format."; 249 LOG(ERROR) << "Incompatible image format.";
250 return; 250 return;
251 } 251 }
252 252
253 if (type != gfx::SHARED_MEMORY_BUFFER) { 253 if (type != gfx::SHARED_MEMORY_BUFFER) {
254 NOTIMPLEMENTED(); 254 NOTIMPLEMENTED();
255 return; 255 return;
256 } 256 }
257 257
258 MojoPlatformHandle platform_handle; 258 base::PlatformFile platform_file;
259 MojoResult extract_result = MojoExtractPlatformHandle( 259 MojoResult unwrap_result = mojo::UnwrapPlatformFile(std::move(memory_handle),
260 memory_handle.release().value(), &platform_handle); 260 &platform_file);
261 if (extract_result != MOJO_RESULT_OK) { 261 if (unwrap_result != MOJO_RESULT_OK) {
262 NOTREACHED(); 262 NOTREACHED();
263 return; 263 return;
264 } 264 }
265 265
266 #if defined(OS_WIN) 266 #if defined(OS_WIN)
267 base::SharedMemoryHandle handle(platform_handle, base::GetCurrentProcId()); 267 base::SharedMemoryHandle handle(platform_file, base::GetCurrentProcId());
268 #else 268 #else
269 base::FileDescriptor handle(platform_handle, false); 269 base::FileDescriptor handle(platform_file, false);
270 #endif 270 #endif
271 271
272 scoped_refptr<gl::GLImageSharedMemory> image = 272 scoped_refptr<gl::GLImageSharedMemory> image =
273 new gl::GLImageSharedMemory(gfx_size, internal_format); 273 new gl::GLImageSharedMemory(gfx_size, internal_format);
274 // TODO(jam): also need a mojo enum for this enum 274 // TODO(jam): also need a mojo enum for this enum
275 if (!image->Initialize( 275 if (!image->Initialize(
276 handle, gfx::GpuMemoryBufferId(id), gpu_format, 0, 276 handle, gfx::GpuMemoryBufferId(id), gpu_format, 0,
277 gfx::RowSizeForBufferFormat(gfx_size.width(), gpu_format, 0))) { 277 gfx::RowSizeForBufferFormat(gfx_size.width(), gpu_format, 0))) {
278 NOTREACHED(); 278 NOTREACHED();
279 return; 279 return;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { 543 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {
544 DCHECK(CalledOnValidThread()); 544 DCHECK(CalledOnValidThread());
545 if (client_) { 545 if (client_) {
546 client_->OnGpuCompletedSwapBuffers(result); 546 client_->OnGpuCompletedSwapBuffers(result);
547 } 547 }
548 } 548 }
549 549
550 } // namespace mus 550 } // namespace mus
OLDNEW
« no previous file with comments | « components/leveldb/leveldb_mojo_proxy.cc ('k') | components/mus/gles2/command_buffer_local.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698