Blender  V3.3
Classes | Functions | Variables
paint_image.cc File Reference

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

#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#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 "NOD_texture.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  GrabClone
 
struct  SampleColorData
 

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)
 
bool ED_image_tools_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)
 
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}}
 

Detailed Description

Functions to paint images in 2D and 3D.

Definition in file paint_image.cc.

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_image_tools_paint_poll()

bool ED_image_tools_paint_poll ( bContext C)

◆ 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 ( struct Main bmain,
struct wmWindowManager wm,
struct Scene scene 
)

Enable the paint cursor if it isn't already.

purpose is to make sure the paint cursor is shown if paint mode is enabled in the image editor. The paint poll will ensure that the cursor is hidden when not in paint mode.

Definition at line 438 of file paint_image.cc.

References blender::compositor::area(), bScreen::areabase, BKE_paint_init(), ED_image_tools_paint_poll(), ED_paint_cursor_start(), enabled, ToolSettings::imapaint, LISTBASE_FOREACH, ImagePaintSettings::paint, paint_cursor_delete_textures(), PAINT_CURSOR_TEXTURE_PAINT, PAINT_MODE_TEXTURE_2D, scene, SI_MODE_PAINT, SPACE_IMAGE, Scene::toolsettings, wmWindowManager::windows, and WM_window_get_active_screen().

Referenced by ED_editors_init().

◆ 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 79 of file paint_image.cc.

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 539 of file paint_image.cc.

References wmOperator::customdata.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_exec()

static int grab_clone_exec ( bContext C,
wmOperator op 
)
static

Definition at line 483 of file paint_image.cc.

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

◆ 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_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 296 of file paint_image.cc.

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 993 of file paint_image.cc.

References C, ED_image_tools_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 96 of file paint_image.cc.

References ED_IMAGE_UNDO_TILE_BITS, IMB_rectclip(), 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 1008 of file paint_image.cc.

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 240 of file paint_image.cc.

References kernel, and MEM_freeN.

Referenced by paint_2d_canvas_free(), paint_new_blur_kernel(), and project_paint_end().

◆ paint_new_blur_kernel()

BlurKernel* paint_new_blur_kernel ( struct Brush br,
bool  proj 
)

Paint blur kernels. Projective painting enforces use of a 2x2 kernel due to lagging. Can be extended to other blur kernels later,

Definition at line 171 of file paint_image.cc.

References Brush::blur_kernel_radius, Brush::blur_mode, exp(), kernel, KERNEL_BOX, KERNEL_GAUSSIAN, MEM_mallocN, paint_delete_blur_kernel(), and type.

Referenced by paint_2d_new_stroke(), and project_state_init().

◆ 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_sample_color()

void PAINT_OT_sample_color ( wmOperatorType ot)

◆ PAINT_OT_texture_paint_toggle()

void PAINT_OT_texture_paint_toggle ( wmOperatorType ot)

◆ 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 721 of file paint_image.cc.

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 84 of file paint_image.cc.

References imapaintpartial.

Referenced by project_image_refresh_tagged().

◆ 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}}
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 77 of file paint_image.cc.

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