X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=blur_effect.cpp;h=9397ca423d429853a9a21c470217447ec688f2a3;hp=a74cd41b0cd63bca7d37150d07ecfbee822ce563;hb=28f1e12c8aeddc47bfced50e33a94c75b501a0df;hpb=37f56fcbe571b2322243f6de59494bf9e0cbb37a diff --git a/blur_effect.cpp b/blur_effect.cpp index a74cd41..9397ca4 100644 --- a/blur_effect.cpp +++ b/blur_effect.cpp @@ -5,10 +5,15 @@ #include "blur_effect.h" #include "effect_chain.h" +#include "effect_util.h" #include "util.h" // Must match blur_effect.frag. #define NUM_TAPS 16 + +using namespace std; + +namespace movit { BlurEffect::BlurEffect() : radius(3.0f), @@ -55,8 +60,8 @@ void BlurEffect::update_radius() float adjusted_radius = radius; while ((mipmap_width > 1 || mipmap_height > 1) && adjusted_radius * 1.5f > NUM_TAPS / 2) { // Find the next mipmap size (round down, minimum 1 pixel). - mipmap_width = std::max(mipmap_width / 2, 1u); - mipmap_height = std::max(mipmap_height / 2, 1u); + mipmap_width = max(mipmap_width / 2, 1u); + mipmap_height = max(mipmap_height / 2, 1u); // Approximate when mipmap sizes are odd, but good enough. adjusted_radius = radius * float(mipmap_width) / float(input_width); @@ -77,7 +82,7 @@ void BlurEffect::update_radius() assert(ok); } -bool BlurEffect::set_float(const std::string &key, float value) { +bool BlurEffect::set_float(const string &key, float value) { if (key == "radius") { radius = value; update_radius(); @@ -101,12 +106,12 @@ SingleBlurPassEffect::SingleBlurPassEffect(BlurEffect *parent) register_int("virtual_height", &virtual_height); } -std::string SingleBlurPassEffect::output_fragment_shader() +string SingleBlurPassEffect::output_fragment_shader() { return read_file("blur_effect.frag"); } -void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); @@ -193,3 +198,5 @@ void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const std::stri void SingleBlurPassEffect::clear_gl_state() { } + +} // namespace movit