blob: e3ae0cbf9e6d7698d15b14d2b7189278b84c2237 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
extern "C" {
#include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
#include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h"
GTFbool GTFNativeCreateDisplay(EGLNativeDisplayType *pNativeDisplay) {
int argc = 0;
char **argv = NULL;
gtk_init(&argc, &argv);
*pNativeDisplay = GDK_DISPLAY();;
return *pNativeDisplay ? GTFtrue : GTFfalse;
void GTFNativeDestroyDisplay(EGLNativeDisplayType nativeDisplay) {
void GTFNativeDestroyWindow(EGLNativeDisplayType nativeDisplay,
EGLNativeWindowType nativeWindow) {
GdkWindow* window = gdk_window_lookup(nativeWindow);
gpointer widget = NULL;
gdk_window_get_user_data(window, &widget);
GTFbool GTFNativeCreateWindow(EGLNativeDisplayType nativeDisplay,
EGLDisplay eglDisplay, EGLConfig eglConfig,
const char* title, int width, int height,
EGLNativeWindowType *pNativeWindow) {
// Due to the behavior of ChromeOS window manager, which always resize the
// top level window etc, we had to create a popup window.
GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_POPUP);
GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(hwnd), title);
gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
gtk_widget_set_double_buffered(hwnd, FALSE);
gtk_widget_set_app_paintable(hwnd, TRUE);
// We had to enter gtk main loop to realize the window on ChromeOS.
*pNativeWindow = GDK_WINDOW_XWINDOW(hwnd->window);
return GTFtrue;
} // extern "C"