Blender V4.3
paint_image_2d.cc File Reference
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "BLI_bitmap.h"
#include "BLI_listbase.h"
#include "BLI_math_color_blend.h"
#include "BLI_stack.h"
#include "BLI_task.h"
#include "BKE_brush.hh"
#include "BKE_colorband.hh"
#include "BKE_context.hh"
#include "BKE_image.hh"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "ED_paint.hh"
#include "ED_screen.hh"
#include "IMB_colormanagement.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "UI_view2d.hh"
#include "paint_intern.hh"

Go to the source code of this file.

Classes

struct  BrushPainterCache
 
struct  BrushPainter
 
struct  ImagePaintRegion
 
struct  ImagePaintTile
 
struct  ImagePaintState
 
struct  Paint2DForeachData
 

Enumerations

enum  ImagePaintTileState { PAINT2D_TILE_UNINITIALIZED = 0 , PAINT2D_TILE_MISSING , PAINT2D_TILE_READY }
 

Functions

static BrushPainterbrush_painter_2d_new (Scene *scene, const Paint *paint, Brush *brush, bool invert)
 
static void brush_painter_2d_require_imbuf (Brush *brush, ImagePaintTile *tile, bool use_float, bool use_color_correction, bool invert)
 
static void brush_painter_cache_2d_free (BrushPainterCache *cache)
 
static void brush_imbuf_tex_co (const rctf *mapping, int x, int y, float texco[3])
 
static ushortbrush_painter_mask_ibuf_new (BrushPainter *painter, const int size)
 
static void brush_painter_mask_imbuf_update (BrushPainter *painter, ImagePaintTile *tile, const ushort *tex_mask_old, int origx, int origy, int w, int h, int xt, int yt, const int diameter)
 
