Blender V4.3
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_math_vector.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#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 "DNA_scene_types.h"
#include "BKE_brush.hh"
#include "BKE_colorband.hh"
#include "BKE_context.hh"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_image.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mesh.hh"
#include "BKE_node_runtime.hh"
#include "BKE_object.hh"
#include "BKE_paint.hh"
#include "BKE_scene.hh"
#include "NOD_texture.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "UI_interface.hh"
#include "UI_view2d.hh"
#include "ED_grease_pencil.hh"
#include "ED_image.hh"
#include "ED_object.hh"
#include "ED_paint.hh"
#include "ED_screen.hh"
#include "WM_api.hh"
#include "WM_message.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "IMB_colormanagement.hh"
#include "paint_intern.hh"

Go to the source code of this file.

Classes

struct  GrabClone
 
struct  SampleColorData
 

Functions

Image Paint Blur
BlurKernelpaint_new_blur_kernel (Brush *br, bool proj)
 
void paint_delete_blur_kernel (BlurKernel *kernel)
 
Image Paint Poll
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)
 
Paint Operator
bool paint_use_opacity_masking (Brush *brush)
 
void paint_brush_color_get (Scene *scene, const Paint *paint, Brush *br, bool color_correction, bool invert, float distance, float pressure, ColorManagedDisplay *display, float r_color[3])
 
void paint_brush_init_tex (Brush *brush)
 
void paint_brush_exit_tex (Brush *brush)
 
bool get_imapaint_zoom (bContext *C, float *zoomx, float *zoomy)
 
Cursor Drawing
static void toggle_paint_cursor (Scene &scene, bool enable)
 
void ED_space_image_paint_update (Main *bmain, wmWindowManager *wm, Scene *scene)
 
Grab Clone Operator
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 *, wmOperator *op)
 
void PAINT_OT_grab_clone (wmOperatorType *ot)
 
Sample Color Operator
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)
 
Texture Paint Toggle Operator
static blender::float3 paint_init_pivot_mesh (Object *ob)
 
static blender::float3 paint_init_pivot_curves (Object *ob)
 
static blender::float3 paint_init_pivot_grease_pencil (Object *ob, const int frame)
 
void paint_init_pivot (Object *ob, Scene *scene)
 
void ED_object_texture_paint_mode_enter_ex (Main &bmain, Scene &scene, Depsgraph &depsgraph, 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)
 
Brush Color Flip Operator
static int brush_colors_flip_exec (bContext *C, wmOperator *)
 
static bool brush_colors_flip_poll (bContext *C)
 
void PAINT_OT_brush_colors_flip (wmOperatorType *ot)
 
Texture Paint Bucket Fill Operator
void ED_imapaint_bucket_fill (bContext *C, float const 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)
 

Image Paint Tile Utilities (Partial Update)

static ImagePaintPartialRedraw imapaintpartial = {{0}}
 
ImagePaintPartialRedrawget_imapaintpartial ()
 
void set_imapaintpartial (ImagePaintPartialRedraw *ippr)
 
void ED_imapaint_clear_partial_redraw ()
 
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)
 

Detailed Description

Functions to paint images in 2D and 3D.

Definition in file paint_image.cc.

Function Documentation

◆ brush_colors_flip_exec()

◆ brush_colors_flip_poll()

◆ ED_image_tools_paint_poll()

◆ ED_imapaint_bucket_fill()

◆ ED_imapaint_clear_partial_redraw()

◆ ED_imapaint_dirty_region()

◆ ED_object_texture_paint_mode_enter()

void ED_object_texture_paint_mode_enter ( bContext * C)

◆ ED_object_texture_paint_mode_enter_ex()

◆ ED_object_texture_paint_mode_exit()

void ED_object_texture_paint_mode_exit ( bContext * C)

◆ ED_object_texture_paint_mode_exit_ex()

◆ ED_space_image_paint_update()

