OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 "media/tools/shader_bench/window.h" |
| 6 |
| 7 #include <gdk/gdkx.h> |
| 8 #include <gtk/gtk.h> |
| 9 |
| 10 #include "base/utf_string_conversions.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) { |
| 15 gtk_main_quit(); |
| 16 return FALSE; |
| 17 } |
| 18 |
| 19 gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) { |
| 20 Painter* painter = reinterpret_cast<Painter*>(data); |
| 21 if (painter) painter->OnPaint(); |
| 22 return FALSE; |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 namespace media { |
| 28 |
| 29 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) { |
| 30 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 31 |
| 32 gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height); |
| 33 gtk_widget_set_double_buffered(hwnd, FALSE); |
| 34 gtk_widget_set_app_paintable(hwnd, TRUE); |
| 35 |
| 36 gtk_widget_show(hwnd); |
| 37 |
| 38 gtk_signal_connect(GTK_OBJECT(GTK_WINDOW(hwnd)), |
| 39 "delete_event", |
| 40 reinterpret_cast<GtkSignalFunc>(::OnDelete), |
| 41 NULL); |
| 42 |
| 43 return GTK_WINDOW(hwnd); |
| 44 } |
| 45 |
| 46 void Window::SetPainter(Painter* painter) { |
| 47 painter_ = painter; |
| 48 gtk_signal_connect(GTK_OBJECT(GTK_WINDOW(window_handle_)), |
| 49 "expose_event", |
| 50 reinterpret_cast<GtkSignalFunc>(::OnExpose), |
| 51 painter_); |
| 52 } |
| 53 |
| 54 gfx::PluginWindowHandle Window::PluginWindow() { |
| 55 return GDK_WINDOW_XWINDOW(GTK_WIDGET(window_handle_)->window); |
| 56 } |
| 57 |
| 58 void Window::Paint() { |
| 59 gint return_val; |
| 60 GdkEvent event; |
| 61 gtk_signal_emit_by_name(GTK_OBJECT(window_handle_), "expose_event", &event, &r
eturn_val); |
| 62 } |
| 63 |
| 64 } // media |
OLD | NEW |