From: Steinar H. Gunderson Date: Thu, 23 Jan 2014 00:35:34 +0000 (+0100) Subject: Move to 'using namespace std;' in all .cpp files. X-Git-Tag: 1.0~60 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=85f9719bf3519b1f1942738d11601584f5d38725;hp=a80b859d6c8bb9ed1e7aa547d4a9972f1a041347 Move to 'using namespace std;' in all .cpp files. There's no intrinsic value to writing std:: over and over again. We keep it in the .h file, of course, in order not to pollute clients' namespaces. --- diff --git a/alpha_division_effect.cpp b/alpha_division_effect.cpp index 9f7b3b7..177a52c 100644 --- a/alpha_division_effect.cpp +++ b/alpha_division_effect.cpp @@ -1,7 +1,9 @@ #include "alpha_division_effect.h" #include "util.h" -std::string AlphaDivisionEffect::output_fragment_shader() +using namespace std; + +string AlphaDivisionEffect::output_fragment_shader() { return read_file("alpha_division_effect.frag"); } diff --git a/alpha_multiplication_effect.cpp b/alpha_multiplication_effect.cpp index dff6f15..6441485 100644 --- a/alpha_multiplication_effect.cpp +++ b/alpha_multiplication_effect.cpp @@ -1,7 +1,9 @@ #include "alpha_multiplication_effect.h" #include "util.h" -std::string AlphaMultiplicationEffect::output_fragment_shader() +using namespace std; + +string AlphaMultiplicationEffect::output_fragment_shader() { return read_file("alpha_multiplication_effect.frag"); } diff --git a/blur_effect.cpp b/blur_effect.cpp index 0ec1b1d..80aef74 100644 --- a/blur_effect.cpp +++ b/blur_effect.cpp @@ -10,6 +10,8 @@ // Must match blur_effect.frag. #define NUM_TAPS 16 + +using namespace std; BlurEffect::BlurEffect() : radius(3.0f), @@ -56,8 +58,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); @@ -78,7 +80,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(); @@ -102,12 +104,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); diff --git a/colorspace_conversion_effect.cpp b/colorspace_conversion_effect.cpp index bd4f70e..0fcea61 100644 --- a/colorspace_conversion_effect.cpp +++ b/colorspace_conversion_effect.cpp @@ -7,6 +7,7 @@ #include "util.h" using namespace Eigen; +using namespace std; // Color coordinates from Rec. 709; sRGB uses the same primaries. static const double rec709_x_R = 0.640, rec709_x_G = 0.300, rec709_x_B = 0.150; @@ -126,7 +127,7 @@ Matrix3d ColorspaceConversionEffect::get_xyz_matrix(Colorspace space) return m; } -std::string ColorspaceConversionEffect::output_fragment_shader() +string ColorspaceConversionEffect::output_fragment_shader() { // Create a matrix to convert from source space -> XYZ, // another matrix to convert from XYZ -> destination space, diff --git a/deconvolution_sharpen_effect.cpp b/deconvolution_sharpen_effect.cpp index a90e5cc..0a13dd6 100644 --- a/deconvolution_sharpen_effect.cpp +++ b/deconvolution_sharpen_effect.cpp @@ -17,6 +17,7 @@ #include "util.h" using namespace Eigen; +using namespace std; DeconvolutionSharpenEffect::DeconvolutionSharpenEffect() : R(5), @@ -37,7 +38,7 @@ DeconvolutionSharpenEffect::DeconvolutionSharpenEffect() register_float("noise", &noise); } -std::string DeconvolutionSharpenEffect::output_fragment_shader() +string DeconvolutionSharpenEffect::output_fragment_shader() { char buf[256]; sprintf(buf, "#define R %u\n", R); @@ -170,10 +171,10 @@ MatrixXf convolve(const MatrixXf &a, const MatrixXf &b) int xa_max = xr; // Now fit to the first demand. - ya_min = std::max(ya_min, 0); - ya_max = std::min(ya_max, a.rows() - 1); - xa_min = std::max(xa_min, 0); - xa_max = std::min(xa_max, a.cols() - 1); + ya_min = max(ya_min, 0); + ya_max = min(ya_max, a.rows() - 1); + xa_min = max(xa_min, 0); + xa_max = min(xa_max, a.cols() - 1); assert(ya_max >= ya_min); assert(xa_max >= xa_min); @@ -220,10 +221,10 @@ MatrixXf central_convolve(const MatrixXf &a, const MatrixXf &b) int xa_max = xr; // Now fit to the first demand. - ya_min = std::max(ya_min, 0); - ya_max = std::min(ya_max, a.rows() - 1); - xa_min = std::max(xa_min, 0); - xa_max = std::min(xa_max, a.cols() - 1); + ya_min = max(ya_min, 0); + ya_max = min(ya_max, a.rows() - 1); + xa_min = max(xa_min, 0); + xa_max = min(xa_max, a.cols() - 1); assert(ya_max >= ya_min); assert(xa_max >= xa_min); @@ -417,7 +418,7 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel() last_noise = noise; } -void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/diffusion_effect.cpp b/diffusion_effect.cpp index a202f8c..fb78bb7 100644 --- a/diffusion_effect.cpp +++ b/diffusion_effect.cpp @@ -6,6 +6,8 @@ #include "effect_chain.h" #include "util.h" +using namespace std; + DiffusionEffect::DiffusionEffect() : blur(new BlurEffect), overlay_matte(new OverlayMatteEffect) @@ -27,7 +29,7 @@ void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self) self->disabled = true; } -bool DiffusionEffect::set_float(const std::string &key, float value) { +bool DiffusionEffect::set_float(const string &key, float value) { if (key == "blurred_mix_amount") { return overlay_matte->set_float(key, value); } @@ -40,7 +42,7 @@ OverlayMatteEffect::OverlayMatteEffect() register_float("blurred_mix_amount", &blurred_mix_amount); } -std::string OverlayMatteEffect::output_fragment_shader() +string OverlayMatteEffect::output_fragment_shader() { return read_file("overlay_matte_effect.frag"); } diff --git a/dither_effect.cpp b/dither_effect.cpp index 4643d07..62355b2 100644 --- a/dither_effect.cpp +++ b/dither_effect.cpp @@ -7,6 +7,8 @@ #include "init.h" #include "util.h" +using namespace std; + namespace { // A simple LCG (linear congruental generator) random generator. @@ -39,14 +41,14 @@ DitherEffect::~DitherEffect() glDeleteTextures(1, &texnum); } -std::string DitherEffect::output_fragment_shader() +string DitherEffect::output_fragment_shader() { char buf[256]; sprintf(buf, "#define NEED_EXPLICIT_ROUND %d\n", (movit_num_wrongly_rounded > 0)); return buf + read_file("dither_effect.frag"); } -void DitherEffect::update_texture(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void DitherEffect::update_texture(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { float *dither_noise = new float[width * height]; float dither_double_amplitude = 1.0f / (1 << num_bits); @@ -54,8 +56,8 @@ void DitherEffect::update_texture(GLuint glsl_program_num, const std::string &pr // We don't need a strictly nonrepeating dither; reducing the resolution // to max 128x128 saves a lot of texture bandwidth, without causing any // noticeable harm to the dither's performance. - texture_width = std::min(width, 128); - texture_height = std::min(height, 128); + texture_width = min(width, 128); + texture_height = min(height, 128); // Using the resolution as a seed gives us a consistent dither from frame to frame. // It also gives a different dither for e.g. different aspect ratios, which _feels_ @@ -85,7 +87,7 @@ void DitherEffect::update_texture(GLuint glsl_program_num, const std::string &pr delete[] dither_noise; } -void DitherEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void DitherEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/effect.cpp b/effect.cpp index b17c0d6..9cd611f 100644 --- a/effect.cpp +++ b/effect.cpp @@ -8,7 +8,9 @@ #include "effect_util.h" #include "util.h" -bool Effect::set_int(const std::string &key, int value) +using namespace std; + +bool Effect::set_int(const string &key, int value) { if (params_int.count(key) == 0) { return false; @@ -17,7 +19,7 @@ bool Effect::set_int(const std::string &key, int value) return true; } -bool Effect::set_float(const std::string &key, float value) +bool Effect::set_float(const string &key, float value) { if (params_float.count(key) == 0) { return false; @@ -26,7 +28,7 @@ bool Effect::set_float(const std::string &key, float value) return true; } -bool Effect::set_vec2(const std::string &key, const float *values) +bool Effect::set_vec2(const string &key, const float *values) { if (params_vec2.count(key) == 0) { return false; @@ -35,7 +37,7 @@ bool Effect::set_vec2(const std::string &key, const float *values) return true; } -bool Effect::set_vec3(const std::string &key, const float *values) +bool Effect::set_vec3(const string &key, const float *values) { if (params_vec3.count(key) == 0) { return false; @@ -44,7 +46,7 @@ bool Effect::set_vec3(const std::string &key, const float *values) return true; } -bool Effect::set_vec4(const std::string &key, const float *values) +bool Effect::set_vec4(const string &key, const float *values) { if (params_vec4.count(key) == 0) { return false; @@ -53,31 +55,31 @@ bool Effect::set_vec4(const std::string &key, const float *values) return true; } -void Effect::register_int(const std::string &key, int *value) +void Effect::register_int(const string &key, int *value) { assert(params_int.count(key) == 0); params_int[key] = value; } -void Effect::register_float(const std::string &key, float *value) +void Effect::register_float(const string &key, float *value) { assert(params_float.count(key) == 0); params_float[key] = value; } -void Effect::register_vec2(const std::string &key, float *values) +void Effect::register_vec2(const string &key, float *values) { assert(params_vec2.count(key) == 0); params_vec2[key] = values; } -void Effect::register_vec3(const std::string &key, float *values) +void Effect::register_vec3(const string &key, float *values) { assert(params_vec3.count(key) == 0); params_vec3[key] = values; } -void Effect::register_vec4(const std::string &key, float *values) +void Effect::register_vec4(const string &key, float *values) { assert(params_vec4.count(key) == 0); params_vec4[key] = values; @@ -85,31 +87,31 @@ void Effect::register_vec4(const std::string &key, float *values) // Output convenience uniforms for each parameter. // These will be filled in per-frame. -std::string Effect::output_convenience_uniforms() const +string Effect::output_convenience_uniforms() const { - std::string output = ""; - for (std::map::const_iterator it = params_float.begin(); + string output = ""; + for (map::const_iterator it = params_float.begin(); it != params_float.end(); ++it) { char buf[256]; sprintf(buf, "uniform float PREFIX(%s);\n", it->first.c_str()); output.append(buf); } - for (std::map::const_iterator it = params_vec2.begin(); + for (map::const_iterator it = params_vec2.begin(); it != params_vec2.end(); ++it) { char buf[256]; sprintf(buf, "uniform vec2 PREFIX(%s);\n", it->first.c_str()); output.append(buf); } - for (std::map::const_iterator it = params_vec3.begin(); + for (map::const_iterator it = params_vec3.begin(); it != params_vec3.end(); ++it) { char buf[256]; sprintf(buf, "uniform vec3 PREFIX(%s);\n", it->first.c_str()); output.append(buf); } - for (std::map::const_iterator it = params_vec4.begin(); + for (map::const_iterator it = params_vec4.begin(); it != params_vec4.end(); ++it) { char buf[256]; @@ -119,24 +121,24 @@ std::string Effect::output_convenience_uniforms() const return output; } -void Effect::set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) +void Effect::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) { - for (std::map::const_iterator it = params_float.begin(); + for (map::const_iterator it = params_float.begin(); it != params_float.end(); ++it) { set_uniform_float(glsl_program_num, prefix, it->first, *it->second); } - for (std::map::const_iterator it = params_vec2.begin(); + for (map::const_iterator it = params_vec2.begin(); it != params_vec2.end(); ++it) { set_uniform_vec2(glsl_program_num, prefix, it->first, it->second); } - for (std::map::const_iterator it = params_vec3.begin(); + for (map::const_iterator it = params_vec3.begin(); it != params_vec3.end(); ++it) { set_uniform_vec3(glsl_program_num, prefix, it->first, it->second); } - for (std::map::const_iterator it = params_vec4.begin(); + for (map::const_iterator it = params_vec4.begin(); it != params_vec4.end(); ++it) { set_uniform_vec4(glsl_program_num, prefix, it->first, it->second); diff --git a/effect_chain.cpp b/effect_chain.cpp index cb80772..d80c4f8 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -26,6 +26,8 @@ #include "resource_pool.h" #include "util.h" +using namespace std; + EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool) : aspect_nom(aspect_nom), aspect_denom(aspect_denom), @@ -144,7 +146,7 @@ void EffectChain::insert_node_between(Node *sender, Node *middle, Node *receiver assert(middle->incoming_links.size() == middle->effect->num_inputs()); } -void EffectChain::find_all_nonlinear_inputs(Node *node, std::vector *nonlinear_inputs) +void EffectChain::find_all_nonlinear_inputs(Node *node, vector *nonlinear_inputs) { if (node->output_gamma_curve == GAMMA_LINEAR && node->effect->effect_type_id() != "GammaCompressionEffect") { @@ -160,7 +162,7 @@ void EffectChain::find_all_nonlinear_inputs(Node *node, std::vector *non } } -Effect *EffectChain::add_effect(Effect *effect, const std::vector &inputs) +Effect *EffectChain::add_effect(Effect *effect, const vector &inputs) { assert(!finalized); assert(inputs.size() == effect->num_inputs()); @@ -173,15 +175,15 @@ Effect *EffectChain::add_effect(Effect *effect, const std::vector &inp } // GLSL pre-1.30 doesn't support token pasting. Replace PREFIX(x) with _x. -std::string replace_prefix(const std::string &text, const std::string &prefix) +string replace_prefix(const string &text, const string &prefix) { - std::string output; + string output; size_t start = 0; while (start < text.size()) { size_t pos = text.find("PREFIX(", start); - if (pos == std::string::npos) { - output.append(text.substr(start, std::string::npos)); + if (pos == string::npos) { + output.append(text.substr(start, string::npos)); break; } @@ -214,44 +216,44 @@ std::string replace_prefix(const std::string &text, const std::string &prefix) } Phase *EffectChain::compile_glsl_program( - const std::vector &inputs, - const std::vector &effects) + const vector &inputs, + const vector &effects) { Phase *phase = new Phase; assert(!effects.empty()); // Deduplicate the inputs. - std::vector true_inputs = inputs; - std::sort(true_inputs.begin(), true_inputs.end()); - true_inputs.erase(std::unique(true_inputs.begin(), true_inputs.end()), true_inputs.end()); + vector true_inputs = inputs; + sort(true_inputs.begin(), true_inputs.end()); + true_inputs.erase(unique(true_inputs.begin(), true_inputs.end()), true_inputs.end()); bool input_needs_mipmaps = false; - std::string frag_shader = read_file("header.frag"); + string frag_shader = read_file("header.frag"); // Create functions for all the texture inputs that we need. for (unsigned i = 0; i < true_inputs.size(); ++i) { Node *input = true_inputs[i]; char effect_id[256]; sprintf(effect_id, "in%u", i); - phase->effect_ids.insert(std::make_pair(input, effect_id)); + phase->effect_ids.insert(make_pair(input, effect_id)); - frag_shader += std::string("uniform sampler2D tex_") + effect_id + ";\n"; - frag_shader += std::string("vec4 ") + effect_id + "(vec2 tc) {\n"; - frag_shader += "\treturn texture2D(tex_" + std::string(effect_id) + ", tc);\n"; + frag_shader += string("uniform sampler2D tex_") + effect_id + ";\n"; + frag_shader += string("vec4 ") + effect_id + "(vec2 tc) {\n"; + frag_shader += "\treturn texture2D(tex_" + string(effect_id) + ", tc);\n"; frag_shader += "}\n"; frag_shader += "\n"; } - std::vector sorted_effects = topological_sort(effects); + vector sorted_effects = topological_sort(effects); for (unsigned i = 0; i < sorted_effects.size(); ++i) { Node *node = sorted_effects[i]; char effect_id[256]; sprintf(effect_id, "eff%u", i); - phase->effect_ids.insert(std::make_pair(node, effect_id)); + phase->effect_ids.insert(make_pair(node, effect_id)); if (node->incoming_links.size() == 1) { - frag_shader += std::string("#define INPUT ") + phase->effect_ids[node->incoming_links[0]] + "\n"; + frag_shader += string("#define INPUT ") + phase->effect_ids[node->incoming_links[0]] + "\n"; } else { for (unsigned j = 0; j < node->incoming_links.size(); ++j) { char buf[256]; @@ -261,7 +263,7 @@ Phase *EffectChain::compile_glsl_program( } frag_shader += "\n"; - frag_shader += std::string("#define FUNCNAME ") + effect_id + "\n"; + frag_shader += string("#define FUNCNAME ") + effect_id + "\n"; frag_shader += replace_prefix(node->effect->output_convenience_uniforms(), effect_id); frag_shader += replace_prefix(node->effect->output_fragment_shader(), effect_id); frag_shader += "#undef PREFIX\n"; @@ -285,7 +287,7 @@ Phase *EffectChain::compile_glsl_program( CHECK(node->effect->set_int("needs_mipmaps", input_needs_mipmaps)); } } - frag_shader += std::string("#define INPUT ") + phase->effect_ids[sorted_effects.back()] + "\n"; + frag_shader += string("#define INPUT ") + phase->effect_ids[sorted_effects.back()] + "\n"; frag_shader.append(read_file("footer.frag")); phase->glsl_program_num = resource_pool->compile_glsl_program(read_file("vs.vert"), frag_shader); @@ -309,22 +311,22 @@ void EffectChain::construct_glsl_programs(Node *output) // Which effects have already been completed? // We need to keep track of it, as an effect with multiple outputs // could otherwise be calculated multiple times. - std::set completed_effects; + set completed_effects; // Effects in the current phase, as well as inputs (outputs from other phases // that we depend on). Note that since we start iterating from the end, // the effect list will be in the reverse order. - std::vector this_phase_inputs; - std::vector this_phase_effects; + vector this_phase_inputs; + vector this_phase_effects; // Effects that we have yet to calculate, but that we know should // be in the current phase. - std::stack effects_todo_this_phase; + stack effects_todo_this_phase; // Effects that we have yet to calculate, but that come from other phases. // We delay these until we have this phase done in its entirety, // at which point we pick any of them and start a new phase from that. - std::stack effects_todo_other_phases; + stack effects_todo_other_phases; effects_todo_this_phase.push(output); @@ -349,7 +351,7 @@ void EffectChain::construct_glsl_programs(Node *output) completed_effects.insert(node); // Find all the dependencies of this effect, and add them to the stack. - std::vector deps = node->incoming_links; + vector deps = node->incoming_links; assert(node->effect->num_inputs() == deps.size()); for (unsigned i = 0; i < deps.size(); ++i) { bool start_new_phase = false; @@ -424,7 +426,7 @@ void EffectChain::construct_glsl_programs(Node *output) // Finally, since the phases are found from the output but must be executed // from the input(s), reverse them, too. - std::reverse(phases.begin(), phases.end()); + reverse(phases.begin(), phases.end()); } void EffectChain::output_dot(const char *filename) @@ -443,10 +445,10 @@ void EffectChain::output_dot(const char *filename) fprintf(fp, " output [shape=box label=\"(output)\"];\n"); for (unsigned i = 0; i < nodes.size(); ++i) { // Find out which phase this event belongs to. - std::vector in_phases; + vector in_phases; for (unsigned j = 0; j < phases.size(); ++j) { const Phase* p = phases[j]; - if (std::find(p->effects.begin(), p->effects.end(), nodes[i]) != p->effects.end()) { + if (find(p->effects.begin(), p->effects.end(), nodes[i]) != p->effects.end()) { in_phases.push_back(j); } } @@ -472,13 +474,13 @@ void EffectChain::output_dot(const char *filename) char to_node_id[256]; snprintf(to_node_id, 256, "n%ld", (long)nodes[i]->outgoing_links[j]); - std::vector labels = get_labels_for_edge(nodes[i], nodes[i]->outgoing_links[j]); + vector labels = get_labels_for_edge(nodes[i], nodes[i]->outgoing_links[j]); output_dot_edge(fp, from_node_id, to_node_id, labels); } if (nodes[i]->outgoing_links.empty() && !nodes[i]->disabled) { // Output node. - std::vector labels = get_labels_for_edge(nodes[i], NULL); + vector labels = get_labels_for_edge(nodes[i], NULL); output_dot_edge(fp, from_node_id, "output", labels); } } @@ -487,9 +489,9 @@ void EffectChain::output_dot(const char *filename) fclose(fp); } -std::vector EffectChain::get_labels_for_edge(const Node *from, const Node *to) +vector EffectChain::get_labels_for_edge(const Node *from, const Node *to) { - std::vector labels; + vector labels; if (to != NULL && to->effect->needs_texture_bounce()) { labels.push_back("needs_bounce"); @@ -544,14 +546,14 @@ std::vector EffectChain::get_labels_for_edge(const Node *from, cons } void EffectChain::output_dot_edge(FILE *fp, - const std::string &from_node_id, - const std::string &to_node_id, - const std::vector &labels) + const string &from_node_id, + const string &to_node_id, + const vector &labels) { if (labels.empty()) { fprintf(fp, " %s -> %s;\n", from_node_id.c_str(), to_node_id.c_str()); } else { - std::string label = labels[0]; + string label = labels[0]; for (unsigned k = 1; k < labels.size(); ++k) { label += ", " + labels[k]; } @@ -724,10 +726,10 @@ void EffectChain::sort_all_nodes_topologically() nodes = topological_sort(nodes); } -std::vector EffectChain::topological_sort(const std::vector &nodes) +vector EffectChain::topological_sort(const vector &nodes) { - std::set nodes_left_to_visit(nodes.begin(), nodes.end()); - std::vector sorted_list; + set nodes_left_to_visit(nodes.begin(), nodes.end()); + vector sorted_list; for (unsigned i = 0; i < nodes.size(); ++i) { topological_sort_visit_node(nodes[i], &nodes_left_to_visit, &sorted_list); } @@ -735,7 +737,7 @@ std::vector EffectChain::topological_sort(const std::vector &nod return sorted_list; } -void EffectChain::topological_sort_visit_node(Node *node, std::set *nodes_left_to_visit, std::vector *sorted_list) +void EffectChain::topological_sort_visit_node(Node *node, set *nodes_left_to_visit, vector *sorted_list) { if (nodes_left_to_visit->count(node) == 0) { return; @@ -1204,7 +1206,7 @@ void EffectChain::fix_internal_gamma_by_asking_inputs(unsigned step) } // See if all inputs can give us linear gamma. If not, leave it. - std::vector nonlinear_inputs; + vector nonlinear_inputs; find_all_nonlinear_inputs(node, &nonlinear_inputs); assert(!nonlinear_inputs.empty()); @@ -1335,7 +1337,7 @@ void EffectChain::add_dither_if_needed() // multiple outputs right now). Node *EffectChain::find_output_node() { - std::vector output_nodes; + vector output_nodes; for (unsigned i = 0; i < nodes.size(); ++i) { Node *node = nodes[i]; if (node->disabled) { @@ -1459,11 +1461,11 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height check_error(); } - std::set generated_mipmaps; + set generated_mipmaps; // We choose the simplest option of having one texture per output, // since otherwise this turns into an (albeit simple) register allocation problem. - std::map output_textures; + map output_textures; for (unsigned phase = 0; phase < phases.size(); ++phase) { // Find a texture for this phase. @@ -1472,7 +1474,7 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height find_output_size(phases[phase]); GLuint tex_num = resource_pool->create_2d_texture(GL_RGBA16F_ARB, phases[phase]->output_width, phases[phase]->output_height); - output_textures.insert(std::make_pair(phases[phase], tex_num)); + output_textures.insert(make_pair(phases[phase], tex_num)); } glUseProgram(phases[phase]->glsl_program_num); @@ -1501,7 +1503,7 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); check_error(); - std::string texture_name = std::string("tex_") + phases[phase]->effect_ids[input]; + string texture_name = string("tex_") + phases[phase]->effect_ids[input]; glUniform1i(glGetUniformLocation(phases[phase]->glsl_program_num, texture_name.c_str()), sampler); check_error(); } @@ -1563,7 +1565,7 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height } } - for (std::map::const_iterator texture_it = output_textures.begin(); + for (map::const_iterator texture_it = output_textures.begin(); texture_it != output_textures.end(); ++texture_it) { resource_pool->release_2d_texture(texture_it->second); diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index c64c7b5..fed8b91 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -16,6 +16,8 @@ #include "test_util.h" #include "util.h" +using namespace std; + TEST(EffectChainTest, EmptyChain) { float data[] = { 0.0f, 0.25f, 0.3f, @@ -32,8 +34,8 @@ TEST(EffectChainTest, EmptyChain) { class IdentityEffect : public Effect { public: IdentityEffect() {} - virtual std::string effect_type_id() const { return "IdentityEffect"; } - std::string output_fragment_shader() { return read_file("identity.frag"); } + virtual string effect_type_id() const { return "IdentityEffect"; } + string output_fragment_shader() { return read_file("identity.frag"); } }; TEST(EffectChainTest, Identity) { @@ -53,8 +55,8 @@ TEST(EffectChainTest, Identity) { class BouncingIdentityEffect : public Effect { public: BouncingIdentityEffect() {} - virtual std::string effect_type_id() const { return "IdentityEffect"; } - std::string output_fragment_shader() { return read_file("identity.frag"); } + virtual string effect_type_id() const { return "IdentityEffect"; } + string output_fragment_shader() { return read_file("identity.frag"); } bool needs_texture_bounce() const { return true; } AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; } }; @@ -93,8 +95,8 @@ TEST(MirrorTest, BasicTest) { class InvertEffect : public Effect { public: InvertEffect() {} - virtual std::string effect_type_id() const { return "InvertEffect"; } - std::string output_fragment_shader() { return read_file("invert_effect.frag"); } + virtual string effect_type_id() const { return "InvertEffect"; } + string output_fragment_shader() { return read_file("invert_effect.frag"); } // A real invert would actually care about its alpha, // but in this unit test, it only complicates things. @@ -108,8 +110,8 @@ template class RewritingEffect : public Effect { public: RewritingEffect() : effect(new T()), replaced_node(NULL) {} - virtual std::string effect_type_id() const { return "RewritingEffect[" + effect->effect_type_id() + "]"; } - std::string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } + virtual string effect_type_id() const { return "RewritingEffect[" + effect->effect_type_id() + "]"; } + string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } virtual void rewrite_graph(EffectChain *graph, Node *self) { replaced_node = graph->add_node(effect); graph->replace_receiver(self, replaced_node); @@ -202,7 +204,7 @@ public: : FlatInput(format, pixel_format, type, width, height), overridden_color_space(format.color_space), overridden_gamma_curve(format.gamma_curve) {} - virtual std::string effect_type_id() const { return "UnknownColorspaceInput"; } + virtual string effect_type_id() const { return "UnknownColorspaceInput"; } void set_color_space(Colorspace colorspace) { overridden_color_space = colorspace; @@ -387,8 +389,8 @@ TEST(EffectChainTest, NoAlphaConversionsWhenPremultipliedAlphaNotNeeded) { class BlueInput : public Input { public: BlueInput() { register_int("needs_mipmaps", &needs_mipmaps); } - virtual std::string effect_type_id() const { return "IdentityEffect"; } - std::string output_fragment_shader() { return read_file("blue.frag"); } + virtual string effect_type_id() const { return "IdentityEffect"; } + string output_fragment_shader() { return read_file("blue.frag"); } virtual AlphaHandling alpha_handling() const { return OUTPUT_BLANK_ALPHA; } virtual void finalize() {} virtual bool can_output_linear_gamma() const { return true; } @@ -406,8 +408,8 @@ private: class RewritingToBlueInput : public Input { public: RewritingToBlueInput() : blue_node(NULL) { register_int("needs_mipmaps", &needs_mipmaps); } - virtual std::string effect_type_id() const { return "RewritingToBlueInput"; } - std::string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } + virtual string effect_type_id() const { return "RewritingToBlueInput"; } + string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } virtual void rewrite_graph(EffectChain *graph, Node *self) { Node *blue_node = graph->add_node(new BlueInput()); graph->replace_receiver(self, blue_node); @@ -457,8 +459,8 @@ TEST(EffectChainTest, NoAlphaConversionsWithBlankAlpha) { class BlankAlphaPreservingEffect : public Effect { public: BlankAlphaPreservingEffect() {} - virtual std::string effect_type_id() const { return "BlankAlphaPreservingEffect"; } - std::string output_fragment_shader() { return read_file("identity.frag"); } + virtual string effect_type_id() const { return "BlankAlphaPreservingEffect"; } + string output_fragment_shader() { return read_file("identity.frag"); } virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; } }; @@ -517,9 +519,9 @@ class MipmapNeedingEffect : public Effect { public: MipmapNeedingEffect() {} virtual bool needs_mipmaps() const { return true; } - virtual std::string effect_type_id() const { return "MipmapNeedingEffect"; } - std::string output_fragment_shader() { return read_file("mipmap_needing_effect.frag"); } - void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) + virtual string effect_type_id() const { return "MipmapNeedingEffect"; } + string output_fragment_shader() { return read_file("mipmap_needing_effect.frag"); } + void set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) { glActiveTexture(GL_TEXTURE0); check_error(); @@ -643,8 +645,8 @@ TEST(EffectChainTest, ResizeDownByFourThenUpByFour) { class AddEffect : public Effect { public: AddEffect() {} - virtual std::string effect_type_id() const { return "AddEffect"; } - std::string output_fragment_shader() { return read_file("add.frag"); } + virtual string effect_type_id() const { return "AddEffect"; } + string output_fragment_shader() { return read_file("add.frag"); } virtual unsigned num_inputs() const { return 2; } virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; } }; @@ -824,7 +826,7 @@ public: input_width = width; input_height = height; } - virtual std::string effect_type_id() const { return "SizeStoringEffect"; } + virtual string effect_type_id() const { return "SizeStoringEffect"; } int input_width, input_height; }; @@ -913,8 +915,8 @@ public: height(height), virtual_width(virtual_width), virtual_height(virtual_height) {} - virtual std::string effect_type_id() const { return "VirtualResizeEffect"; } - std::string output_fragment_shader() { return read_file("identity.frag"); } + virtual string effect_type_id() const { return "VirtualResizeEffect"; } + string output_fragment_shader() { return read_file("identity.frag"); } virtual bool changes_output_size() const { return true; } diff --git a/effect_util.cpp b/effect_util.cpp index e57a562..f49b477 100644 --- a/effect_util.cpp +++ b/effect_util.cpp @@ -4,13 +4,15 @@ #include #include "util.h" -GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key) +using namespace std; + +GLint get_uniform_location(GLuint glsl_program_num, const string &prefix, const string &key) { - std::string name = prefix + "_" + key; + string name = prefix + "_" + key; return glGetUniformLocation(glsl_program_num, name.c_str()); } -void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value) +void set_uniform_int(GLuint glsl_program_num, const string &prefix, const string &key, int value) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -21,7 +23,7 @@ void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const s check_error(); } -void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value) +void set_uniform_float(GLuint glsl_program_num, const string &prefix, const string &key, float value) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -32,7 +34,7 @@ void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const check_error(); } -void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values) +void set_uniform_vec2(GLuint glsl_program_num, const string &prefix, const string &key, const float *values) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -43,7 +45,7 @@ void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const check_error(); } -void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values) +void set_uniform_vec3(GLuint glsl_program_num, const string &prefix, const string &key, const float *values) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -54,7 +56,7 @@ void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const check_error(); } -void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values) +void set_uniform_vec4(GLuint glsl_program_num, const string &prefix, const string &key, const float *values) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -65,7 +67,7 @@ void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const check_error(); } -void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values) +void set_uniform_vec4_array(GLuint glsl_program_num, const string &prefix, const string &key, const float *values, size_t num_values) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { @@ -76,7 +78,7 @@ void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, check_error(); } -void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d& matrix) +void set_uniform_mat3(GLuint glsl_program_num, const string &prefix, const string &key, const Eigen::Matrix3d& matrix) { GLint location = get_uniform_location(glsl_program_num, prefix, key); if (location == -1) { diff --git a/fft_pass_effect.cpp b/fft_pass_effect.cpp index a3de379..b3c3cf6 100644 --- a/fft_pass_effect.cpp +++ b/fft_pass_effect.cpp @@ -4,6 +4,8 @@ #include "effect_util.h" #include "util.h" +using namespace std; + FFTPassEffect::FFTPassEffect() : input_width(1280), input_height(720), @@ -21,14 +23,14 @@ FFTPassEffect::~FFTPassEffect() glDeleteTextures(1, &tex); } -std::string FFTPassEffect::output_fragment_shader() +string FFTPassEffect::output_fragment_shader() { char buf[256]; sprintf(buf, "#define DIRECTION_VERTICAL %d\n", (direction == VERTICAL)); return buf + read_file("fft_pass_effect.frag"); } -void FFTPassEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void FFTPassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/flat_input.cpp b/flat_input.cpp index 0a81392..70cc109 100644 --- a/flat_input.cpp +++ b/flat_input.cpp @@ -7,6 +7,8 @@ #include "resource_pool.h" #include "util.h" +using namespace std; + FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height) : image_format(image_format), pixel_format(pixel_format), @@ -64,7 +66,7 @@ void FlatInput::finalize() finalized = true; } -void FlatInput::set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) +void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) { glActiveTexture(GL_TEXTURE0 + *sampler_num); check_error(); @@ -108,7 +110,7 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const std::string& prefix, ++*sampler_num; } -std::string FlatInput::output_fragment_shader() +string FlatInput::output_fragment_shader() { return read_file("flat_input.frag"); } diff --git a/gamma_compression_effect.cpp b/gamma_compression_effect.cpp index b1a16a6..3d4fd12 100644 --- a/gamma_compression_effect.cpp +++ b/gamma_compression_effect.cpp @@ -6,13 +6,15 @@ #include "effect_util.h" #include "util.h" +using namespace std; + GammaCompressionEffect::GammaCompressionEffect() : destination_curve(GAMMA_LINEAR) { register_int("destination_curve", (int *)&destination_curve); } -std::string GammaCompressionEffect::output_fragment_shader() +string GammaCompressionEffect::output_fragment_shader() { if (destination_curve == GAMMA_LINEAR) { return read_file("identity.frag"); @@ -25,7 +27,7 @@ std::string GammaCompressionEffect::output_fragment_shader() assert(false); } -void GammaCompressionEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void GammaCompressionEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/gamma_expansion_effect.cpp b/gamma_expansion_effect.cpp index bfccaa0..f51dc21 100644 --- a/gamma_expansion_effect.cpp +++ b/gamma_expansion_effect.cpp @@ -5,13 +5,15 @@ #include "gamma_expansion_effect.h" #include "util.h" +using namespace std; + GammaExpansionEffect::GammaExpansionEffect() : source_curve(GAMMA_LINEAR) { register_int("source_curve", (int *)&source_curve); } -std::string GammaExpansionEffect::output_fragment_shader() +string GammaExpansionEffect::output_fragment_shader() { if (source_curve == GAMMA_LINEAR) { return read_file("identity.frag"); @@ -24,7 +26,7 @@ std::string GammaExpansionEffect::output_fragment_shader() assert(false); } -void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void GammaExpansionEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/glow_effect.cpp b/glow_effect.cpp index 86a3d7f..2cc6d01 100644 --- a/glow_effect.cpp +++ b/glow_effect.cpp @@ -7,6 +7,8 @@ #include "mix_effect.h" #include "util.h" +using namespace std; + GlowEffect::GlowEffect() : blur(new BlurEffect), cutoff(new HighlightCutoffEffect), @@ -35,7 +37,7 @@ void GlowEffect::rewrite_graph(EffectChain *graph, Node *self) self->disabled = true; } -bool GlowEffect::set_float(const std::string &key, float value) { +bool GlowEffect::set_float(const string &key, float value) { if (key == "blurred_mix_amount") { return mix->set_float("strength_second", value); } @@ -51,7 +53,7 @@ HighlightCutoffEffect::HighlightCutoffEffect() register_float("cutoff", &cutoff); } -std::string HighlightCutoffEffect::output_fragment_shader() +string HighlightCutoffEffect::output_fragment_shader() { return read_file("highlight_cutoff_effect.frag"); } diff --git a/init.cpp b/init.cpp index aca85b9..df72832 100644 --- a/init.cpp +++ b/init.cpp @@ -7,6 +7,8 @@ #include "init.h" #include "util.h" +using namespace std; + bool movit_initialized = false; MovitDebugLevel movit_debug_level = MOVIT_DEBUG_ON; float movit_texel_subpixel_precision; @@ -16,7 +18,7 @@ int movit_num_wrongly_rounded; // The rules for objects with nontrivial constructors in static scope // are somewhat convoluted, and easy to mess up. We simply have a // pointer instead (and never care to clean it up). -std::string *movit_data_directory = NULL; +string *movit_data_directory = NULL; namespace { @@ -114,7 +116,7 @@ void measure_texel_subpixel_precision() float biggest_jump = 0.0f; for (unsigned i = 1; i < width; ++i) { assert(out_data[i] >= out_data[i - 1]); - biggest_jump = std::max(biggest_jump, out_data[i] - out_data[i - 1]); + biggest_jump = max(biggest_jump, out_data[i] - out_data[i - 1]); } movit_texel_subpixel_precision = biggest_jump; @@ -275,13 +277,13 @@ void check_extensions() } // namespace -void init_movit(const std::string& data_directory, MovitDebugLevel debug_level) +void init_movit(const string& data_directory, MovitDebugLevel debug_level) { if (movit_initialized) { return; } - movit_data_directory = new std::string(data_directory); + movit_data_directory = new string(data_directory); movit_debug_level = debug_level; glewInit(); diff --git a/lift_gamma_gain_effect.cpp b/lift_gamma_gain_effect.cpp index f00da87..5bc989a 100644 --- a/lift_gamma_gain_effect.cpp +++ b/lift_gamma_gain_effect.cpp @@ -5,6 +5,8 @@ #include "lift_gamma_gain_effect.h" #include "util.h" +using namespace std; + LiftGammaGainEffect::LiftGammaGainEffect() : lift(0.0f, 0.0f, 0.0f), gamma(1.0f, 1.0f, 1.0f), @@ -15,12 +17,12 @@ LiftGammaGainEffect::LiftGammaGainEffect() register_vec3("gain", (float *)&gain); } -std::string LiftGammaGainEffect::output_fragment_shader() +string LiftGammaGainEffect::output_fragment_shader() { return read_file("lift_gamma_gain_effect.frag"); } -void LiftGammaGainEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void LiftGammaGainEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/mirror_effect.cpp b/mirror_effect.cpp index 7c9875a..2aa1fea 100644 --- a/mirror_effect.cpp +++ b/mirror_effect.cpp @@ -1,11 +1,13 @@ #include "mirror_effect.h" #include "util.h" +using namespace std; + MirrorEffect::MirrorEffect() { } -std::string MirrorEffect::output_fragment_shader() +string MirrorEffect::output_fragment_shader() { return read_file("mirror_effect.frag"); } diff --git a/mix_effect.cpp b/mix_effect.cpp index 0f80a8f..6e279cb 100644 --- a/mix_effect.cpp +++ b/mix_effect.cpp @@ -1,6 +1,8 @@ #include "mix_effect.h" #include "util.h" +using namespace std; + MixEffect::MixEffect() : strength_first(0.5f), strength_second(0.5f) { @@ -8,7 +10,7 @@ MixEffect::MixEffect() register_float("strength_second", &strength_second); } -std::string MixEffect::output_fragment_shader() +string MixEffect::output_fragment_shader() { return read_file("mix_effect.frag"); } diff --git a/multiply_effect.cpp b/multiply_effect.cpp index f3610d3..3e35810 100644 --- a/multiply_effect.cpp +++ b/multiply_effect.cpp @@ -3,13 +3,15 @@ #include "multiply_effect.h" #include "util.h" +using namespace std; + MultiplyEffect::MultiplyEffect() : factor(1.0f, 1.0f, 1.0f, 1.0f) { register_vec4("factor", (float *)&factor); } -std::string MultiplyEffect::output_fragment_shader() +string MultiplyEffect::output_fragment_shader() { return read_file("multiply_effect.frag"); } diff --git a/overlay_effect.cpp b/overlay_effect.cpp index 799c359..09c1638 100644 --- a/overlay_effect.cpp +++ b/overlay_effect.cpp @@ -1,9 +1,11 @@ #include "overlay_effect.h" #include "util.h" +using namespace std; + OverlayEffect::OverlayEffect() {} -std::string OverlayEffect::output_fragment_shader() +string OverlayEffect::output_fragment_shader() { return read_file("overlay_effect.frag"); } diff --git a/padding_effect.cpp b/padding_effect.cpp index 00d475a..9d93aca 100644 --- a/padding_effect.cpp +++ b/padding_effect.cpp @@ -5,6 +5,8 @@ #include "padding_effect.h" #include "util.h" +using namespace std; + PaddingEffect::PaddingEffect() : border_color(0.0f, 0.0f, 0.0f, 0.0f), output_width(1280), @@ -19,12 +21,12 @@ PaddingEffect::PaddingEffect() register_float("left", &left); } -std::string PaddingEffect::output_fragment_shader() +string PaddingEffect::output_fragment_shader() { return read_file("padding_effect.frag"); } -void PaddingEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void PaddingEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/resample_effect.cpp b/resample_effect.cpp index c2ef531..6c490f1 100644 --- a/resample_effect.cpp +++ b/resample_effect.cpp @@ -13,6 +13,8 @@ #include "resample_effect.h" #include "util.h" +using namespace std; + namespace { float sinc(float x) @@ -155,7 +157,7 @@ void ResampleEffect::update_size() assert(ok); } -bool ResampleEffect::set_float(const std::string &key, float value) { +bool ResampleEffect::set_float(const string &key, float value) { if (key == "width") { output_width = value; update_size(); @@ -193,7 +195,7 @@ SingleResamplePassEffect::~SingleResamplePassEffect() glDeleteTextures(1, &texnum); } -std::string SingleResamplePassEffect::output_fragment_shader() +string SingleResamplePassEffect::output_fragment_shader() { char buf[256]; sprintf(buf, "#define DIRECTION_VERTICAL %d\n", (direction == VERTICAL)); @@ -212,7 +214,7 @@ std::string SingleResamplePassEffect::output_fragment_shader() // // For horizontal scaling, we fill in the exact same texture; // the shader just interprets it differently. -void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { unsigned src_size, dst_size; if (direction == SingleResamplePassEffect::HORIZONTAL) { @@ -286,7 +288,7 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const std // Anyhow, in this case we clearly need to look at more source pixels // to compute the destination pixel, and how many depend on the scaling factor. // Thus, the kernel width will vary with how much we scale. - float radius_scaling_factor = std::min(float(dst_size) / float(src_size), 1.0f); + float radius_scaling_factor = min(float(dst_size) / float(src_size), 1.0f); int int_radius = lrintf(LANCZOS_RADIUS / radius_scaling_factor); int src_samples = int_radius * 2 + 1; float *weights = new float[dst_samples * src_samples * 2]; @@ -316,7 +318,7 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const std src_bilinear_samples = 0; for (unsigned y = 0; y < dst_samples; ++y) { unsigned num_samples_saved = combine_samples(weights + (y * src_samples) * 2, NULL, src_samples, UINT_MAX); - src_bilinear_samples = std::max(src_bilinear_samples, src_samples - num_samples_saved); + src_bilinear_samples = max(src_bilinear_samples, src_samples - num_samples_saved); } // Now that we know the right width, actually combine the samples. @@ -348,7 +350,7 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const std delete[] bilinear_weights; } -void SingleResamplePassEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void SingleResamplePassEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/resize_effect.cpp b/resize_effect.cpp index 1141fba..70efea0 100644 --- a/resize_effect.cpp +++ b/resize_effect.cpp @@ -1,6 +1,8 @@ #include "resize_effect.h" #include "util.h" +using namespace std; + ResizeEffect::ResizeEffect() : width(1280), height(720) { @@ -8,7 +10,7 @@ ResizeEffect::ResizeEffect() register_int("height", &height); } -std::string ResizeEffect::output_fragment_shader() +string ResizeEffect::output_fragment_shader() { return read_file("identity.frag"); } diff --git a/resource_pool.cpp b/resource_pool.cpp index 6eadd90..b074247 100644 --- a/resource_pool.cpp +++ b/resource_pool.cpp @@ -50,7 +50,7 @@ ResourcePool::~ResourcePool() void ResourcePool::delete_program(GLuint glsl_program_num) { bool found_program = false; - for (std::map, GLuint>::iterator program_it = programs.begin(); + for (map, GLuint>::iterator program_it = programs.begin(); program_it != programs.end(); ++program_it) { if (program_it->second == glsl_program_num) { @@ -62,7 +62,7 @@ void ResourcePool::delete_program(GLuint glsl_program_num) assert(found_program); glDeleteProgram(glsl_program_num); - std::map >::iterator shader_it = + map >::iterator shader_it = program_shaders.find(glsl_program_num); assert(shader_it != program_shaders.end()); diff --git a/sandbox_effect.cpp b/sandbox_effect.cpp index 6aafb74..840611e 100644 --- a/sandbox_effect.cpp +++ b/sandbox_effect.cpp @@ -3,18 +3,20 @@ #include "sandbox_effect.h" #include "util.h" +using namespace std; + SandboxEffect::SandboxEffect() : parm(0.0f) { register_float("parm", &parm); } -std::string SandboxEffect::output_fragment_shader() +string SandboxEffect::output_fragment_shader() { return read_file("sandbox_effect.frag"); } -void SandboxEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void SandboxEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/saturation_effect.cpp b/saturation_effect.cpp index 3eff6e4..637da86 100644 --- a/saturation_effect.cpp +++ b/saturation_effect.cpp @@ -3,13 +3,15 @@ #include "saturation_effect.h" #include "util.h" +using namespace std; + SaturationEffect::SaturationEffect() : saturation(1.0f) { register_float("saturation", &saturation); } -std::string SaturationEffect::output_fragment_shader() +string SaturationEffect::output_fragment_shader() { return read_file("saturation_effect.frag"); } diff --git a/test_util.cpp b/test_util.cpp index eaa5fc6..be34583 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -11,6 +11,8 @@ #include "test_util.h" #include "util.h" +using namespace std; + class Input; namespace { @@ -32,7 +34,7 @@ void vertical_flip(T *data, unsigned width, unsigned height) for (unsigned y = 0; y < height / 2; ++y) { unsigned flip_y = height - y - 1; for (unsigned x = 0; x < width; ++x) { - std::swap(data[y * width + x], data[flip_y * width + x]); + swap(data[y * width + x], data[flip_y * width + x]); } } } diff --git a/unsharp_mask_effect.cpp b/unsharp_mask_effect.cpp index 7c28925..115553b 100644 --- a/unsharp_mask_effect.cpp +++ b/unsharp_mask_effect.cpp @@ -7,6 +7,8 @@ #include "unsharp_mask_effect.h" #include "util.h" +using namespace std; + UnsharpMaskEffect::UnsharpMaskEffect() : blur(new BlurEffect), mix(new MixEffect) @@ -30,7 +32,7 @@ void UnsharpMaskEffect::rewrite_graph(EffectChain *graph, Node *self) self->disabled = true; } -bool UnsharpMaskEffect::set_float(const std::string &key, float value) { +bool UnsharpMaskEffect::set_float(const string &key, float value) { if (key == "amount") { bool ok = mix->set_float("strength_first", 1.0f + value); return ok && mix->set_float("strength_second", -value); diff --git a/util.cpp b/util.cpp index a1fac6d..6b1de53 100644 --- a/util.cpp +++ b/util.cpp @@ -8,7 +8,9 @@ #include "init.h" #include "util.h" -extern std::string *movit_data_directory; +using namespace std; + +extern string *movit_data_directory; void hsv2rgb(float h, float s, float v, float *r, float *g, float *b) { @@ -66,9 +68,9 @@ void hsv2rgb_normalized(float h, float s, float v, float *r, float *g, float *b) } } -std::string read_file(const std::string &filename) +string read_file(const string &filename) { - const std::string full_pathname = *movit_data_directory + "/" + filename; + const string full_pathname = *movit_data_directory + "/" + filename; static char buf[131072]; FILE *fp = fopen(full_pathname.c_str(), "r"); @@ -80,10 +82,10 @@ std::string read_file(const std::string &filename) int len = fread(buf, 1, sizeof(buf), fp); fclose(fp); - return std::string(buf, len); + return string(buf, len); } -GLuint compile_shader(const std::string &shader_src, GLenum type) +GLuint compile_shader(const string &shader_src, GLenum type) { GLuint obj = glCreateShader(type); const GLchar* source[] = { shader_src.data() }; @@ -116,7 +118,7 @@ void print_3x3_matrix(const Eigen::Matrix3d& m) printf("\n"); } -std::string output_glsl_mat3(const std::string &name, const Eigen::Matrix3d &m) +string output_glsl_mat3(const string &name, const Eigen::Matrix3d &m) { char buf[1024]; sprintf(buf, diff --git a/vignette_effect.cpp b/vignette_effect.cpp index 0f5c688..6a9a340 100644 --- a/vignette_effect.cpp +++ b/vignette_effect.cpp @@ -5,6 +5,8 @@ #include "vignette_effect.h" #include "util.h" +using namespace std; + VignetteEffect::VignetteEffect() : center(0.5f, 0.5f), aspect_correction(1.0f, 1.0f), @@ -16,7 +18,7 @@ VignetteEffect::VignetteEffect() register_float("inner_radius", (float *)&inner_radius); } -std::string VignetteEffect::output_fragment_shader() +string VignetteEffect::output_fragment_shader() { return read_file("vignette_effect.frag"); } @@ -30,7 +32,7 @@ void VignetteEffect::inform_input_size(unsigned input_num, unsigned width, unsig } } -void VignetteEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void VignetteEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); diff --git a/white_balance_effect.cpp b/white_balance_effect.cpp index 2c99ca8..53c49e4 100644 --- a/white_balance_effect.cpp +++ b/white_balance_effect.cpp @@ -10,6 +10,7 @@ #include "white_balance_effect.h" using namespace Eigen; +using namespace std; namespace { @@ -103,12 +104,12 @@ WhiteBalanceEffect::WhiteBalanceEffect() register_float("output_color_temperature", &output_color_temperature); } -std::string WhiteBalanceEffect::output_fragment_shader() +string WhiteBalanceEffect::output_fragment_shader() { return read_file("white_balance_effect.frag"); } -void WhiteBalanceEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +void WhiteBalanceEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num) { Matrix3d rgb_to_xyz_matrix = ColorspaceConversionEffect::get_xyz_matrix(COLORSPACE_sRGB); Vector3d rgb(neutral_color.r, neutral_color.g, neutral_color.b); diff --git a/ycbcr_input.cpp b/ycbcr_input.cpp index 4166da9..6e73d3e 100644 --- a/ycbcr_input.cpp +++ b/ycbcr_input.cpp @@ -11,6 +11,7 @@ #include "ycbcr_input.h" using namespace Eigen; +using namespace std; namespace { @@ -100,7 +101,7 @@ void YCbCrInput::finalize() finalized = true; } -void YCbCrInput::set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) +void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num) { for (unsigned channel = 0; channel < 3; ++channel) { glActiveTexture(GL_TEXTURE0 + *sampler_num + channel); @@ -144,7 +145,7 @@ void YCbCrInput::set_gl_state(GLuint glsl_program_num, const std::string& prefix *sampler_num += 3; } -std::string YCbCrInput::output_fragment_shader() +string YCbCrInput::output_fragment_shader() { float coeff[3], offset[3], scale[3]; @@ -212,7 +213,7 @@ std::string YCbCrInput::output_fragment_shader() // Inverting the matrix gives us what we need to go from YCbCr back to RGB. Matrix3d ycbcr_to_rgb = rgb_to_ycbcr.inverse(); - std::string frag_shader; + string frag_shader; frag_shader = output_glsl_mat3("PREFIX(inv_ycbcr_matrix)", ycbcr_to_rgb);