void ED_space_image_paint_update ( Main * bmain,
wmWindowManager * wm,
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 476 of file paint_image.cc.

References BKE_paint_init(), ED_image_tools_paint_poll(), ED_paint_cursor_start(), LISTBASE_FOREACH, ImagePaintSettings::paint, paint_cursor_delete_textures(), PAINT_CURSOR_TEXTURE_PAINT, SI_MODE_PAINT, SPACE_IMAGE, Texture2D, wmWindowManager::windows, and WM_window_get_active_screen().

Referenced by ED_editors_init().

◆ facemask_paint_poll()

◆ get_imapaint_zoom()

◆ get_imapaintpartial()

ImagePaintPartialRedraw * get_imapaintpartial ( )

Definition at line 84 of file paint_image.cc.

References imapaintpartial.

◆ grab_clone_apply()

◆ grab_clone_cancel()

static void grab_clone_cancel ( bContext * ,
wmOperator * op )
static

Definition at line 583 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 526 of file paint_image.cc.

References grab_clone_apply(), and OPERATOR_FINISHED.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_invoke()

◆ grab_clone_modal()

◆ image_paint_2d_clone_poll()

◆ image_paint_brush()

◆ image_paint_poll_ex()

◆ image_paint_poll_ignore_tool()

static bool image_paint_poll_ignore_tool ( bContext * C)
static

Definition at line 322 of file paint_image.cc.

References image_paint_poll_ex().

Referenced by sample_color_poll().

◆ image_texture_paint_poll()

bool image_texture_paint_poll ( bContext * C)

Definition at line 1129 of file paint_image.cc.

References ED_image_tools_paint_poll(), and texture_paint_poll().

Referenced by ED_keymap_paint().

◆ imapaint_image_update()

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

References ED_IMAGE_UNDO_TILE_BITS, IMB_rectclip(), and w().

Referenced by ED_imapaint_dirty_region(), and paint_2d_op().

◆ mask_paint_poll()

bool mask_paint_poll ( bContext * C)

Definition at line 1144 of file paint_image.cc.

References BKE_paint_select_elem_test(), and CTX_data_active_object().

◆ paint_brush_color_get()

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

References MEM_freeN(), and BlurKernel::wdata.

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

◆ paint_init_pivot()

◆ paint_init_pivot_curves()

static blender::float3 paint_init_pivot_curves ( Object * ob)
static

Definition at line 824 of file paint_image.cc.

References bounds(), Object::data, and blender::math::midpoint().

Referenced by paint_init_pivot().

◆ paint_init_pivot_grease_pencil()

static blender::float3 paint_init_pivot_grease_pencil ( Object * ob,
const int frame )
static

Definition at line 835 of file paint_image.cc.

References bounds(), Object::data, and blender::math::midpoint().

Referenced by paint_init_pivot().

◆ paint_init_pivot_mesh()

static blender::float3 paint_init_pivot_mesh ( Object * ob)
static

◆ paint_new_blur_kernel()

BlurKernel * paint_new_blur_kernel ( 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 192 of file paint_image.cc.

References Brush::blur_kernel_radius, Brush::blur_mode, exp(), KERNEL_BOX, KERNEL_GAUSSIAN, MEM_mallocN, paint_delete_blur_kernel(), BlurKernel::pixel_len, printf, BlurKernel::side, BlurKernel::side_squared, and BlurKernel::wdata.

Referenced by paint_2d_new_stroke(), and project_state_init().

◆ PAINT_OT_brush_colors_flip()

◆ PAINT_OT_grab_clone()

◆ PAINT_OT_sample_color()

◆ PAINT_OT_texture_paint_toggle()

◆ paint_use_opacity_masking()

◆ sample_color_exec()

◆ sample_color_invoke()

◆ sample_color_modal()

◆ sample_color_poll()

static bool sample_color_poll ( bContext * C)
static

◆ sample_color_update_header()

static void sample_color_update_header ( SampleColorData * data,
bContext * C )
static

◆ set_imapaintpartial()

void set_imapaintpartial ( ImagePaintPartialRedraw * ippr)

Definition at line 89 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()

◆ texture_paint_toggle_poll()

static bool texture_paint_toggle_poll ( bContext * C)
static

◆ toggle_paint_cursor()

◆ vert_paint_poll()

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

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