static void brush_painter_mask_imbuf_partial_update (BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
 
static ImBufbrush_painter_imbuf_new (BrushPainter *painter, ImagePaintTile *tile, const int size, float pressure, float distance)
 
static void brush_painter_imbuf_update (BrushPainter *painter, ImagePaintTile *tile, ImBuf *oldtexibuf, int origx, int origy, int w, int h, int xt, int yt)
 
static void brush_painter_imbuf_partial_update (BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const int diameter)
 
static void brush_painter_2d_tex_mapping (ImagePaintState *s, ImagePaintTile *tile, const int diameter, const float pos[2], const float mouse[2], int mapmode, rctf *r_mapping)
 
static void brush_painter_2d_refresh_cache (ImagePaintState *s, BrushPainter *painter, ImagePaintTile *tile, const float pos[2], const float mouse[2], float pressure, float distance, float size)
 
static bool paint_2d_ensure_tile_canvas (ImagePaintState *s, int i)
 
static void paint_2d_ibuf_rgb_get (ImBuf *ibuf, int x, int y, float r_rgb[4])
 
static void paint_2d_ibuf_rgb_set (ImBuf *ibuf, int x, int y, const bool is_torus, const float rgb[4])
 
static void paint_2d_ibuf_tile_convert (ImBuf *ibuf, int *x, int *y, short paint_tile)
 
static float paint_2d_ibuf_add_if (ImBuf *ibuf, int x, int y, float *outrgb, short paint_tile, float w)
 
static void paint_2d_lift_soften (ImagePaintState *s, ImagePaintTile *tile, ImBuf *ibuf, ImBuf *ibufb, const int *pos, const short paint_tile)
 
static void paint_2d_set_region (ImagePaintRegion *region, int destx, int desty, int srcx, int srcy, int width, int height)
 
static int paint_2d_torus_split_region (ImagePaintRegion region[4], ImBuf *dbuf, ImBuf *sbuf, short paint_tile)
 
static void paint_2d_lift_smear (ImBuf *ibuf, ImBuf *ibufb, int *pos, short paint_tile)
 
static ImBufpaint_2d_lift_clone (ImBuf *ibuf, ImBuf *ibufb, const int *pos)
 
static void paint_2d_convert_brushco (ImBuf *ibufb, const float pos[2], int ipos[2])
 
static void paint_2d_do_making_brush (ImagePaintState *s, ImagePaintTile *tile, ImagePaintRegion *region, ImBuf *frombuf, float mask_max, short blend, int tilex, int tiley, int tilew, int tileh)
 
static void paint_2d_op_foreach_do (void *__restrict data_v, const int iter, const TaskParallelTLS *__restrict)
 
static int paint_2d_op (void *state, ImagePaintTile *tile, const float lastpos[2], const float pos[2])
 
static int paint_2d_canvas_set (ImagePaintState *s)
 
static void paint_2d_canvas_free (ImagePaintState *s)
 
static void paint_2d_transform_mouse (View2D *v2d, const float in[2], float out[2])
 
static bool is_inside_tile (const int size[2], const float pos[2], const float brush[2])
 
static void paint_2d_uv_to_coord (ImagePaintTile *tile, const float uv[2], float coord[2])
 
void paint_2d_stroke (void *ps, const float prev_mval[2], const float mval[2], const bool eraser, float pressure, float distance, float base_size)
 
void * paint_2d_new_stroke (bContext *C, wmOperator *op, int mode)
 
void paint_2d_redraw (const bContext *C, void *ps, bool final)
 
void paint_2d_stroke_done (void *ps)
 
static void paint_2d_fill_add_pixel_byte (const int x_px, const int y_px, ImBuf *ibuf, BLI_Stack *stack, BLI_bitmap *touched, const float color[4], float threshold_sq)
 
static void paint_2d_fill_add_pixel_float (const int x_px, const int y_px, ImBuf *ibuf, BLI_Stack *stack, BLI_bitmap *touched, const float color[4], float threshold_sq)
 
static ImageUserpaint_2d_get_tile_iuser (ImagePaintState *s, int tile_number)
 
void paint_2d_bucket_fill (const bContext *C, const float color[3], Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
 
void paint_2d_gradient_fill (const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
 

Enumeration Type Documentation

◆ ImagePaintTileState

Enumerator
PAINT2D_TILE_UNINITIALIZED 
PAINT2D_TILE_MISSING 
PAINT2D_TILE_READY 

Definition at line 96 of file paint_image_2d.cc.

Function Documentation

◆ brush_imbuf_tex_co()

static void brush_imbuf_tex_co ( const rctf * mapping,
int x,
int y,
float texco[3] )
static

◆ brush_painter_2d_new()

static BrushPainter * brush_painter_2d_new ( Scene * scene,
const Paint * paint,
Brush * brush,
bool invert )
static

◆ brush_painter_2d_refresh_cache()

◆ brush_painter_2d_require_imbuf()

◆ brush_painter_2d_tex_mapping()

static void brush_painter_2d_tex_mapping ( ImagePaintState * s,
ImagePaintTile * tile,
const int diameter,
const float pos[2],
const float mouse[2],
int mapmode,
rctf * r_mapping )
static

◆ brush_painter_cache_2d_free()

◆ brush_painter_imbuf_new()

◆ brush_painter_imbuf_partial_update()

static void brush_painter_imbuf_partial_update ( BrushPainter * painter,
ImagePaintTile * tile,
const float pos[2],
const int diameter )
static

◆ brush_painter_imbuf_update()

◆ brush_painter_mask_ibuf_new()

static ushort * brush_painter_mask_ibuf_new ( BrushPainter * painter,
const int size )
static

◆ brush_painter_mask_imbuf_partial_update()

static void brush_painter_mask_imbuf_partial_update ( BrushPainter * painter,
ImagePaintTile * tile,
const float pos[2],
const int diameter )
static

Update the brush mask image by trying to reuse the cached texture result. This can be considerably faster for brushes that change size due to pressure or textures that stick to the surface where only part of the pixels are new

Definition at line 294 of file paint_image_2d.cc.

References brush_painter_mask_imbuf_update(), floorf, IMB_rectclip(), int, MEM_freeN(), MEM_mallocN, min_ii(), pos, BrushPainterCache::tex_mask, BrushPainterCache::tex_mask_old, BrushPainterCache::tex_mask_old_h, BrushPainterCache::tex_mask_old_w, tile, w(), ImBuf::x, and ImBuf::y.

Referenced by brush_painter_2d_refresh_cache().

◆ brush_painter_mask_imbuf_update()

static void brush_painter_mask_imbuf_update ( BrushPainter * painter,
ImagePaintTile * tile,
const ushort * tex_mask_old,
int origx,
int origy,
int w,
int h,
int xt,
int yt,
const int diameter )
static

◆ is_inside_tile()

static bool is_inside_tile ( const int size[2],
const float pos[2],
const float brush[2] )
static

Definition at line 1470 of file paint_image_2d.cc.

References pos.

Referenced by paint_2d_stroke().

◆ paint_2d_bucket_fill()

◆ paint_2d_canvas_free()

static void paint_2d_canvas_free ( ImagePaintState * s)
static

Definition at line 1452 of file paint_image_2d.cc.

References BKE_image_release_ibuf(), and paint_delete_blur_kernel().

Referenced by paint_2d_stroke_done().

◆ paint_2d_canvas_set()

◆ paint_2d_convert_brushco()

static void paint_2d_convert_brushco ( ImBuf * ibufb,
const float pos[2],
int ipos[2] )
static

Definition at line 1203 of file paint_image_2d.cc.

References floorf, int, pos, ImBuf::x, and ImBuf::y.

Referenced by paint_2d_op().

◆ paint_2d_do_making_brush()

static void paint_2d_do_making_brush ( ImagePaintState * s,
ImagePaintTile * tile,
ImagePaintRegion * region,
ImBuf * frombuf,
float mask_max,
short blend,
int tilex,
int tiley,
int tilew,
int tileh )
static

◆ paint_2d_ensure_tile_canvas()

◆ paint_2d_fill_add_pixel_byte()

static void paint_2d_fill_add_pixel_byte ( const int x_px,
const int y_px,
ImBuf * ibuf,
BLI_Stack * stack,
BLI_bitmap * touched,
const float color[4],
float threshold_sq )
static

◆ paint_2d_fill_add_pixel_float()

static void paint_2d_fill_add_pixel_float ( const int x_px,
const int y_px,
ImBuf * ibuf,
BLI_Stack * stack,
BLI_bitmap * touched,
const float color[4],
float threshold_sq )
static

◆ paint_2d_get_tile_iuser()

static ImageUser * paint_2d_get_tile_iuser ( ImagePaintState * s,
int tile_number )
static

Definition at line 1775 of file paint_image_2d.cc.

References paint_2d_ensure_tile_canvas().

Referenced by paint_2d_bucket_fill(), and paint_2d_gradient_fill().

◆ paint_2d_gradient_fill()

◆ paint_2d_ibuf_add_if()

static float paint_2d_ibuf_add_if ( ImBuf * ibuf,
int x,
int y,
float * outrgb,
short paint_tile,
float w )
static

◆ paint_2d_ibuf_rgb_get()

static void paint_2d_ibuf_rgb_get ( ImBuf * ibuf,
int x,
int y,
float r_rgb[4] )
static

◆ paint_2d_ibuf_rgb_set()

static void paint_2d_ibuf_rgb_set ( ImBuf * ibuf,
int x,
int y,
const bool is_torus,
const float rgb[4] )
static

◆ paint_2d_ibuf_tile_convert()

static void paint_2d_ibuf_tile_convert ( ImBuf * ibuf,
int * x,
int * y,
short paint_tile )
static

Definition at line 911 of file paint_image_2d.cc.

References PAINT_TILE_X, PAINT_TILE_Y, ImBuf::x, and ImBuf::y.

Referenced by paint_2d_ibuf_add_if(), and paint_2d_lift_soften().

◆ paint_2d_lift_clone()

static ImBuf * paint_2d_lift_clone ( ImBuf * ibuf,
ImBuf * ibufb,
const int * pos )
static

◆ paint_2d_lift_smear()

static void paint_2d_lift_smear ( ImBuf * ibuf,
ImBuf * ibufb,
int * pos,
short paint_tile )
static

◆ paint_2d_lift_soften()

◆ paint_2d_new_stroke()

◆ paint_2d_op()

◆ paint_2d_op_foreach_do()

static void paint_2d_op_foreach_do ( void *__restrict data_v,
const int iter,
const TaskParallelTLS * __restrict )
static

Definition at line 1279 of file paint_image_2d.cc.

References paint_2d_do_making_brush().

Referenced by paint_2d_op().

◆ paint_2d_redraw()

◆ paint_2d_set_region()

static void paint_2d_set_region ( ImagePaintRegion * region,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height )
static

◆ paint_2d_stroke()

◆ paint_2d_stroke_done()

◆ paint_2d_torus_split_region()

static int paint_2d_torus_split_region ( ImagePaintRegion region[4],
ImBuf * dbuf,
ImBuf * sbuf,
short paint_tile )
static

◆ paint_2d_transform_mouse()

static void paint_2d_transform_mouse ( View2D * v2d,
const float in[2],
float out[2] )
static

Definition at line 1465 of file paint_image_2d.cc.

References UI_view2d_region_to_view().

Referenced by paint_2d_bucket_fill(), and paint_2d_gradient_fill().

◆ paint_2d_uv_to_coord()

static void paint_2d_uv_to_coord ( ImagePaintTile * tile,
const float uv[2],
float coord[2] )
static

Definition at line 1476 of file paint_image_2d.cc.

References tile.

Referenced by paint_2d_stroke().