1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef GPU_IPC_COMMON_SURFACE_HANDLE_H_
6 #define GPU_IPC_COMMON_SURFACE_HANDLE_H_
7 
8 #include <stdint.h>
9 
10 #include "build/build_config.h"
11 
12 #if (defined(OS_MAC) || defined(OS_WIN) || defined(USE_X11) || \
13      defined(USE_OZONE)) &&                                      \
14     !defined(OS_NACL)
15 #include "ui/gfx/native_widget_types.h"
16 #define GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW
17 #endif
18 
19 namespace gpu {
20 
21 // SurfaceHandle is the native type used to reference a native surface in the
22 // GPU process so that we can create "view" contexts on it.
23 
24 // On Windows, Mac, Linux and Chrome OS, we can use a AcceleratedWidget across
25 // processes, so SurfaceHandle is exactly that.
26 // On Android, there is no type we can directly access across processes, so we
27 // go through the GpuSurfaceTracker, and SurfaceHandle is a (scalar) handle
28 // generated by that.
29 // On NaCl, we don't have native surfaces per se, but we need SurfaceHandle to
30 // be defined, because some APIs that use it are referenced there.
31 //
32 // TODO(fuchsia): Figure out the right approach for Fuchsia.
33 #if defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
34 using SurfaceHandle = gfx::AcceleratedWidget;
35 constexpr SurfaceHandle kNullSurfaceHandle = gfx::kNullAcceleratedWidget;
36 #elif defined(OS_ANDROID) || defined(OS_NACL) || defined(OS_FUCHSIA)
37 using SurfaceHandle = int32_t;
38 constexpr SurfaceHandle kNullSurfaceHandle = 0;
39 #else
40 #error Platform not supported.
41 #endif
42 
43 }  // namespace gpu
44 
45 #endif  // GPU_IPC_COMMON_SURFACE_HANDLE_H_
46