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

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: Fixed nits 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
« no previous file with comments | « media/tools/shader_bench/window.cc ('k') | media/tools/shader_bench/window_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/task.h"
8 #include "media/tools/shader_bench/painter.h"
9
10 #include <gdk/gdkx.h>
11 #include <gtk/gtk.h>
12
13 namespace {
14
15 gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) {
16 gtk_main_quit();
17 return FALSE;
18 }
19
20 gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) {
21 media::Window* window = reinterpret_cast<media::Window*>(data);
22 if (window)
23 window->OnPaint();
24 return FALSE;
25 }
26
27 } // namespace
28
29 namespace media {
30
31 gfx::NativeWindow Window::CreateNativeWindow(int width, int height) {
32 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
33
34 gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
35 gtk_widget_set_double_buffered(hwnd, FALSE);
36 gtk_widget_set_app_paintable(hwnd, TRUE);
37 gtk_widget_show(hwnd);
38
39 return GTK_WINDOW(hwnd);
40 }
41
42 gfx::PluginWindowHandle Window::PluginWindow() {
43 return GDK_WINDOW_XWINDOW(GTK_WIDGET(window_handle_)->window);
44 }
45
46 void Window::Start(int limit, Task* done_task, Painter* painter) {
47 running_ = true;
48 count_ = 0;
49 limit_ = limit;
50 done_task_ = done_task;
51 painter_ = painter;
52
53 gtk_signal_connect(GTK_OBJECT(window_handle_),
54 "delete_event",
55 reinterpret_cast<GtkSignalFunc>(::OnDelete),
56 NULL);
57
58 gtk_signal_connect(GTK_OBJECT(window_handle_),
59 "expose_event",
60 reinterpret_cast<GtkSignalFunc>(::OnExpose),
61 this);
62
63 gtk_widget_queue_draw(GTK_WIDGET(window_handle_));
64 MainLoop();
65 }
66
67 void Window::OnPaint() {
68 if (!running_)
69 return;
70
71 if (count_ < limit_) {
72 painter_->OnPaint();
73 count_++;
74 gtk_widget_queue_draw(GTK_WIDGET(window_handle_));
75 } else {
76 running_ = false;
77 if (done_task_) {
78 done_task_->Run();
79 delete done_task_;
80 }
81 gtk_main_quit();
82 }
83 }
84
85 void Window::MainLoop() {
86 gtk_main();
87 }
88
89 } // namespace media
OLDNEW
« no previous file with comments | « media/tools/shader_bench/window.cc ('k') | media/tools/shader_bench/window_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698