| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <EGL/egl.h> | |
| 6 #include <EGL/eglext.h> | |
| 7 #include <gdk/gdkx.h> | |
| 8 #include <gtk/gtk.h> | |
| 9 | |
| 10 extern "C" { | |
| 11 | |
| 12 #if defined(GLES2_CONFORM_SUPPORT_ONLY) | |
| 13 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h" | |
| 14 #else | |
| 15 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h" | |
| 16 #endif | |
| 17 | |
| 18 GTFbool GTFNativeCreateDisplay(EGLNativeDisplayType *pNativeDisplay) { | |
| 19 int argc = 0; | |
| 20 char **argv = NULL; | |
| 21 gtk_init(&argc, &argv); | |
| 22 *pNativeDisplay = GDK_DISPLAY();; | |
| 23 return *pNativeDisplay ? GTFtrue : GTFfalse; | |
| 24 } | |
| 25 | |
| 26 void GTFNativeDestroyDisplay(EGLNativeDisplayType nativeDisplay) { | |
| 27 gtk_exit(0); | |
| 28 } | |
| 29 | |
| 30 void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay, | |
| 31 EGLNativeWindowType nativeWindow) { | |
| 32 GdkWindow* window = gdk_window_lookup(nativeWindow); | |
| 33 gpointer widget = NULL; | |
| 34 gdk_window_get_user_data(window, &widget); | |
| 35 gtk_widget_destroy(GTK_WIDGET(widget)); | |
| 36 } | |
| 37 | |
| 38 GTFbool GTFNativeCreateWindow(EGLNativeDisplayType nativeDisplay, | |
| 39 EGLDisplay eglDisplay, EGLConfig eglConfig, | |
| 40 const char* title, int width, int height, | |
| 41 EGLNativeWindowType *pNativeWindow) { | |
| 42 #ifdef CHROMEOS_GLES2_CONFORMANCE | |
| 43 // Due to the behavior of ChromeOS window manager, which always resize the | |
| 44 // top level window etc, we had to create a popup window. | |
| 45 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_POPUP); | |
| 46 #else | |
| 47 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 48 #endif | |
| 49 | |
| 50 gtk_window_set_title(GTK_WINDOW(hwnd), title); | |
| 51 gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height); | |
| 52 gtk_widget_set_double_buffered(hwnd, FALSE); | |
| 53 gtk_widget_set_app_paintable(hwnd, TRUE); | |
| 54 | |
| 55 // We had to enter gtk main loop to realize the window on ChromeOS. | |
| 56 gtk_widget_show_now(hwnd); | |
| 57 | |
| 58 *pNativeWindow = GDK_WINDOW_XWINDOW(hwnd->window); | |
| 59 | |
| 60 return GTFtrue; | |
| 61 } | |
| 62 | |
| 63 } // extern "C" | |
| OLD | NEW |