Blender V4.3
rectop.cc File Reference
#include <cstdlib>
#include "BLI_math_base.h"
#include "BLI_math_color.h"
#include "BLI_math_color_blend.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "IMB_colormanagement.hh"
#include "MEM_guardedalloc.h"
#include <cstring>

Go to the source code of this file.

Classes

struct  RectBlendThreadData
 

Typedefs

using IMB_blend_func = void (*)(uchar *dst, const uchar *src1, const uchar *src2)
 
using IMB_blend_func_float = void (*)(float *dst, const float *src1, const float *src2)
 

Functions

void IMB_blend_color_byte (uchar dst[4], const uchar src1[4], const uchar src2[4], IMB_BlendMode mode)
 
void IMB_blend_color_float (float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
 
void IMB_rectclip (ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
 
static void imb_rectclip3 (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, int *destx, int *desty, int *origx, int *origy, int *srcx, int *srcy, int *width, int *height)
 
void IMB_rectcpy (ImBuf *dbuf, const ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height)
 
void IMB_rectblend (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, ushort *dmask, const ushort *curvemask, const ushort *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
 
static void rectblend_thread_do (void *data_v, int scanline)
 
void IMB_rectblend_threaded (ImBuf *dbuf, const ImBuf *obuf, const ImBuf *sbuf, ushort *dmask, const ushort *curvemask, const ushort *texmask, float mask_max, int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, IMB_BlendMode mode, bool accumulate)
 
void IMB_rectfill (ImBuf *drect, const float col[4])
 
void IMB_rectfill_area_replace (const ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
 
void buf_rectfill_area (uchar *rect, float *rectf, int width, int height, const float col[4], ColorManagedDisplay *display, int x1, int y1, int x2, int y2)
 
void IMB_rectfill_area (ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2, ColorManagedDisplay *display)
 
void IMB_rectfill_alpha (ImBuf *ibuf, const float value)
 
Crop
static void rect_crop_4bytes (void **buf_p, const int size_src[2], const rcti *crop)
 
static void rect_crop_16bytes (void **buf_p, const int size_src[2], const rcti *crop)
 
void IMB_rect_crop (ImBuf *ibuf, const rcti *crop)
 
static void rect_realloc_4bytes (void **buf_p, const uint size[2])
 
static void rect_realloc_16bytes (void **buf_p, const uint size[2])
 
void IMB_rect_size_set (ImBuf *ibuf, const uint size[2])
 

Typedef Documentation

◆ IMB_blend_func

using IMB_blend_func = void (*)(uchar *dst, const uchar *src1, const uchar *src2)

Definition at line 491 of file rectop.cc.

◆ IMB_blend_func_float

using IMB_blend_func_float = void (*)(float *dst, const float *src1, const float *src2)

Definition at line 492 of file rectop.cc.

Function Documentation

◆ buf_rectfill_area()

void buf_rectfill_area ( unsigned char * rect,
float * rectf,
int width,
int height,
const float col[4],
ColorManagedDisplay * display,
int x1,
int y1,
int x2,
int y2 )

This should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it.

Definition at line 1130 of file rectop.cc.

References CLAMP, col, copy_v4_v4(), fb(), IMB_colormanagement_display_to_scene_linear_v3(), srgb_to_linearrgb_v4(), and unit_float_to_uchar_clamp.

Referenced by BKE_image_stamp_buf(), and IMB_rectfill_area().

◆ IMB_blend_color_byte()

◆ IMB_blend_color_float()

void IMB_blend_color_float ( float dst[4],
const float src1[4],
const float src2[4],
IMB_BlendMode mode )

Definition at line 115 of file rectop.cc.

References blend_color_add_alpha_float(), blend_color_add_float(), blend_color_burn_float(), blend_color_color_float(), blend_color_darken_float(), blend_color_difference_float(), blend_color_dodge_float(), blend_color_erase_alpha_float(), blend_color_exclusion_float(), blend_color_hardlight_float(), blend_color_hue_float(), blend_color_lighten_float(), blend_color_linearburn_float(), blend_color_linearlight_float(), blend_color_luminosity_float(), blend_color_mix_float(), blend_color_mul_float(), blend_color_overlay_float(), blend_color_pinlight_float(), blend_color_saturation_float(), blend_color_screen_float(), blend_color_softlight_float(), blend_color_sub_float(), blend_color_vividlight_float(), IMB_BLEND_ADD, IMB_BLEND_ADD_ALPHA, IMB_BLEND_COLOR, IMB_BLEND_COLORBURN, IMB_BLEND_COLORDODGE, IMB_BLEND_DARKEN, IMB_BLEND_DIFFERENCE, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_EXCLUSION, IMB_BLEND_HARDLIGHT, IMB_BLEND_HUE, IMB_BLEND_LIGHTEN, IMB_BLEND_LINEARBURN, IMB_BLEND_LINEARLIGHT, IMB_BLEND_LUMINOSITY, IMB_BLEND_MIX, IMB_BLEND_MUL, IMB_BLEND_OVERLAY, IMB_BLEND_PINLIGHT, IMB_BLEND_SATURATION, IMB_BLEND_SCREEN, IMB_BLEND_SOFTLIGHT, IMB_BLEND_SUB, and IMB_BLEND_VIVIDLIGHT.

Referenced by blender::ed::sculpt_paint::expand::colors_update_task(), blender::ed::sculpt_paint::color::do_paint_brush_task(), do_projectpaint_clone_f(), do_projectpaint_draw_f(), do_projectpaint_mask_f(), do_projectpaint_thread(), blender::ed::sculpt_paint::paint::image::PaintingKernel< ImageBuffer >::paint(), paint_2d_bucket_fill(), and paint_2d_gradient_fill().

◆ IMB_rect_crop()

◆ IMB_rect_size_set()

void IMB_rect_size_set ( ImBuf * ibuf,
const uint size[2] )

◆ IMB_rectblend()

void IMB_rectblend ( ImBuf * dbuf,
const ImBuf * obuf,
const ImBuf * sbuf,
ushort * dmask,
const ushort * curvemask,
const ushort * texmask,
float mask_max,
int destx,
int desty,
int origx,
int origy,
int srcx,
int srcy,
int width,
int height,
IMB_BlendMode mode,
bool accumulate )

Definition at line 494 of file rectop.cc.

References blend_color_add_alpha_byte(), blend_color_add_alpha_float(), blend_color_add_byte(), blend_color_add_float(), blend_color_burn_byte(), blend_color_burn_float(), blend_color_color_byte(), blend_color_color_float(), blend_color_darken_byte(), blend_color_darken_float(), blend_color_difference_byte(), blend_color_difference_float(), blend_color_dodge_byte(), blend_color_dodge_float(), blend_color_erase_alpha_byte(), blend_color_erase_alpha_float(), blend_color_exclusion_byte(), blend_color_exclusion_float(), blend_color_hardlight_byte(), blend_color_hardlight_float(), blend_color_hue_byte(), blend_color_hue_float(), blend_color_interpolate_byte(), blend_color_interpolate_float(), blend_color_lighten_byte(), blend_color_lighten_float(), blend_color_linearburn_byte(), blend_color_linearburn_float(), blend_color_linearlight_byte(), blend_color_linearlight_float(), blend_color_luminosity_byte(), blend_color_luminosity_float(), blend_color_mix_byte(), blend_color_mix_float(), blend_color_mul_byte(), blend_color_mul_float(), blend_color_overlay_byte(), blend_color_overlay_float(), blend_color_pinlight_byte(), blend_color_pinlight_float(), blend_color_saturation_byte(), blend_color_saturation_float(), blend_color_screen_byte(), blend_color_screen_float(), blend_color_softlight_byte(), blend_color_softlight_float(), blend_color_sub_byte(), blend_color_sub_float(), blend_color_vividlight_byte(), blend_color_vividlight_float(), ImBuf::byte_buffer, ImBuf::channels, ImBufByteBuffer::data, ImBufFloatBuffer::data, divide_round_i(), float, ImBuf::float_buffer, IMB_BLEND_ADD, IMB_BLEND_ADD_ALPHA, IMB_BLEND_COLOR, IMB_BLEND_COLORBURN, IMB_BLEND_COLORDODGE, IMB_BLEND_COPY, IMB_BLEND_COPY_ALPHA, IMB_BLEND_COPY_RGB, IMB_BLEND_DARKEN, IMB_BLEND_DIFFERENCE, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_EXCLUSION, IMB_BLEND_HARDLIGHT, IMB_BLEND_HUE, IMB_BLEND_INTERPOLATE, IMB_BLEND_LIGHTEN, IMB_BLEND_LINEARBURN, IMB_BLEND_LINEARLIGHT, IMB_BLEND_LUMINOSITY, IMB_BLEND_MIX, IMB_BLEND_MUL, IMB_BLEND_OVERLAY, IMB_BLEND_PINLIGHT, IMB_BLEND_SATURATION, IMB_BLEND_SCREEN, IMB_BLEND_SOFTLIGHT, IMB_BLEND_SUB, IMB_BLEND_VIVIDLIGHT, imb_rectclip3(), mask(), min_ff(), mul_v4_v4fl(), ImBuf::x, and x.

Referenced by IMB_rectblend_threaded(), IMB_rectcpy(), paint_2d_do_making_brush(), paint_2d_lift_clone(), paint_2d_lift_smear(), and rectblend_thread_do().

◆ IMB_rectblend_threaded()

void IMB_rectblend_threaded ( ImBuf * dbuf,
const ImBuf * obuf,
const ImBuf * sbuf,
ushort * dmask,
const ushort * curvemask,
const ushort * texmask,
float mask_max,
int destx,
int desty,
int origx,
int origy,
int srcx,
int srcy,
int width,
int height,
IMB_BlendMode mode,
bool accumulate )

◆ IMB_rectclip()

◆ imb_rectclip3()

static void imb_rectclip3 ( ImBuf * dbuf,
const ImBuf * obuf,
const ImBuf * sbuf,
int * destx,
int * desty,
int * origx,
int * origy,
int * srcx,
int * srcy,
int * width,
int * height )
static

Definition at line 368 of file rectop.cc.

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

Referenced by IMB_rectblend().

◆ IMB_rectcpy()

void IMB_rectcpy ( ImBuf * dbuf,
const ImBuf * sbuf,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height )

◆ IMB_rectfill()

void IMB_rectfill ( ImBuf * drect,
const float col[4] )

Replace pixels of entire image with solid color.

Parameters
drectAn image to be filled with color. It must be 4 channel image.
colRGBA color, which is assigned directly to both byte (via scaling) and float buffers.

Definition at line 1051 of file rectop.cc.

References ImBuf::byte_buffer, col, ImBufByteBuffer::data, ImBufFloatBuffer::data, ImBuf::float_buffer, int, ImBuf::x, and ImBuf::y.

Referenced by blender::io::usd::cache_image_color(), blender::ed::object::clear_single_image(), create_missing_media_image(), IMB_font_preview(), IMB_thumb_load_font(), and RE_bake_ibuf_clear().

◆ IMB_rectfill_alpha()

◆ IMB_rectfill_area()

void IMB_rectfill_area ( ImBuf * ibuf,
const float col[4],
int x1,
int y1,
int x2,
int y2,
ColorManagedDisplay * display )

Blend pixels of image area with solid color.

For images with uchar buffer use color matching image color-space. For images with float buffer use color display color-space. If display color-space can not be referenced, use color in SRGB color-space.

Parameters
ibufan image to be filled with color. It must be 4 channel image.
colRGBA color.
x1,y1,x2,y2(x1, y1) defines starting point of the rectangular area to be filled, (x2, y2) is the end point. Note that values are allowed to be loosely ordered, which means that x2 is allowed to be lower than x1, as well as y2 is allowed to be lower than y1. No matter the order the area between x1 and x2, and y1 and y2 is filled.
displaycolor-space reference for display space.

Definition at line 1241 of file rectop.cc.

References buf_rectfill_area(), ImBuf::byte_buffer, col, ImBufByteBuffer::data, ImBufFloatBuffer::data, ImBuf::float_buffer, ImBuf::x, and ImBuf::y.

Referenced by ui_tooltip_data_from_button_or_extra_icon().

◆ IMB_rectfill_area_replace()

void IMB_rectfill_area_replace ( const ImBuf * ibuf,
const float col[4],
int x1,
int y1,
int x2,
int y2 )

Replace pixels of image area with solid color.

Parameters
ibufan image to be filled with color. It must be 4 channel image.
colRGBA color, which is assigned directly to both byte (via scaling) and float buffers.
x1,y1,x2,y2(x1, y1) defines starting point of the rectangular area to be filled, (x2, y2) is the end point. Note that values are allowed to be loosely ordered, which means that x2 is allowed to be lower than x1, as well as y2 is allowed to be lower than y1. No matter the order the area between x1 and x2, and y1 and y2 is filled.

Definition at line 1083 of file rectop.cc.

References BLI_assert, ImBuf::byte_buffer, ImBuf::channels, CLAMP, col, ImBufByteBuffer::data, ImBufFloatBuffer::data, ImBuf::float_buffer, ImBuf::x, x, and ImBuf::y.

◆ rect_crop_16bytes()

static void rect_crop_16bytes ( void ** buf_p,
const int size_src[2],
const rcti * crop )
static

Definition at line 223 of file rectop.cc.

References BLI_rcti_size_x(), BLI_rcti_size_y(), MEM_reallocN, rcti::xmin, and rcti::ymin.

Referenced by IMB_rect_crop().

◆ rect_crop_4bytes()

static void rect_crop_4bytes ( void ** buf_p,
const int size_src[2],
const rcti * crop )
static

Definition at line 206 of file rectop.cc.

References BLI_rcti_size_x(), BLI_rcti_size_y(), MEM_reallocN, rcti::xmin, and rcti::ymin.

Referenced by IMB_rect_crop().

◆ rect_realloc_16bytes()

static void rect_realloc_16bytes ( void ** buf_p,
const uint size[2] )
static

Definition at line 278 of file rectop.cc.

References MEM_freeN(), and MEM_mallocN.

Referenced by IMB_rect_size_set().

◆ rect_realloc_4bytes()

static void rect_realloc_4bytes ( void ** buf_p,
const uint size[2] )
static

Re-allocate buffers at a new size.

Definition at line 269 of file rectop.cc.

References MEM_freeN(), and MEM_mallocN.

Referenced by IMB_rect_size_set().

◆ rectblend_thread_do()

static void rectblend_thread_do ( void * data_v,
int scanline )
static

Definition at line 969 of file rectop.cc.

References IMB_rectblend().

Referenced by IMB_rectblend_threaded().