Blender  V2.93
Classes | Typedefs | Enumerations | Functions | Variables
paint_image.c File Reference

Functions to paint images in 2D and 3D. More...

#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "DNA_brush_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "BKE_brush.h"
#include "BKE_colorband.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_paint.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_view2d.h"
#include "ED_image.h"
#include "ED_object.h"
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
#include "IMB_colormanagement.h"
#include "paint_intern.h"

Go to the source code of this file.

Classes

struct  PaintOperation
 
struct  GrabClone
 
struct  SampleColorData
 

Typedefs

typedef enum eTexPaintMode eTexPaintMode
 
typedef struct PaintOperation PaintOperation
 
typedef struct GrabClone GrabClone
 

Enumerations

enum  eTexPaintMode { PAINT_MODE_2D , PAINT_MODE_3D_PROJECT }
 

Functions

ImagePaintPartialRedrawget_imapaintpartial (void)
 
void set_imapaintpartial (struct ImagePaintPartialRedraw *ippr)
 
void ED_imapaint_clear_partial_redraw (void)
 
void imapaint_region_tiles (ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
 
void ED_imapaint_dirty_region (Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h, bool find_old)
 
void imapaint_image_update (SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint)
 
BlurKernelpaint_new_blur_kernel (Brush *br, bool proj)
 
void paint_delete_blur_kernel (BlurKernel *kernel)
 
static Brushimage_paint_brush (bContext *C)
 
static bool image_paint_poll_ex (bContext *C, bool check_tool)
 
static bool image_paint_poll (bContext *C)
 
static bool image_paint_poll_ignore_tool (bContext *C)
 
static bool image_paint_2d_clone_poll (bContext *C)
 
bool paint_use_opacity_masking (Brush *brush)
 
void paint_brush_color_get (struct Scene *scene, struct Brush *br, bool color_correction, bool invert, float distance, float pressure, float color[3], struct ColorManagedDisplay *display)
 
void paint_brush_init_tex (Brush *brush)
 
void paint_brush_exit_tex (Brush *brush)
 
static void gradient_draw_line (bContext *UNUSED(C), int x, int y, void *customdata)
 
static PaintOperationtexture_paint_init (bContext *C, wmOperator *op, const float mouse[2])
 
static void paint_stroke_update_step (bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
 
static void paint_stroke_redraw (const bContext *C, struct PaintStroke *stroke, bool final)
 
static void paint_stroke_done (const bContext *C, struct PaintStroke *stroke)
 
static bool paint_stroke_test_start (bContext *C, wmOperator *op, const float mouse[2])
 
static int paint_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int paint_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_image_paint (wmOperatorType *ot)
 
bool get_imapaint_zoom (bContext *C, float *zoomx, float *zoomy)
 
static void toggle_paint_cursor (Scene *scene, bool enable)
 
void ED_space_image_paint_update (Main *bmain, wmWindowManager *wm, Scene *scene)
 
static void grab_clone_apply (bContext *C, wmOperator *op)
 
static int grab_clone_exec (bContext *C, wmOperator *op)
 
static int grab_clone_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int grab_clone_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void grab_clone_cancel (bContext *UNUSED(C), wmOperator *op)
 
void PAINT_OT_grab_clone (wmOperatorType *ot)
 
static void sample_color_update_header (SampleColorData *data, bContext *C)
 
static int sample_color_exec (bContext *C, wmOperator *op)
 
static int sample_color_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int sample_color_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static bool sample_color_poll (bContext *C)
 
void PAINT_OT_sample_color (wmOperatorType *ot)
 
void ED_object_texture_paint_mode_enter_ex (Main *bmain, Scene *scene, Object *ob)
 
void ED_object_texture_paint_mode_enter (bContext *C)
 
void ED_object_texture_paint_mode_exit_ex (Main *bmain, Scene *scene, Object *ob)
 
void ED_object_texture_paint_mode_exit (bContext *C)
 
static bool texture_paint_toggle_poll (bContext *C)
 
static int texture_paint_toggle_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_texture_paint_toggle (wmOperatorType *ot)
 
static int brush_colors_flip_exec (bContext *C, wmOperator *UNUSED(op))
 
static bool brush_colors_flip_poll (bContext *C)
 
void PAINT_OT_brush_colors_flip (wmOperatorType *ot)
 
void ED_imapaint_bucket_fill (struct bContext *C, float color[3], wmOperator *op, const int mouse[2])
 
static bool texture_paint_poll (bContext *C)
 
bool image_texture_paint_poll (bContext *C)
 
bool facemask_paint_poll (bContext *C)
 
bool vert_paint_poll (bContext *C)
 
bool mask_paint_poll (bContext *C)
 

Variables

static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0}
 

Detailed Description

Functions to paint images in 2D and 3D.

Definition in file paint_image.c.

Typedef Documentation

◆ eTexPaintMode

◆ GrabClone

typedef struct GrabClone GrabClone

◆ PaintOperation

Enumeration Type Documentation

◆ eTexPaintMode

Enumerator
PAINT_MODE_2D 
PAINT_MODE_3D_PROJECT 

Definition at line 332 of file paint_image.c.

Function Documentation

◆ brush_colors_flip_exec()

static int brush_colors_flip_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ brush_colors_flip_poll()

static bool brush_colors_flip_poll ( bContext C)
static

◆ ED_imapaint_bucket_fill()

void ED_imapaint_bucket_fill ( struct bContext C,
float  color[3],
wmOperator op,
const int  mouse[2] 
)

◆ ED_imapaint_clear_partial_redraw()

void ED_imapaint_clear_partial_redraw ( void  )

◆ ED_imapaint_dirty_region()

void ED_imapaint_dirty_region ( Image ima,
ImBuf ibuf,
ImageUser iuser,
int  x,
int  y,
int  w,
int  h,
bool  find_old 
)

◆ ED_object_texture_paint_mode_enter()

void ED_object_texture_paint_mode_enter ( bContext C)

◆ ED_object_texture_paint_mode_enter_ex()

void ED_object_texture_paint_mode_enter_ex ( Main bmain,
Scene scene,
Object ob 
)

◆ ED_object_texture_paint_mode_exit()

void ED_object_texture_paint_mode_exit ( bContext C)

◆ ED_object_texture_paint_mode_exit_ex()

void ED_object_texture_paint_mode_exit_ex ( Main bmain,
Scene scene,
Object ob 
)

◆ ED_space_image_paint_update()

void ED_space_image_paint_update ( Main bmain,
wmWindowManager wm,
Scene scene 
)

◆ facemask_paint_poll()

bool facemask_paint_poll ( bContext C)

◆ get_imapaint_zoom()

bool get_imapaint_zoom ( bContext C,
float zoomx,
float zoomy 
)

◆ get_imapaintpartial()

ImagePaintPartialRedraw* get_imapaintpartial ( void  )

Definition at line 92 of file paint_image.c.

References imapaintpartial.

◆ grab_clone_apply()

static void grab_clone_apply ( bContext C,
wmOperator op 
)
static

◆ grab_clone_cancel()

static void grab_clone_cancel ( bContext UNUSEDC,
wmOperator op 
)
static

Definition at line 908 of file paint_image.c.

References wmOperator::customdata, and MEM_freeN.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_exec()

static int grab_clone_exec ( bContext C,
wmOperator op 
)
static

Definition at line 852 of file paint_image.c.

References C, grab_clone_apply(), and OPERATOR_FINISHED.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_invoke()

static int grab_clone_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ grab_clone_modal()

static int grab_clone_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ gradient_draw_line()

static void gradient_draw_line ( bContext UNUSEDC,
int  x,
int  y,
void *  customdata 
)
static

◆ image_paint_2d_clone_poll()

static bool image_paint_2d_clone_poll ( bContext C)
static

◆ image_paint_brush()

static Brush* image_paint_brush ( bContext C)
static

◆ image_paint_poll()

static bool image_paint_poll ( bContext C)
static

◆ image_paint_poll_ex()

static bool image_paint_poll_ex ( bContext C,
bool  check_tool 
)
static

◆ image_paint_poll_ignore_tool()

static bool image_paint_poll_ignore_tool ( bContext C)
static

Definition at line 311 of file paint_image.c.

References C, and image_paint_poll_ex().

Referenced by sample_color_poll().

◆ image_texture_paint_poll()

bool image_texture_paint_poll ( bContext C)

Definition at line 1360 of file paint_image.c.

References C, image_paint_poll(), and texture_paint_poll().

Referenced by ED_keymap_paint().

◆ imapaint_image_update()

void imapaint_image_update ( SpaceImage sima,
Image image,
ImBuf ibuf,
ImageUser iuser,
short  texpaint 
)

◆ imapaint_region_tiles()

void imapaint_region_tiles ( ImBuf ibuf,
int  x,
int  y,
int  w,
int  h,
int *  tx,
int *  ty,
int *  tw,
int *  th 
)

Definition at line 109 of file paint_image.c.

References ED_IMAGE_UNDO_TILE_BITS, IMB_rectclip(), NULL, w(), x, and y.

Referenced by ED_imapaint_dirty_region(), and paint_2d_op().

◆ mask_paint_poll()

bool mask_paint_poll ( bContext C)

Definition at line 1375 of file paint_image.c.

References BKE_paint_select_elem_test(), C, and CTX_data_active_object().

Referenced by PAINT_OT_weight_set().

◆ paint_brush_color_get()

void paint_brush_color_get ( struct Scene scene,
struct Brush br,
bool  color_correction,
bool  invert,
float  distance,
float  pressure,
float  color[3],
struct ColorManagedDisplay display 
)

◆ paint_brush_exit_tex()

void paint_brush_exit_tex ( Brush brush)

◆ paint_brush_init_tex()

void paint_brush_init_tex ( Brush brush)

◆ paint_delete_blur_kernel()

void paint_delete_blur_kernel ( BlurKernel kernel)

Definition at line 257 of file paint_image.c.

References MEM_freeN, and BlurKernel::wdata.

Referenced by paint_2d_canvas_free(), and project_paint_end().

◆ paint_exec()

static int paint_exec ( bContext C,
wmOperator op 
)
static

◆ paint_invoke()

static int paint_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ paint_new_blur_kernel()

BlurKernel* paint_new_blur_kernel ( Brush br,
bool  proj 
)

◆ PAINT_OT_brush_colors_flip()

void PAINT_OT_brush_colors_flip ( wmOperatorType ot)

◆ PAINT_OT_grab_clone()

void PAINT_OT_grab_clone ( wmOperatorType ot)

◆ PAINT_OT_image_paint()

void PAINT_OT_image_paint ( wmOperatorType ot)

◆ PAINT_OT_sample_color()

void PAINT_OT_sample_color ( wmOperatorType ot)

◆ PAINT_OT_texture_paint_toggle()

void PAINT_OT_texture_paint_toggle ( wmOperatorType ot)

◆ paint_stroke_done()

static void paint_stroke_done ( const bContext C,
struct PaintStroke stroke 
)
static

◆ paint_stroke_redraw()

static void paint_stroke_redraw ( const bContext C,
struct PaintStroke stroke,
bool  final 
)
static

◆ paint_stroke_test_start()

static bool paint_stroke_test_start ( bContext C,
wmOperator op,
const float  mouse[2] 
)
static

Definition at line 680 of file paint_image.c.

References C, wmOperator::customdata, paint_stroke_set_mode_data(), and texture_paint_init().

Referenced by paint_exec(), and paint_invoke().

◆ paint_stroke_update_step()

static void paint_stroke_update_step ( bContext C,
struct PaintStroke stroke,
PointerRNA itemptr 
)
static

◆ paint_use_opacity_masking()

bool paint_use_opacity_masking ( Brush brush)

◆ sample_color_exec()

static int sample_color_exec ( bContext C,
wmOperator op 
)
static

◆ sample_color_invoke()

static int sample_color_invoke ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ sample_color_modal()

static int sample_color_modal ( bContext C,
wmOperator op,
const wmEvent event 
)
static

◆ sample_color_poll()

static bool sample_color_poll ( bContext C)
static

Definition at line 1089 of file paint_image.c.

References C, image_paint_poll_ignore_tool(), and vertex_paint_poll_ignore_tool().

Referenced by PAINT_OT_sample_color().

◆ sample_color_update_header()

static void sample_color_update_header ( SampleColorData data,
bContext C 
)
static

◆ set_imapaintpartial()

void set_imapaintpartial ( struct ImagePaintPartialRedraw ippr)

Definition at line 97 of file paint_image.c.

References imapaintpartial.

Referenced by project_image_refresh_tagged().

◆ texture_paint_init()

static PaintOperation* texture_paint_init ( bContext C,
wmOperator op,
const float  mouse[2] 
)
static

◆ texture_paint_poll()

static bool texture_paint_poll ( bContext C)
static

◆ texture_paint_toggle_exec()

static int texture_paint_toggle_exec ( bContext C,
wmOperator op 
)
static

◆ texture_paint_toggle_poll()

static bool texture_paint_toggle_poll ( bContext C)
static

◆ toggle_paint_cursor()

static void toggle_paint_cursor ( Scene scene,
bool  enable 
)
static

◆ vert_paint_poll()

bool vert_paint_poll ( bContext C)

Variable Documentation

◆ imapaintpartial

ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0}
static

This is a static resource for non-global access. Maybe it should be exposed as part of the paint operation, but for now just give a public interface.

Definition at line 90 of file paint_image.c.

Referenced by ED_imapaint_clear_partial_redraw(), ED_imapaint_dirty_region(), get_imapaintpartial(), imapaint_image_update(), and set_imapaintpartial().