Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: media/tools/shader_bench/window_linux.cc

Issue 4873002: Benchmark tool for GPU-accelerated video rendering (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes based on code review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 namespace {
11
12 gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) {
13 gtk_main_quit();
14 return FALSE;
15 }
16
17 gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) {
18 media::Window* window = reinterpret_cast<media::Window*>(data);
19 if (window) window->OnPaint();
20 return FALSE;
21 }
22
23 } // namespace
24
25 namespace media {
26
27 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) {
28 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
29
30 gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
31 gtk_widget_set_double_buffered(hwnd, FALSE);
32 gtk_widget_set_app_paintable(hwnd, TRUE);
33 gtk_widget_show(hwnd);
34
35 return GTK_WINDOW(hwnd);
36 }
37
38 gfx::PluginWindowHandle Window::PluginWindow() {
39 return GDK_WINDOW_XWINDOW(GTK_WIDGET(window_handle_)->window);
40 }
41
42 void Window::Start(int limit, Task* done_task, Painter* painter) {
43 running_ = true;
44 count_ = 0;
45 limit_ = limit;
46 done_task_ = done_task;
47 painter_ = painter;
48
49 gtk_signal_connect(GTK_OBJECT(window_handle_),
50 "delete_event",
51 reinterpret_cast<GtkSignalFunc>(::OnDelete),
52 NULL);
53
54 gtk_signal_connect(GTK_OBJECT(window_handle_),
55 "expose_event",
56 reinterpret_cast<GtkSignalFunc>(::OnExpose),
57 this);
58
59 gtk_widget_queue_draw(GTK_WIDGET(window_handle_));
60 MainLoop();
61 }
62
63 void Window::OnPaint() {
64 if (!running_)
65 return;
66
67 if (count_ < limit_) {
68 painter_->OnPaint();
69 count_++;
70 gtk_widget_queue_draw(GTK_WIDGET(window_handle_));
71 } else {
72 running_ = false;
73 if (done_task_) {
74 done_task_->Run();
75 delete done_task_;
76 }
77 gtk_main_quit();
78 }
79 }
80
81 void Window::MainLoop() {
82 gtk_main();
83 }
84
85 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698