Implemented window class on linux. Standalone demos are working on linux now.
Review URL: http://codereview.chromium.org/565041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38106 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
gpu/demos
@@ -43,17 +43,22 @@
|
|||||||
'../gpu.gyp:command_buffer_service',
|
'../gpu.gyp:command_buffer_service',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
|
'framework/main_exe.cc',
|
||||||
'framework/window.cc',
|
'framework/window.cc',
|
||||||
'framework/window.h',
|
'framework/window.h',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS=="linux"', {'sources': ['framework/window_linux.cc']}],
|
['OS=="linux"', {
|
||||||
['OS=="mac"', {'sources': ['framework/window_mac.mm']}],
|
'sources': ['framework/window_linux.cc'],
|
||||||
['OS=="win"', {'sources': ['framework/window_win.cc']}],
|
'dependencies': ['../../build/linux/system.gyp:gtk'],
|
||||||
|
}],
|
||||||
|
['OS=="mac"', {
|
||||||
|
'sources': ['framework/window_mac.mm'],
|
||||||
|
}],
|
||||||
|
['OS=="win"', {
|
||||||
|
'sources': ['framework/window_win.cc'],
|
||||||
|
}],
|
||||||
],
|
],
|
||||||
'direct_dependent_settings': {
|
|
||||||
'sources': ['framework/main_exe.cc'],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'gpu_demo_framework_pepper',
|
'target_name': 'gpu_demo_framework_pepper',
|
||||||
|
@@ -6,12 +6,20 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "gpu/demos/framework/window.h"
|
#include "gpu/demos/framework/window.h"
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#endif // OS_LINUX
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static const int kWindowWidth = 512;
|
static const int kWindowWidth = 512;
|
||||||
static const int kWindowHeight = 512;
|
static const int kWindowHeight = 512;
|
||||||
} // namespace.
|
} // namespace.
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
gtk_init(&argc, &argv);
|
||||||
|
#endif // OS_LINUX
|
||||||
|
|
||||||
// AtExitManager is used by singleton classes to delete themselves when
|
// AtExitManager is used by singleton classes to delete themselves when
|
||||||
// the program terminates.
|
// the program terminates.
|
||||||
base::AtExitManager at_exit_manager_;
|
base::AtExitManager at_exit_manager_;
|
||||||
@@ -22,3 +30,4 @@ int main(int argc, char *argv[]) {
|
|||||||
window.MainLoop();
|
window.MainLoop();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,19 +4,60 @@
|
|||||||
|
|
||||||
#include "gpu/demos/framework/window.h"
|
#include "gpu/demos/framework/window.h"
|
||||||
|
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "base/utf_string_conversions.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
using gpu::demos::Window;
|
||||||
|
|
||||||
|
gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) {
|
||||||
|
gtk_main_quit();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) {
|
||||||
|
Window* window = static_cast<Window*>(data);
|
||||||
|
window->OnPaint();
|
||||||
|
|
||||||
|
// TODO(alokp): Figure out why this is crashing. Animation will not work
|
||||||
|
// until then.
|
||||||
|
//gtk_widget_queue_draw(widget);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
namespace demos {
|
namespace demos {
|
||||||
|
|
||||||
void Window::MainLoop() {
|
void Window::MainLoop() {
|
||||||
|
gtk_signal_connect(GTK_OBJECT(window_handle_),
|
||||||
|
"delete_event",
|
||||||
|
reinterpret_cast<GtkSignalFunc>(OnDelete),
|
||||||
|
NULL);
|
||||||
|
gtk_signal_connect(GTK_OBJECT(window_handle_),
|
||||||
|
"expose_event",
|
||||||
|
reinterpret_cast<GtkSignalFunc>(OnExpose),
|
||||||
|
this);
|
||||||
|
gtk_main();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
|
gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
|
||||||
int width, int height) {
|
int width, int height) {
|
||||||
return NULL;
|
GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
|
gtk_window_set_title(GTK_WINDOW(hwnd), WideToUTF8(title).c_str());
|
||||||
|
gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
|
||||||
|
gtk_widget_set_double_buffered(hwnd, FALSE);
|
||||||
|
gtk_widget_set_app_paintable(hwnd, TRUE);
|
||||||
|
|
||||||
|
gtk_widget_show(hwnd);
|
||||||
|
return GTK_WINDOW(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
|
gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
|
||||||
return gfx::kNullPluginWindow;
|
return GDK_WINDOW_XWINDOW(GTK_WIDGET(hwnd)->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace demos
|
} // namespace demos
|
||||||
|
Reference in New Issue
Block a user