+ : radius(3.0f)
+{
+ hpass = new SingleBlurPassEffect();
+ hpass->set_int("direction", SingleBlurPassEffect::HORIZONTAL);
+ vpass = new SingleBlurPassEffect();
+ vpass->set_int("direction", SingleBlurPassEffect::VERTICAL);
+
+ update_radius();
+}
+
+void BlurEffect::add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &inputs)
+{
+ assert(inputs.size() == 1);
+ hpass->add_self_to_effect_chain(chain, inputs);
+
+ std::vector<Effect *> vpass_inputs;
+ vpass_inputs.push_back(hpass);
+ vpass->add_self_to_effect_chain(chain, vpass_inputs);
+}
+
+void BlurEffect::update_radius()
+{
+ // We only have 16 taps to work with on each side, and we want that to
+ // reach out to about 2.5*sigma. Bump up the mipmap levels (giving us
+ // box blurs) until we have what we need.
+ //
+ // TODO: Consider the actual width and height (they influence mipmap
+ // sizes subtly).
+ unsigned base_mipmap_level = 0;
+ float adjusted_radius = radius;
+ while (adjusted_radius * 1.5f > NUM_TAPS / 2) {
+ ++base_mipmap_level;
+ adjusted_radius /= 2.0f;
+ }
+
+ bool ok = hpass->set_float("radius", adjusted_radius);
+ ok |= hpass->set_int("width", 1280 / (1 << base_mipmap_level)); // FIXME
+ ok |= hpass->set_int("height", 720 / (1 << base_mipmap_level)); // FIXME
+
+ ok |= vpass->set_float("radius", adjusted_radius);
+ ok |= vpass->set_int("width", 1280 / (1 << base_mipmap_level)); // FIXME
+ ok |= vpass->set_int("height", 720 / (1 << base_mipmap_level)); // FIXME
+
+ assert(ok);
+}
+
+bool BlurEffect::set_float(const std::string &key, float value) {
+ if (key == "radius") {
+ radius = value;
+ update_radius();
+ return true;
+ }
+ return false;
+}
+
+SingleBlurPassEffect::SingleBlurPassEffect()