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"
10 #include <X11/Xutil.h>
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
) {
26 case SHIM_EGL_LIBRARY
:
28 case SHIM_GLES_LIBRARY
:
29 return "libGLESv2.so.2";
35 bool ShimInitialize(void) {
36 g_display
= XOpenDisplay(NULL
);
37 return g_display
!= NULL
;
40 bool ShimTerminate(void) {
41 XCloseDisplay(g_display
);
45 ShimNativeWindowId
ShimCreateWindow(void) {
46 XSetWindowAttributes swa
;
47 memset(&swa
, 0, sizeof(swa
));
50 Window window
= XCreateWindow(g_display
,
51 DefaultRootWindow(g_display
),
63 XMapWindow(g_display
, window
);
64 XStoreName(g_display
, window
, "EGL test");
70 bool ShimQueryWindow(ShimNativeWindowId window_id
, int attribute
, int* value
) {
71 XWindowAttributes window_attributes
;
73 case SHIM_WINDOW_WIDTH
:
74 XGetWindowAttributes(g_display
, window_id
, &window_attributes
);
75 *value
= window_attributes
.width
;
77 case SHIM_WINDOW_HEIGHT
:
78 XGetWindowAttributes(g_display
, window_id
, &window_attributes
);
79 *value
= window_attributes
.height
;
86 bool ShimDestroyWindow(ShimNativeWindowId window_id
) {
87 XDestroyWindow(g_display
, window_id
);
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
) {