|
Blender V5.3
|
#include <algorithm>#include <numeric>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "DNA_mask_types.h"#include "DNA_scene_types.h"#include "DNA_vec_types.h"#include "BLI_array.hh"#include "BLI_delaunay_2d.hh"#include "BLI_math_geom_c.hh"#include "BLI_math_vector_c.hh"#include "BLI_math_vector_types.hh"#include "BLI_memarena.hh"#include "BLI_scanfill.hh"#include "BLI_utildefines.hh"#include "BLI_vector.hh"#include "BLI_linklist.hh"#include "BLI_listbase.hh"#include "BLI_rect.hh"#include "BLI_task_c.hh"#include "BKE_mask.hh"#include "BLI_strict_flags.hh"Go to the source code of this file.
Classes | |
| struct | blender::MaskRasterLayer |
| struct | blender::MaskRasterSplineInfo |
| struct | blender::MaskRasterHandle |
| struct | blender::MaskRasterizeBufferData |
Namespaces | |
| namespace | blender |
| BMesh Iterators. | |
Macros | |
| #define | USE_SCANFILL_EDGE_WORKAROUND |
| #define | SPLINE_RESOL_CAP_PER_PIXEL 2 |
| #define | SPLINE_RESOL_CAP_MIN 8 |
| #define | SPLINE_RESOL_CAP_MAX 64 |
| #define | SF_EDGE_IS_BOUNDARY 0xff |
| #define | SF_KEYINDEX_TEMP_ID uint(-1) |
| #define | TRI_TERMINATOR_ID uint(-1) |
| #define | TRI_VERT uint(-1) |
| #define | FACE_ASSERT(face, vert_max) |
| #define | CALC_CAP_RESOL |
| #define | CALC_CAP_RESOL |
Functions | |
| static void | blender::rotate_point_v2 (float r_p[2], const float p[2], const float cent[2], const float angle, const float asp[2]) |
| BLI_INLINE uint | blender::clampis_uint (const uint v, const uint min, const uint max) |
| static ScanFillVert * | blender::scanfill_vert_add_v2_with_depth (ScanFillContext *sf_ctx, const float co_xy[2], const float co_z) |
| static uint | blender::maskrasterize_layer_fill_open_spline_feather_quads (const MaskRasterSplineInfo *open_spline_ranges, uint open_spline_index, uint *face, const uint vert_num) |
| static void | blender::maskrasterize_spline_differentiate_point_outset (float(*diff_feather_points)[2], float(*diff_points)[2], const uint tot_diff_point, const float ofs, const bool do_test) |
| static bool | blender::isect_aabb_tri_v2 (const float xmin, const float ymin, const float xmax, const float ymax, const float v1[2], const float v2[2], const float v3[2]) |
| static bool | blender::layer_bucket_isect_test (const MaskRasterLayer *layer, uint face_index, const uint bucket_x, const uint bucket_y, const float bucket_size_x, const float bucket_size_y) |
| static void | blender::maskrasterize_layer_init_from_mask_layer (MaskRasterLayer *layer, const MaskLayer *masklay) |
| static void | blender::layer_bucket_init_dummy (MaskRasterLayer *layer) |
| static void | blender::layer_bucket_init (MaskRasterLayer *layer, const float pixel_size) |
| static void | blender::maskrasterize_layer_init_scanfill (MaskRasterHandle *mr_handle, MaskLayer *masklay, uint masklay_index, const rctf &default_bounds, const float pixel_size, const float asp_xy[2], const int width, const int height, const bool do_aspect_correct, const bool do_mask_aa, const bool do_feather, MemArena *sf_arena) |
| static void | blender::maskrasterize_layer_init_cdt (MaskRasterHandle *mr_handle, MaskLayer *masklay, uint masklay_index, const rctf &default_bounds, const float pixel_size, const float asp_xy[2], const int width, const int height, const bool do_aspect_correct, const bool do_mask_aa, const bool do_feather) |
| static float | blender::maskrasterize_layer_z_depth_quad (const float pt[2], const float v1[3], const float v2[3], const float v3[3], const float v4[3]) |
| static float | blender::maskrasterize_layer_isect (const uint *face, float(*cos)[3], const float dist_orig, const float xy[2]) |
| BLI_INLINE uint | blender::layer_bucket_index_from_xy (MaskRasterLayer *layer, const float xy[2]) |
| static float | blender::layer_bucket_depth_from_xy (MaskRasterLayer *layer, const float xy[2]) |
| static void | blender::maskrasterize_buffer_cb (void *__restrict userdata, const int y, const TaskParallelTLS *__restrict) |
Rasterization | |
| MaskRasterHandle * | blender::BKE_maskrasterize_handle_new () |
| void | blender::BKE_maskrasterize_handle_free (MaskRasterHandle *mr_handle) |
| void | blender::BKE_maskrasterize_handle_init (MaskRasterHandle *mr_handle, Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather) |
| float | blender::BKE_maskrasterize_handle_sample (MaskRasterHandle *mr_handle, const float xy[2]) |
| void | blender::BKE_maskrasterize_buffer (MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer) |
| Rasterize a buffer from a single mask (threaded execution). | |
Variables | |
| static constexpr int | blender::BUCKET_PIXELS_PER_CELL = 8 |
| static CLG_LogRef | blender::LOG = {"mask.rasterize"} |
This module exposes a rasterizer that works as a black box - implementation details are confined to this file.
The basic method to access is:
This file is admittedly a bit confusticated, in quite few areas speed was chosen over readability, though it is commented - so shouldn't be so hard to see what's going on.
Implementation:
To rasterize the mask its converted into geometry that use a ray-cast for each pixel lookup.
Initially kdopbvh was used but this ended up being too slow.
To gain some extra speed we take advantage of a few shortcuts that can be made rasterizing masks specifically.
Other Details:
This is getting a bit complicated with the addition of unfilled splines and end capping - If large changes are needed here we would be better off using an iterable BLI_mempool for triangles and converting to a contiguous array afterwards.
Definition in file mask_rasterize.cc.
| #define CALC_CAP_RESOL |
| #define CALC_CAP_RESOL |
Referenced by blender::maskrasterize_layer_init_cdt(), and blender::maskrasterize_layer_init_scanfill().
| #define FACE_ASSERT | ( | face, | |
| vert_max ) |
Definition at line 105 of file mask_rasterize.cc.
Referenced by blender::maskrasterize_layer_fill_open_spline_feather_quads(), blender::maskrasterize_layer_init_cdt(), and blender::maskrasterize_layer_init_scanfill().
| #define SF_EDGE_IS_BOUNDARY 0xff |
Definition at line 96 of file mask_rasterize.cc.
Referenced by blender::maskrasterize_layer_init_scanfill().
| #define SF_KEYINDEX_TEMP_ID uint(-1) |
Definition at line 97 of file mask_rasterize.cc.
Referenced by blender::maskrasterize_layer_init_scanfill().
| #define SPLINE_RESOL_CAP_MAX 64 |
Definition at line 88 of file mask_rasterize.cc.
| #define SPLINE_RESOL_CAP_MIN 8 |
Definition at line 87 of file mask_rasterize.cc.
| #define SPLINE_RESOL_CAP_PER_PIXEL 2 |
Definition at line 86 of file mask_rasterize.cc.
| #define TRI_TERMINATOR_ID uint(-1) |
Definition at line 99 of file mask_rasterize.cc.
Referenced by blender::layer_bucket_depth_from_xy(), and blender::layer_bucket_init().
| #define TRI_VERT uint(-1) |
Definition at line 100 of file mask_rasterize.cc.
Referenced by blender::layer_bucket_init(), blender::layer_bucket_isect_test(), blender::maskrasterize_layer_init_cdt(), blender::maskrasterize_layer_init_scanfill(), and blender::maskrasterize_layer_isect().
| #define USE_SCANFILL_EDGE_WORKAROUND |
Definition at line 84 of file mask_rasterize.cc.