=== modified file 'src/composite-test-simple-blur.cc'
@@ -299,22 +299,29 @@
// Private structure used to avoid contaminating composite-test.h with all of
// the CompositeTestSimpleBlur internal classes.
//
+typedef map<unsigned int, RenderWindowBlur*> BlurWindowMapType;
struct BlurPrivate
{
RenderScreen screen;
RenderClearImage desktop;
- map<unsigned int, RenderWindowBlur*> windowMap;
+ BlurWindowMapType windowMap;
int screen_width;
int screen_height;
double lastUpdateTime;
float window_scale_factor;
+ unsigned int passes;
+ unsigned int radius;
+ bool separable;
BlurPrivate() :
desktop(GLCOMPBENCH_DATA_PATH"/background.png"),
screen_width(0),
screen_height(0),
lastUpdateTime(0),
- window_scale_factor(0.4) {}
+ window_scale_factor(0),
+ passes(0),
+ radius(0),
+ separable(false) {}
~BlurPrivate() {}
};
@@ -339,7 +346,7 @@
CompositeTestSimpleBlur::~CompositeTestSimpleBlur()
{
- for (map<unsigned int, RenderWindowBlur*>::iterator winIt = priv_->windowMap.begin();
+ for (BlurWindowMapType::iterator winIt = priv_->windowMap.begin();
winIt != priv_->windowMap.end();
winIt++)
{
@@ -372,9 +379,9 @@
{
// See how our options tell us to behave...
priv_->window_scale_factor = Util::fromString<float>(options_["window-size"].value);
- unsigned int passes(Util::fromString<unsigned int>(options_["passes"].value));
- unsigned int radius(Util::fromString<unsigned int>(options_["blur-radius"].value));
- bool separable(options_["separable"].value == "true");
+ priv_->passes = Util::fromString<unsigned int>(options_["passes"].value);
+ priv_->radius = Util::fromString<unsigned int>(options_["blur-radius"].value);
+ priv_->separable = (options_["separable"].value == "true");
// Ensure we get a transparent clear color for all following operations
glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -401,7 +408,7 @@
window_size *= priv_->window_scale_factor;
clamp_size(window_size);
vec2 corner_offset(window_size / 2.0);
- RenderWindowBlur* ro = new RenderWindowBlur(passes, radius, separable);
+ RenderWindowBlur* ro = new RenderWindowBlur(priv_->passes, priv_->radius, priv_->separable);
ro->init(program_);
ro->set_background(win->get_texture().i);
vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
@@ -448,21 +455,34 @@
{
continue;
}
+ vec2 window_size(cw->width(), cw->height());
+ window_size *= priv_->window_scale_factor;
+ clamp_size(window_size);
+ vec2 corner_offset(window_size / 2.0);
+ vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
+ screen_size.y() * (0.5 + 0.25 * sin(i * angular_step)));
unsigned int winHandle(cw->get_xwindow());
- map<unsigned int, RenderWindowBlur*>::iterator roIt = priv_->windowMap.find(winHandle);
+ BlurWindowMapType::iterator roIt = priv_->windowMap.find(winHandle);
if (roIt == priv_->windowMap.end())
{
- Log::debug("Failed to find window 0x%x in window map\n", winHandle);
- continue;
+ // This window either wasn't present during prepare_for_run, or
+ // when the last draw was triggered, so we'll add a render object
+ // for it to the map.
+ RenderWindowBlur* ro = new RenderWindowBlur(priv_->passes, priv_->radius, priv_->separable);
+ ro->init(program_);
+ pair<BlurWindowMapType::iterator, bool> retState =
+ priv_->windowMap.insert(make_pair(cw->get_xwindow(), ro));
+ if (!retState.second)
+ {
+ // Map insertion failed. This shouldn't happen, but we need to
+ // check anyway.
+ Log::error("Failed to insert new render object into window map\n");
+ continue;
+ }
+ roIt = retState.first;
}
RenderWindowBlur* ro = roIt->second;
ro->refresh_window(cw->get_texture().i);
- vec2 window_size(cw->width(), cw->height());
- window_size *= priv_->window_scale_factor;
- clamp_size(window_size);
- vec2 corner_offset(window_size / 2.0);
- vec2 center(screen_size.x() * (0.5 + 0.25 * cos(i * angular_step)),
- screen_size.y() * (0.5 + 0.25 * sin(i * angular_step)));
ro->position(center - corner_offset);
ro->resize(window_size);
ro->render_to(priv_->desktop);