Merge lp:~glcompbench-dev/glcompbench/blur-update into lp:glcompbench

Proposed by Jesse Barker
Status: Merged
Merged at revision: 80
Proposed branch: lp:~glcompbench-dev/glcompbench/blur-update
Merge into: lp:glcompbench
Diff against target: 110 lines (+36/-16)
1 file modified
src/composite-test-simple-blur.cc (+36/-16)
To merge this branch: bzr merge lp:~glcompbench-dev/glcompbench/blur-update
Reviewer Review Type Date Requested Status
Alexandros Frantzis Approve
Review via email: mp+99368@code.launchpad.net

Description of the change

Blur: Initially the test was targeted at the scripted benchmark case where we feed glcompbench a discrete list of window ids and that list never changes during execution. The changes contained here update the handling of the window list during the draw() member of the test object to add a render object for any window that was not previously part of the list. The changes are relatively small, and I believe, clean.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/composite-test-simple-blur.cc'
2--- src/composite-test-simple-blur.cc 2012-03-20 16:24:50 +0000
3+++ src/composite-test-simple-blur.cc 2012-03-26 16:44:31 +0000
4@@ -299,22 +299,29 @@
5 // Private structure used to avoid contaminating composite-test.h with all of
6 // the CompositeTestSimpleBlur internal classes.
7 //
8+typedef map<unsigned int, RenderWindowBlur*> BlurWindowMapType;
9 struct BlurPrivate
10 {
11 RenderScreen screen;
12 RenderClearImage desktop;
13- map<unsigned int, RenderWindowBlur*> windowMap;
14+ BlurWindowMapType windowMap;
15 int screen_width;
16 int screen_height;
17 double lastUpdateTime;
18 float window_scale_factor;
19+ unsigned int passes;
20+ unsigned int radius;
21+ bool separable;
22
23 BlurPrivate() :
24 desktop(GLCOMPBENCH_DATA_PATH"/background.png"),
25 screen_width(0),
26 screen_height(0),
27 lastUpdateTime(0),
28- window_scale_factor(0.4) {}
29+ window_scale_factor(0),
30+ passes(0),
31+ radius(0),
32+ separable(false) {}
33
34 ~BlurPrivate() {}
35 };
36@@ -339,7 +346,7 @@
37
38 CompositeTestSimpleBlur::~CompositeTestSimpleBlur()
39 {
40- for (map<unsigned int, RenderWindowBlur*>::iterator winIt = priv_->windowMap.begin();
41+ for (BlurWindowMapType::iterator winIt = priv_->windowMap.begin();
42 winIt != priv_->windowMap.end();
43 winIt++)
44 {
45@@ -372,9 +379,9 @@
46 {
47 // See how our options tell us to behave...
48 priv_->window_scale_factor = Util::fromString<float>(options_["window-size"].value);
49- unsigned int passes(Util::fromString<unsigned int>(options_["passes"].value));
50- unsigned int radius(Util::fromString<unsigned int>(options_["blur-radius"].value));
51- bool separable(options_["separable"].value == "true");
52+ priv_->passes = Util::fromString<unsigned int>(options_["passes"].value);
53+ priv_->radius = Util::fromString<unsigned int>(options_["blur-radius"].value);
54+ priv_->separable = (options_["separable"].value == "true");
55
56 // Ensure we get a transparent clear color for all following operations
57 glClearColor(0.0, 0.0, 0.0, 0.0);
58@@ -401,7 +408,7 @@
59 window_size *= priv_->window_scale_factor;
60 clamp_size(window_size);
61 vec2 corner_offset(window_size / 2.0);
62- RenderWindowBlur* ro = new RenderWindowBlur(passes, radius, separable);
63+ RenderWindowBlur* ro = new RenderWindowBlur(priv_->passes, priv_->radius, priv_->separable);
64 ro->init(program_);
65 ro->set_background(win->get_texture().i);
66 vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
67@@ -448,21 +455,34 @@
68 {
69 continue;
70 }
71+ vec2 window_size(cw->width(), cw->height());
72+ window_size *= priv_->window_scale_factor;
73+ clamp_size(window_size);
74+ vec2 corner_offset(window_size / 2.0);
75+ vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
76+ screen_size.y() * (0.5 + 0.25 * sin(i * angular_step)));
77 unsigned int winHandle(cw->get_xwindow());
78- map<unsigned int, RenderWindowBlur*>::iterator roIt = priv_->windowMap.find(winHandle);
79+ BlurWindowMapType::iterator roIt = priv_->windowMap.find(winHandle);
80 if (roIt == priv_->windowMap.end())
81 {
82- Log::debug("Failed to find window 0x%x in window map\n", winHandle);
83- continue;
84+ // This window either wasn't present during prepare_for_run, or
85+ // when the last draw was triggered, so we'll add a render object
86+ // for it to the map.
87+ RenderWindowBlur* ro = new RenderWindowBlur(priv_->passes, priv_->radius, priv_->separable);
88+ ro->init(program_);
89+ pair<BlurWindowMapType::iterator, bool> retState =
90+ priv_->windowMap.insert(make_pair(cw->get_xwindow(), ro));
91+ if (!retState.second)
92+ {
93+ // Map insertion failed. This shouldn't happen, but we need to
94+ // check anyway.
95+ Log::error("Failed to insert new render object into window map\n");
96+ continue;
97+ }
98+ roIt = retState.first;
99 }
100 RenderWindowBlur* ro = roIt->second;
101 ro->refresh_window(cw->get_texture().i);
102- vec2 window_size(cw->width(), cw->height());
103- window_size *= priv_->window_scale_factor;
104- clamp_size(window_size);
105- vec2 corner_offset(window_size / 2.0);
106- vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
107- screen_size.y() * (0.5 + 0.25 * sin(i * angular_step)));
108 ro->position(center - corner_offset);
109 ro->resize(window_size);
110 ro->render_to(priv_->desktop);

Subscribers

People subscribed via source and target branches

to all changes: