Move VISUAL_STATE promise to activation
[chromium-blink-merge.git] / ui / ozone / platform / egltest / eglplatform_shim_xeleven.cc
blobc7e008086192c6931d3bbc8352aff15ae53f7f70
1 // Copyright 2014 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.
5 #include "ui/ozone/platform/egltest/eglplatform_shim.h"
7 #include <string.h>
8 #include <X11/Xlib.h>
9 #include <X11/Xatom.h>
10 #include <X11/Xutil.h>
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
16 Display* g_display;
18 const int kDefaultX = 0;
19 const int kDefaultY = 0;
20 const int kDefaultWidth = 1280;
21 const int kDefaultHeight = 720;
22 const int kDefaultBorderWidth = 0;
24 const char* ShimQueryString(int name) {
25 switch (name) {
26 case SHIM_EGL_LIBRARY:
27 return "libEGL.so.1";
28 case SHIM_GLES_LIBRARY:
29 return "libGLESv2.so.2";
30 default:
31 return NULL;
35 bool ShimInitialize(void) {
36 g_display = XOpenDisplay(NULL);
37 return g_display != NULL;
40 bool ShimTerminate(void) {
41 XCloseDisplay(g_display);
42 return true;
45 ShimNativeWindowId ShimCreateWindow(void) {
46 XSetWindowAttributes swa;
47 memset(&swa, 0, sizeof(swa));
48 swa.event_mask = 0;
50 Window window = XCreateWindow(g_display,
51 DefaultRootWindow(g_display),
52 kDefaultX,
53 kDefaultY,
54 kDefaultWidth,
55 kDefaultHeight,
56 kDefaultBorderWidth,
57 CopyFromParent,
58 InputOutput,
59 CopyFromParent,
60 CWEventMask,
61 &swa);
63 XMapWindow(g_display, window);
64 XStoreName(g_display, window, "EGL test");
65 XFlush(g_display);
67 return window;
70 bool ShimQueryWindow(ShimNativeWindowId window_id, int attribute, int* value) {
71 XWindowAttributes window_attributes;
72 switch (attribute) {
73 case SHIM_WINDOW_WIDTH:
74 XGetWindowAttributes(g_display, window_id, &window_attributes);
75 *value = window_attributes.width;
76 return true;
77 case SHIM_WINDOW_HEIGHT:
78 XGetWindowAttributes(g_display, window_id, &window_attributes);
79 *value = window_attributes.height;
80 return true;
81 default:
82 return false;
86 bool ShimDestroyWindow(ShimNativeWindowId window_id) {
87 XDestroyWindow(g_display, window_id);
88 return true;
91 ShimEGLNativeDisplayType ShimGetNativeDisplay(void) {
92 return reinterpret_cast<ShimEGLNativeDisplayType>(g_display);
95 ShimEGLNativeWindowType ShimGetNativeWindow(
96 ShimNativeWindowId native_window_id) {
97 return native_window_id;
100 bool ShimReleaseNativeWindow(ShimEGLNativeWindowType native_window) {
101 return true;
104 #ifdef __cplusplus
106 #endif