From 77e927b58fca272d1d336a9def63678fb28c0632 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jul 2021 15:01:05 +1000 Subject: Cleanup: reserve C++ comments for disabled code Use C comments for plain text. --- source/blender/blenkernel/BKE_cloth.h | 28 +- source/blender/blenkernel/intern/armature_pose.cc | 2 +- source/blender/blenkernel/intern/boids.c | 4 +- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/fluid.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenlib/BLI_dlrbTree.h | 5 +- source/blender/blenlib/intern/BLI_mmap.c | 6 +- source/blender/blenlib/intern/math_base_inline.c | 6 +- source/blender/blenlib/intern/winstuff.c | 2 +- source/blender/blenloader/intern/versioning_250.c | 8 +- .../operations/COM_DoubleEdgeMaskOperation.cc | 1030 ++++++++++---------- .../operations/COM_FastGaussianBlurOperation.cc | 43 +- .../depsgraph/intern/builder/deg_builder_rna.cc | 4 +- .../depsgraph/intern/eval/deg_eval_flush.cc | 18 +- source/blender/editors/physics/particle_edit.c | 4 +- .../freestyle/intern/application/Controller.cpp | 2 +- .../blender/imbuf/intern/oiio/openimageio_api.cpp | 2 +- source/blender/makesdna/DNA_anim_types.h | 2 +- source/blender/makesdna/DNA_constraint_types.h | 2 +- .../nodes/texture/nodes/node_texture_rotate.c | 2 +- source/blender/sequencer/intern/strip_transform.c | 6 +- 22 files changed, 593 insertions(+), 589 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index a0e3d5dc142..dbf285feb92 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -39,14 +39,14 @@ struct Scene; #define DO_INLINE MALWAYS_INLINE -/* goal defines */ +/* Goal defines. */ #define SOFTGOALSNAP 0.999f /* This is approximately the smallest number that can be * represented by a float, given its precision. */ #define ALMOST_ZERO FLT_EPSILON -/* Bits to or into the ClothVertex.flags. */ +/* Bits to or into the #ClothVertex.flags. */ typedef enum eClothVertexFlag { CLOTH_VERT_FLAG_PINNED = (1 << 0), CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self collisions */ @@ -150,7 +150,7 @@ typedef struct ClothSpring { float target[3]; } ClothSpring; -// some macro enhancements for vector treatment +/* Some macro enhancements for vector treatment. */ #define VECSUBADDSS(v1, v2, aS, v3, bS) \ { \ *(v1) -= *(v2)*aS + *(v3)*bS; \ @@ -211,9 +211,8 @@ typedef enum { CLOTH_SPRING_FLAG_NEEDED = (1 << 2), /* Springs has values to be applied. */ } CLOTH_SPRINGS_FLAGS; -///////////////////////////////////////////////// -// collision.c -//////////////////////////////////////////////// +/* -------------------------------------------------------------------- */ +/* collision.c */ struct CollPair; @@ -225,20 +224,17 @@ typedef struct ColliderContacts { int totcollisions; } ColliderContacts; -// needed for implicit.c +/* needed for implicit.c */ int cloth_bvh_collision(struct Depsgraph *depsgraph, struct Object *ob, struct ClothModifierData *clmd, float step, float dt); -//////////////////////////////////////////////// +/* -------------------------------------------------------------------- */ +/* cloth.c */ -///////////////////////////////////////////////// -// cloth.c -//////////////////////////////////////////////// - -// needed for modifier.c +/* Needed for modifier.c */ void cloth_free_modifier_extern(struct ClothModifierData *clmd); void cloth_free_modifier(struct ClothModifierData *clmd); void clothModifier_do(struct ClothModifierData *clmd, @@ -250,18 +246,16 @@ void clothModifier_do(struct ClothModifierData *clmd, int cloth_uses_vgroup(struct ClothModifierData *clmd); -// needed for collision.c +/* Needed for collision.c */ void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving, bool self); -// needed for button_object.c +/* Needed for button_object.c */ void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr); void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3], const float dir_new[3]); -//////////////////////////////////////////////// - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc index 09e1c7d6615..2b2268c6302 100644 --- a/source/blender/blenkernel/intern/armature_pose.cc +++ b/source/blender/blenkernel/intern/armature_pose.cc @@ -42,7 +42,7 @@ using BoneNameSet = blender::Set; using ActionApplier = blender::FunctionRef; -// Forward declarations. +/* Forward declarations. */ BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose); void pose_apply_disable_fcurves_for_unselected_bones(bAction *action, const BoneNameSet &selected_bone_names); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index c57adae485f..efd0fc71b20 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -231,7 +231,7 @@ static bool rule_avoid_collision(BoidRule *rule, int n, neighbors = 0, nearest = 0; bool ret = 0; - // check deflector objects first + /* Check deflector objects first. */ if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) { ParticleCollision col; BVHTreeRayHit hit; @@ -293,7 +293,7 @@ static bool rule_avoid_collision(BoidRule *rule, } } - // check boids in own system + /* Check boids in own system. */ if (acbr->options & BRULE_ACOLL_WITH_BOIDS) { neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree, pa->prev_state.co, diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 1b628b16802..fc1721eaf3a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -547,7 +547,7 @@ static float eff_calc_visibility(ListBase *colliders, return visibility; } -// noise function for wind e.g. +/* Noise function for wind e.g. */ static float wind_func(struct RNG *rng, float strength) { int random = (BLI_rng_get_int(rng) + 1) % 128; /* max 2357 */ diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 2b48683a3a8..1d8dc97d2af 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -1545,7 +1545,7 @@ static void emit_from_particles(Object *flow_ob, float dt) { if (ffs && ffs->psys && ffs->psys->part && - ELEM(ffs->psys->part->type, PART_EMITTER, PART_FLUID)) // is particle system selected + ELEM(ffs->psys->part->type, PART_EMITTER, PART_FLUID)) /* Is particle system selected. */ { ParticleSimulationData sim; ParticleSystem *psys = ffs->psys; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 941db80b76c..89de37d6e4b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1653,7 +1653,7 @@ static void object_update_from_subsurf_ccg(Object *object) * * All this is defeating all the designs we need to follow to allow safe * threaded evaluation, but this is as good as we can make it within the - * current sculpt//evaluated mesh design. This is also how we've survived + * current sculpt/evaluated mesh design. This is also how we've survived * with old DerivedMesh based solutions. So, while this is all wrong and * needs reconsideration, doesn't seem to be a big stopper for real * production artists. diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index 8c20e3d3988..437dacfa80b 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -137,7 +137,8 @@ short BLI_dlrbTree_contains(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void * */ /* Add the given data to the tree, and return the node added */ -// NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned +/* NOTE: for duplicates, the update_cb is called (if available), + * and the existing node is returned. */ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, DLRBT_NAlloc_FP new_cb, @@ -145,7 +146,7 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, void *data); /* Remove the given element from the tree and balance again */ -// FIXME: this is not implemented yet... +/* FIXME: this is not implemented yet... */ // void BLI_dlrbTree_remove(DLRBT_Tree *tree, DLRBT_Node *node); /* Node Operations (Manual) --------------------- */ diff --git a/source/blender/blenlib/intern/BLI_mmap.c b/source/blender/blenlib/intern/BLI_mmap.c index 71510b62ba1..c25e89df818 100644 --- a/source/blender/blenlib/intern/BLI_mmap.c +++ b/source/blender/blenlib/intern/BLI_mmap.c @@ -31,11 +31,11 @@ #ifndef WIN32 # include # include -# include // for mmap -# include // for read close +# include /* For mmap. */ +# include /* For read close. */ #else # include "BLI_winstuff.h" -# include // for open close read +# include /* For open close read. */ #endif struct BLI_mmap_file { diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 58b109eca10..0a213fa8696 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -410,7 +410,7 @@ MINLINE float pingpongf(float value, float scale) return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale); } -// Square. +/* Square. */ MINLINE int square_s(short a) { @@ -442,7 +442,7 @@ MINLINE double square_d(double a) return a * a; } -// Cube. +/* Cube. */ MINLINE int cube_s(short a) { @@ -474,7 +474,7 @@ MINLINE double cube_d(double a) return a * a * a; } -// Min/max +/* Min/max */ MINLINE float min_ff(float a, float b) { diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index beeae175869..d5c9c5cd5e6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -30,7 +30,7 @@ # include "MEM_guardedalloc.h" -# define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY +# define WIN32_SKIP_HKEY_PROTECTION /* Need to use HKEY. */ # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_utildefines.h" diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index b368650eaca..e56c1995363 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -132,7 +132,7 @@ static void sequencer_init_preview_region(ARegion *region) region->v2d.max[0] = 12000.0f; region->v2d.max[1] = 12000.0f; region->v2d.cur = region->v2d.tot; - region->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); + region->v2d.align = V2D_ALIGN_FREE; /* `(V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y)` */ region->v2d.keeptot = V2D_KEEPTOT_FREE; } @@ -852,7 +852,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) Object *ob; for (ob = bmain->objects.first; ob; ob = ob->id.next) { - if (ob->flag & 8192) { // OB_POSEMODE = 8192 + if (ob->flag & 8192) { /* OB_POSEMODE = 8192. */ ob->mode |= OB_MODE_POSE; } } @@ -1405,7 +1405,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) { - sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE + sce->r.ffcodecdata.audio_codec = 0x0; /* `CODEC_ID_NONE` */ } SEQ_ALL_BEGIN (sce->ed, seq) { @@ -1745,7 +1745,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* New Settings */ if (!MAIN_VERSION_ATLEAST(bmain, 252, 5)) { - brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space + brush->flag |= BRUSH_SPACE_ATTEN; /* Explicitly enable adaptive space. */ /* spacing was originally in pixels, convert it to percentage for new version * size should not be zero due to sanity check above diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc index 1a0d7e52b0f..13993c06d51 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc @@ -25,7 +25,7 @@ namespace blender::compositor { -// this part has been copied from the double edge mask +/* This part has been copied from the double edge mask. */ static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, const unsigned int *limask, @@ -35,163 +35,163 @@ static void do_adjacentKeepBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the right, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the right, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the right, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the right, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -205,214 +205,218 @@ static void do_adjacentBleedBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x - 1]) { // test if outer mask is empty underneath or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the right, are empty in the inner mask, + * But filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty above or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x + rw] || + !lomask[x + 1]) { /* Test if outer mask is empty above or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x + rw] || + !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the left, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the left, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the left, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the left, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * But filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -426,155 +430,155 @@ static void do_allKeepBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size - /* Test the four corners */ - /* upper left corner */ + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ + /* Test the four corners. */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the right + /* Test if the inner mask is empty underneath or to the right. */ if (!limask[x - rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the left + /* Test if the inner mask is empty underneath or to the left. */ if (!limask[x - rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the right + /* Test if inner mask is empty above or to the right. */ if (!limask[x + rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the left + /* Test if inner mask is empty above or to the left. */ if (!limask[x + rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -588,207 +592,210 @@ static void do_allBleedBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the right + /* Test if the inner mask is empty underneath or to the right. */ if (!limask[x - rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the left + /* Test if the inner mask is empty underneath or to the left. */ if (!limask[x - rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the right + /* Test if inner mask is empty above or to the right. */ if (!limask[x + rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x + rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the left + /* Test if inner mask is empty above or to the left. */ if (!limask[x + rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x + rw] || - !lomask[x - 1]) { // test if outer mask is empty underneath or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -804,13 +811,14 @@ static void do_allEdgeDetection(unsigned int t, unsigned int in_osz, unsigned int in_gsz) { - int x; // x = pixel loop counter - int a; // a = pixel loop counter - int dx; // dx = delta x - int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop - int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop - int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop - int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop + int x; /* Pixel loop counter. */ + int a; /* Pixel loop counter. */ + int dx; /* Delta x. */ + int pix_prevRow; /* Pixel one row behind the one we are testing in a loop. */ + int pix_nextRow; /* Pixel one row in front of the one we are testing in a loop. */ + int pix_prevCol; /* Pixel one column behind the one we are testing in a loop. */ + int pix_nextCol; /* Pixel one column in front of the one we are testing in a loop. */ + /* Test all rows between the FIRST and LAST rows, excluding left and right edges */ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) { a = x - 2; @@ -819,8 +827,8 @@ static void do_allEdgeDetection(unsigned int t, pix_prevCol = a + 1; pix_nextCol = a - 1; while (a > dx - 2) { - if (!limask[a]) { // if the inner mask is empty - if (lomask[a]) { // if the outer mask is full + if (!limask[a]) { /* If the inner mask is empty. */ + if (lomask[a]) { /* If the outer mask is full. */ /* * Next we test all 4 directions around the current pixel: next/prev/up/down * The test ensures that the outer mask is empty and that the inner mask @@ -831,23 +839,23 @@ static void do_allEdgeDetection(unsigned int t, (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || (!lomask[pix_prevRow] && !limask[pix_prevRow])) { - in_osz++; // increment the outer boundary pixel count - lres[a] = 3; // flag pixel as part of outer edge + in_osz++; /* Increment the outer boundary pixel count. */ + lres[a] = 3; /* Flag pixel as part of outer edge. */ } - else { // it's not a boundary pixel, but it is a gradient pixel - in_gsz++; // increment the gradient pixel count - lres[a] = 2; // flag pixel as gradient + else { /* It's not a boundary pixel, but it is a gradient pixel. */ + in_gsz++; /* Increment the gradient pixel count. */ + lres[a] = 2; /* Flag pixel as gradient. */ } } } else { if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] || !limask[pix_prevRow]) { - in_isz++; // increment the inner boundary pixel count - lres[a] = 4; // flag pixel as part of inner edge + in_isz++; /* Increment the inner boundary pixel count. */ + lres[a] = 4; /* Flag pixel as part of inner edge. */ } else { - res[a] = 1.0f; // pixel is part of inner mask, but not at an edge + res[a] = 1.0f; /* Pixel is part of inner mask, but not at an edge. */ } } a--; @@ -858,7 +866,7 @@ static void do_allEdgeDetection(unsigned int t, } } - rsize[0] = in_isz; // fill in our return sizes for edges + fill + rsize[0] = in_isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = in_osz; rsize[2] = in_gsz; } @@ -874,13 +882,13 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int in_osz, unsigned int in_gsz) { - int x; // x = pixel loop counter - int a; // a = pixel loop counter - int dx; // dx = delta x - int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop - int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop - int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop - int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop + int x; /* Pixel loop counter. */ + int a; /* Pixel loop counter. */ + int dx; /* Delta x. */ + int pix_prevRow; /* Pixel one row behind the one we are testing in a loop. */ + int pix_nextRow; /* Pixel one row in front of the one we are testing in a loop. */ + int pix_prevCol; /* Pixel one column behind the one we are testing in a loop. */ + int pix_nextCol; /* Pixel one column in front of the one we are testing in a loop. */ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) { a = x - 2; @@ -889,8 +897,8 @@ static void do_adjacentEdgeDetection(unsigned int t, pix_prevCol = a + 1; pix_nextCol = a - 1; while (a > dx - 2) { - if (!limask[a]) { // if the inner mask is empty - if (lomask[a]) { // if the outer mask is full + if (!limask[a]) { /* If the inner mask is empty. */ + if (lomask[a]) { /* If the outer mask is full. */ /* * Next we test all 4 directions around the current pixel: next/prev/up/down * The test ensures that the outer mask is empty and that the inner mask @@ -901,12 +909,12 @@ static void do_adjacentEdgeDetection(unsigned int t, (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || (!lomask[pix_prevRow] && !limask[pix_prevRow])) { - in_osz++; // increment the outer boundary pixel count - lres[a] = 3; // flag pixel as part of outer edge + in_osz++; /* Increment the outer boundary pixel count. */ + lres[a] = 3; /* Flag pixel as part of outer edge. */ } - else { // it's not a boundary pixel, but it is a gradient pixel - in_gsz++; // increment the gradient pixel count - lres[a] = 2; // flag pixel as gradient + else { /* It's not a boundary pixel, but it is a gradient pixel. */ + in_gsz++; /* Increment the gradient pixel count. */ + lres[a] = 2; /* Flag pixel as gradient. */ } } } @@ -915,22 +923,22 @@ static void do_adjacentEdgeDetection(unsigned int t, (!limask[pix_prevCol] && lomask[pix_prevCol]) || (!limask[pix_nextRow] && lomask[pix_nextRow]) || (!limask[pix_prevRow] && lomask[pix_prevRow])) { - in_isz++; // increment the inner boundary pixel count - lres[a] = 4; // flag pixel as part of inner edge + in_isz++; /* Increment the inner boundary pixel count. */ + lres[a] = 4; /* Flag pixel as part of inner edge. */ } else { - res[a] = 1.0f; // pixel is part of inner mask, but not at an edge + res[a] = 1.0f; /* Pixel is part of inner mask, but not at an edge. */ } } a--; - pix_prevRow--; // advance all four "surrounding" pixel pointers + pix_prevRow--; /* Advance all four "surrounding" pixel pointers. */ pix_nextRow--; pix_prevCol--; pix_nextCol--; } } - rsize[0] = in_isz; // fill in our return sizes for edges + fill + rsize[0] = in_isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = in_osz; rsize[2] = in_gsz; } @@ -945,12 +953,12 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int isz, unsigned int gsz) { - int x; // x = pixel loop counter - int a; // a = temporary pixel index buffer loop counter - unsigned int ud; // ud = unscaled edge distance - unsigned int dmin; // dmin = minimum edge distance + int x; /* Pixel loop counter. */ + int a; /* Temporary pixel index buffer loop counter. */ + unsigned int ud; /* Unscaled edge distance. */ + unsigned int dmin; /* Minimum edge distance. */ - unsigned int rsl; // long used for finding fast 1.0/sqrt + unsigned int rsl; /* Long used for finding fast `1.0/sqrt`. */ unsigned int gradientFillOffset; /* For looping inner edge pixel indexes, represents current position from offset. */ @@ -1025,36 +1033,37 @@ static void do_createEdgeLocationBuffer(unsigned int t, */ /* clang-format on */ - gradientFillOffset = 0; // since there are likely "more" of these, put it first. :) - *innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes - *outerEdgeOffset = (*innerEdgeOffset) + isz; // set start of outer edge indexes - /* set the accumulators to correct positions */ // set up some accumulator variables for loops - gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective - innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each - outerAccum = *outerEdgeOffset; // section fills up its allocated space in gbuf - // uses dmin=row, rsl=col + gradientFillOffset = 0; /* Since there are likely "more" of these, put it first. :). */ + *innerEdgeOffset = gradientFillOffset + gsz; /* Set start of inner edge indexes. */ + *outerEdgeOffset = (*innerEdgeOffset) + isz; /* Set start of outer edge indexes. */ + /* Set the accumulators to correct positions */ /* Set up some accumulator variables for loops. + */ + gradientAccum = gradientFillOffset; /* Each accumulator variable starts at its respective. */ + innerAccum = *innerEdgeOffset; /* Section's offset so when we start filling, each. */ + outerAccum = *outerEdgeOffset; /* Section fills up its allocated space in gbuf. */ + /* Uses `dmin=row`, `rsl=col`. */ for (x = 0, dmin = 0; x < t; x += rw, dmin++) { for (rsl = 0; rsl < rw; rsl++) { a = x + rsl; - if (lres[a] == 2) { // it is a gradient pixel flagged by 2 - ud = gradientAccum << 1; // double the index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into gradient pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into gradient pixel location buffer - gradientAccum++; // increment gradient index buffer pointer + if (lres[a] == 2) { /* It is a gradient pixel flagged by 2. */ + ud = gradientAccum << 1; /* Double the index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into gradient pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into gradient pixel location buffer. */ + gradientAccum++; /* Increment gradient index buffer pointer. */ } - else if (lres[a] == 3) { // it is an outer edge pixel flagged by 3 - ud = outerAccum << 1; // double the index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into outer edge pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into outer edge pixel location buffer - outerAccum++; // increment outer edge index buffer pointer - res[a] = 0.0f; // set output pixel intensity now since it won't change later + else if (lres[a] == 3) { /* It is an outer edge pixel flagged by 3. */ + ud = outerAccum << 1; /* Double the index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into outer edge pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into outer edge pixel location buffer. */ + outerAccum++; /* Increment outer edge index buffer pointer. */ + res[a] = 0.0f; /* Set output pixel intensity now since it won't change later. */ } - else if (lres[a] == 4) { // it is an inner edge pixel flagged by 4 - ud = innerAccum << 1; // double int index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into inner edge pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into inner edge pixel location buffer - innerAccum++; // increment inner edge index buffer pointer - res[a] = 1.0f; // set output pixel intensity now since it won't change later + else if (lres[a] == 4) { /* It is an inner edge pixel flagged by 4. */ + ud = innerAccum << 1; /* Double int index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into inner edge pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into inner edge pixel location buffer. */ + innerAccum++; /* Increment inner edge index buffer pointer. */ + res[a] = 1.0f; /* Set output pixel intensity now since it won't change later. */ } } } @@ -1069,21 +1078,21 @@ static void do_fillGradientBuffer(unsigned int rw, unsigned int innerEdgeOffset, unsigned int outerEdgeOffset) { - int x; // x = pixel loop counter - int a; // a = temporary pixel index buffer loop counter - int fsz; // size of the frame - unsigned int rsl; // long used for finding fast 1.0/sqrt - float rsf; // float used for finding fast 1.0/sqrt - const float rsopf = 1.5f; // constant float used for finding fast 1.0/sqrt + int x; /* Pixel loop counter. */ + int a; /* Temporary pixel index buffer loop counter. */ + int fsz; /* Size of the frame. */ + unsigned int rsl; /* Long used for finding fast `1.0/sqrt`. */ + float rsf; /* Float used for finding fast `1.0/sqrt`. */ + const float rsopf = 1.5f; /* Constant float used for finding fast `1.0/sqrt`. */ unsigned int gradientFillOffset; unsigned int t; - unsigned int ud; // ud = unscaled edge distance - unsigned int dmin; // dmin = minimum edge distance - float odist; // odist = current outer edge distance - float idist; // idist = current inner edge distance - int dx; // dx = X-delta (used for distance proportion calculation) - int dy; // dy = Y-delta (used for distance proportion calculation) + unsigned int ud; /* Unscaled edge distance. */ + unsigned int dmin; /* Minimum edge distance. */ + float odist; /* Current outer edge distance. */ + float idist; /* Current inner edge distance. */ + int dx; /* X-delta (used for distance proportion calculation) */ + int dy; /* Y-delta (used for distance proportion calculation) */ /* * The general algorithm used to color each gradient pixel is: @@ -1146,92 +1155,95 @@ static void do_fillGradientBuffer(unsigned int rw, for (x = gsz - 1; x >= 0; x--) { gradientFillOffset = x << 1; - t = gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x] - fsz = gbuf[gradientFillOffset + 1]; // calculate row of pixel indexed by gbuf[x] - dmin = 0xffffffff; // reset min distance to edge pixel + t = gbuf[gradientFillOffset]; /* Calculate column of pixel indexed by `gbuf[x]`. */ + fsz = gbuf[gradientFillOffset + 1]; /* Calculate row of pixel indexed by `gbuf[x]`. */ + dmin = 0xffffffff; /* Reset min distance to edge pixel. */ for (a = outerEdgeOffset + osz - 1; a >= outerEdgeOffset; - a--) { // loop through all outer edge buffer pixels + a--) { /* Loop through all outer edge buffer pixels. */ ud = a << 1; - dy = t - gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row - dx = fsz - gbuf[ud + 1]; // set dy to gradient pixel row - outer edge pixel column - ud = dx * dx + dy * dy; // compute sum of squares - if (ud < dmin) { // if our new sum of squares is less than the current minimum - dmin = ud; // set a new minimum equal to the new lower value + dy = t - gbuf[ud]; /* Set dx to gradient pixel column - outer edge pixel row. */ + dx = fsz - gbuf[ud + 1]; /* Set dy to gradient pixel row - outer edge pixel column. */ + ud = dx * dx + dy * dy; /* Compute sum of squares. */ + if (ud < dmin) { /* If our new sum of squares is less than the current minimum. */ + dmin = ud; /* Set a new minimum equal to the new lower value. */ } } - odist = (float)(dmin); // cast outer min to a float - rsf = odist * 0.5f; // - rsl = *(unsigned int *)&odist; // use some peculiar properties of the way bits are stored - rsl = 0x5f3759df - (rsl >> 1); // in floats vs. unsigned ints to compute an approximate - odist = *(float *)&rsl; // reciprocal square root + odist = (float)(dmin); /* Cast outer min to a float. */ + rsf = odist * 0.5f; + rsl = *(unsigned int *)&odist; /* Use some peculiar properties of the way bits are stored. */ + rsl = 0x5f3759df - (rsl >> 1); /* In floats vs. unsigned ints to compute an approximate. */ + odist = *(float *)&rsl; /* Reciprocal square root. */ odist = odist * (rsopf - (rsf * odist * - odist)); // -- ** this line can be iterated for more accuracy ** -- - dmin = 0xffffffff; // reset min distance to edge pixel + odist)); /* -- This line can be iterated for more accuracy. -- */ + dmin = 0xffffffff; /* Reset min distance to edge pixel. */ for (a = innerEdgeOffset + isz - 1; a >= innerEdgeOffset; - a--) { // loop through all inside edge pixels + a--) { /* Loop through all inside edge pixels. */ ud = a << 1; - dy = t - gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel - dx = fsz - gbuf[ud + 1]; // compute delta in X from gradient pixel to inside edge pixel - ud = dx * dx + dy * dy; // compute sum of squares - if (ud < dmin) { // if our new sum of squares is less than the current minimum we've found - dmin = ud; // set a new minimum equal to the new lower value + dy = t - gbuf[ud]; /* Compute delta in Y from gradient pixel to inside edge pixel. */ + dx = fsz - gbuf[ud + 1]; /* Compute delta in X from gradient pixel to inside edge pixel. */ + ud = dx * dx + dy * dy; /* Compute sum of squares. */ + if (ud < + dmin) { /* If our new sum of squares is less than the current minimum we've found. */ + dmin = ud; /* Set a new minimum equal to the new lower value. */ } } - idist = (float)(dmin); // cast inner min to a float - rsf = idist * 0.5f; // - rsl = *(unsigned int *)&idist; // - rsl = 0x5f3759df - (rsl >> 1); // see notes above - idist = *(float *)&rsl; // - idist = idist * (rsopf - (rsf * idist * idist)); // - /* - * Note once again that since we are using reciprocals of distance values our + + /* Cast inner min to a float. */ + idist = (float)(dmin); + rsf = idist * 0.5f; + rsl = *(unsigned int *)&idist; + + /* See notes above. */ + rsl = 0x5f3759df - (rsl >> 1); + idist = *(float *)&rsl; + idist = idist * (rsopf - (rsf * idist * idist)); + + /* NOTE: once again that since we are using reciprocals of distance values our * proportion is already the correct intensity, and does not need to be - * subtracted from 1.0 like it would have if we used real distances. - */ + * subtracted from 1.0 like it would have if we used real distances. */ - /* - * Here we reconstruct the pixel's memory location in the CompBuf by - * Pixel Index = Pixel Column + ( Pixel Row * Row Width ) - */ + /* Here we reconstruct the pixel's memory location in the CompBuf by + * `Pixel Index = Pixel Column + ( Pixel Row * Row Width )`. */ res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] = - (idist / (idist + odist)); // set intensity + (idist / (idist + odist)); /* Set intensity. */ } } -// end of copy +/* End of copy. */ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float *res) { - unsigned int *lres; // lres = unsigned int pointer to output pixel buffer (for bit operations) - unsigned int *limask; // limask = unsigned int pointer to inner mask (for bit operations) - unsigned int *lomask; // lomask = unsigned int pointer to outer mask (for bit operations) - - int rw; // rw = pixel row width - int t; // t = total number of pixels in buffer - 1 (used for loop starts) - int fsz; // size of the frame - - unsigned int isz = 0; // size (in pixels) of inside edge pixel index buffer - unsigned int osz = 0; // size (in pixels) of outside edge pixel index buffer - unsigned int gsz = 0; // size (in pixels) of gradient pixel index buffer - unsigned int rsize[3]; // size storage to pass to helper functions + unsigned int *lres; /* Pointer to output pixel buffer (for bit operations). */ + unsigned int *limask; /* Pointer to inner mask (for bit operations). */ + unsigned int *lomask; /* Pointer to outer mask (for bit operations). */ + + int rw; /* Pixel row width. */ + int t; /* Total number of pixels in buffer - 1 (used for loop starts). */ + int fsz; /* Size of the frame. */ + + unsigned int isz = 0; /* Size (in pixels) of inside edge pixel index buffer. */ + unsigned int osz = 0; /* Size (in pixels) of outside edge pixel index buffer. */ + unsigned int gsz = 0; /* Size (in pixels) of gradient pixel index buffer. */ + unsigned int rsize[3]; /* Size storage to pass to helper functions. */ unsigned int innerEdgeOffset = - 0; // offset into final buffer where inner edge pixel indexes start + 0; /* Offset into final buffer where inner edge pixel indexes start. */ unsigned int outerEdgeOffset = - 0; // offset into final buffer where outer edge pixel indexes start + 0; /* Offset into final buffer where outer edge pixel indexes start. */ - unsigned short *gbuf; // gradient/inner/outer pixel location index buffer + unsigned short *gbuf; /* Gradient/inner/outer pixel location index buffer. */ - if (true) { // if both input sockets have some data coming in... + if (true) { /* If both input sockets have some data coming in... */ - rw = this->getWidth(); // width of a row of pixels - t = (rw * this->getHeight()) - 1; // determine size of the frame + rw = this->getWidth(); /* Width of a row of pixels. */ + t = (rw * this->getHeight()) - 1; /* Determine size of the frame. */ memset(res, 0, - sizeof(float) * (t + 1)); // clear output buffer (not all pixels will be written later) + sizeof(float) * + (t + 1)); /* Clear output buffer (not all pixels will be written later). */ - lres = (unsigned int *)res; // unsigned int pointer to output buffer (for bit level ops) - limask = (unsigned int *)imask; // unsigned int pointer to input mask (for bit level ops) - lomask = (unsigned int *)omask; // unsigned int pointer to output mask (for bit level ops) + lres = (unsigned int *)res; /* Pointer to output buffer (for bit level ops).. */ + limask = (unsigned int *)imask; /* Pointer to input mask (for bit level ops).. */ + lomask = (unsigned int *)omask; /* Pointer to output mask (for bit level ops).. */ /* * The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the @@ -1258,52 +1270,52 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float * * Each version has slightly different criteria for detecting an edge pixel. */ - if (this->m_adjacentOnly) { // if "adjacent only" inner edge mode is turned on - if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_adjacentOnly) { /* If "adjacent only" inner edge mode is turned on. */ + if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */ do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize); } - else { // "bleed out" buffer edge mode is turned on + else { /* "bleed out" buffer edge mode is turned on. */ do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - // set up inner edge, outer edge, and gradient buffer sizes after border pass + /* Set up inner edge, outer edge, and gradient buffer sizes after border pass. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // detect edges in all non-border pixels in the buffer + /* Detect edges in all non-border pixels in the buffer. */ do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } - else { // "all" inner edge mode is turned on - if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on + else { /* "all" inner edge mode is turned on. */ + if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */ do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize); } - else { // "bleed out" buffer edge mode is turned on + else { /* "bleed out" buffer edge mode is turned on. */ do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - // set up inner edge, outer edge, and gradient buffer sizes after border pass + /* Set up inner edge, outer edge, and gradient buffer sizes after border pass. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // detect edges in all non-border pixels in the buffer + /* Detect edges in all non-border pixels in the buffer. */ do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } - // set edge and gradient buffer sizes once again... - // the sizes in rsize[] may have been modified - // by the do_*EdgeDetection() function. + /* Set edge and gradient buffer sizes once again... + * the sizes in rsize[] may have been modified + * by the `do_*EdgeDetection()` function. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // calculate size of pixel index buffer needed + /* Calculate size of pixel index buffer needed. */ fsz = gsz + isz + osz; - // allocate edge/gradient pixel index buffer + /* Allocate edge/gradient pixel index buffer. */ gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); do_createEdgeLocationBuffer( t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); - // free the gradient index buffer + /* Free the gradient index buffer. */ MEM_freeN(gbuf); } } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc index 2be6e4d1be7..a4c48828f17 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc @@ -126,7 +126,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float *buffer = src->getBuffer(); const uint8_t num_channels = src->get_num_channels(); - // <0.5 not valid, though can have a possibly useful sort of sharpening effect + /* <0.5 not valid, though can have a possibly useful sort of sharpening effect. */ if (sigma < 0.5f) { return; } @@ -135,8 +135,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, xy = 3; } - // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, - // so just skipping blur along faulty direction if src's def is below that limit! + /* XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, + * so just skipping blur along faulty direction if src's def is below that limit! */ if (src_width < 3) { xy &= ~1; } @@ -147,32 +147,32 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, return; } - // see "Recursive Gabor Filtering" by Young/VanVliet - // all factors here in double.prec. - // Required, because for single.prec it seems to blow up if sigma > ~200 + /* See "Recursive Gabor Filtering" by Young/VanVliet + * all factors here in double.prec. + * Required, because for single.prec it seems to blow up if sigma > ~200 */ if (sigma >= 3.556f) { q = 0.9804f * (sigma - 3.556f) + 2.5091f; } - else { // sigma >= 0.5 + else { /* `sigma >= 0.5`. */ q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f; } q2 = q * q; sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q); - // no gabor filtering here, so no complex multiplies, just the regular coefs. - // all negated here, so as not to have to recalc Triggs/Sdika matrix + /* No gabor filtering here, so no complex multiplies, just the regular coefs. + * all negated here, so as not to have to recalc Triggs/Sdika matrix. */ cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc; cf[2] = -q2 * (3.38246 + 3.0 * q) / sc; - // 0 & 3 unchanged + /* 0 & 3 unchanged. */ cf[3] = q2 * q / sc; cf[0] = 1.0 - cf[1] - cf[2] - cf[3]; - // Triggs/Sdika border corrections, - // it seems to work, not entirely sure if it is actually totally correct, - // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark), - // found one other implementation by Cristoph Lampert, - // but neither seem to be quite the same, result seems to be ok so far anyway. - // Extra scale factor here to not have to do it in filter, - // though maybe this had something to with the precision errors + /* Triggs/Sdika border corrections, + * it seems to work, not entirely sure if it is actually totally correct, + * Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark), + * found one other implementation by Cristoph Lampert, + * but neither seem to be quite the same, result seems to be ok so far anyway. + * Extra scale factor here to not have to do it in filter, + * though maybe this had something to with the precision errors */ sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3])); tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]); @@ -210,12 +210,12 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, } \ (void)0 - // intermediate buffers + /* Intermediate buffers. */ sz = MAX2(src_width, src_height); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); - if (xy & 1) { // H + if (xy & 1) { /* H. */ int offset; for (y = 0; y < src_height; y++) { const int yx = y * src_width; @@ -232,7 +232,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, } } } - if (xy & 2) { // V + if (xy & 2) { /* V. */ int offset; const int add = src_width * num_channels; @@ -257,7 +257,6 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, #undef YVV } -/// FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() { this->addInputSocket(DataType::Value); @@ -336,8 +335,6 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) } } - // newBuf-> - this->m_iirgaus = copy; } unlockMutex(); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index 8e3960e1a15..bdabd67cc07 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -153,8 +153,8 @@ bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_co return false; } - // If substr != prop_identifier, it means that the substring is found further in prop_identifier, - // and that thus index -1 is a valid memory location. + /* If substr != prop_identifier, it means that the substring is found further in prop_identifier, + * and that thus index -1 is a valid memory location. */ const bool start_ok = substr == prop_identifier || substr[-1] == '.'; if (!start_ok) { return false; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 1b24e2b7ad2..a015491e2d7 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -58,15 +58,15 @@ #include "intern/eval/deg_eval_copy_on_write.h" -// Invalidate data-block data when update is flushed on it. -// -// The idea of this is to help catching cases when area is accessing data which -// is not yet evaluated, which could happen due to missing relations. The issue -// is that usually that data will be kept from previous frame, and it looks to -// be plausible. -// -// This ensures that data does not look plausible, making it much easier to -// catch usage of invalid state. +/* Invalidate data-block data when update is flushed on it. + * + * The idea of this is to help catching cases when area is accessing data which + * is not yet evaluated, which could happen due to missing relations. The issue + * is that usually that data will be kept from previous frame, and it looks to + * be plausible. + * + * This ensures that data does not look plausible, making it much easier to + * catch usage of invalid state. */ #undef INVALIDATE_ON_FLUSH namespace blender::deg { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f2bbd6d5084..5a629058c81 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -368,7 +368,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o else if (pset->edittype == PE_TYPE_SOFTBODY && pid->type == PTCACHE_TYPE_SOFTBODY) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { pset->flag |= PE_FADE_TIME; - // NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; + /* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; @@ -377,7 +377,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o else if (pset->edittype == PE_TYPE_CLOTH && pid->type == PTCACHE_TYPE_CLOTH) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { pset->flag |= PE_FADE_TIME; - // NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; + /* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */ PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); } edit = pid->cache->edit; diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index 9c675c93a2e..0d243a812fa 100644 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -707,7 +707,7 @@ void Controller::ComputeSteerableViewMap() for (unsigned int x = 0; x < img[i]->width(); ++x) { //img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)) / 255.0f); img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y))); - //float c = qGray(qimg.pixel(x, y)); + // float c = qGray(qimg.pixel(x, y)); //img[i]->setPixel(x, y, qGray(qimg.pixel(x, y))); } } diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 0941338160d..3ad902a241d 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -28,7 +28,7 @@ # define _USE_MATH_DEFINES #endif -// NOTE: Keep first, BLI_path_util conflicts with OIIO's format. +/* NOTE: Keep first, #BLI_path_util conflicts with OIIO's format. */ #include "openimageio_api.h" #include #include diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index c02035be4ac..837dadaa719 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -210,7 +210,7 @@ typedef struct FMod_Envelope { } FMod_Envelope; /* cycling/repetition modifier data */ -// TODO: we can only do complete cycles... +/* TODO: we can only do complete cycles. */ typedef struct FMod_Cycles { /** Extrapolation mode to use before first keyframe. */ short before_mode; diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 34f50b23c77..63bf587d7fb 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -1102,7 +1102,7 @@ typedef enum eRotLimit_Flags { /* distance limit constraint */ /* bDistLimitConstraint->flag */ typedef enum eDistLimit_Flag { - /* "soft" cushion effect when reaching the limit sphere */ // NOT IMPLEMENTED! + /* "soft" cushion effect when reaching the limit sphere */ /* NOT IMPLEMENTED! */ LIMITDIST_USESOFT = (1 << 0), /* as for all Limit constraints - allow to be used during transform? */ LIMITDIST_TRANSFORM = (1 << 1), diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c index 06eb632378c..9985499772e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c @@ -47,7 +47,7 @@ static void rotate(float new_co[3], float a, const float ax[3], const float co[3 float cos_a = cosf(a * (float)(2 * M_PI)); float sin_a = sinf(a * (float)(2 * M_PI)); - // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina + /* `x' = xcosa + n(n.x)(1-cosa) + (x*n)sina`. */ mul_v3_v3fl(perp, co, cos_a); mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a)); diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index b7989349ebe..c9af2fced65 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -269,9 +269,9 @@ bool SEQ_transform_seqbase_shuffle_ex(ListBase *seqbasep, } test->machine += channel_delta; - SEQ_time_update_sequence( - evil_scene, - test); // XXX: I don't think this is needed since were only moving vertically, Campbell. + + /* XXX: I don't think this is needed since were only moving vertically, Campbell. */ + SEQ_time_update_sequence(evil_scene, test); } if ((test->machine < 1) || (test->machine > MAXSEQ)) { -- cgit v1.2.3