Blender  V3.3
Classes | Macros
draw_cache_impl_gpencil.c File Reference
#include "DNA_curve_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_screen_types.h"
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_geom.h"
#include "DRW_engine.h"
#include "DRW_render.h"
#include "ED_gpencil.h"
#include "GPU_batch.h"
#include "DEG_depsgraph_query.h"
#include "BLI_hash.h"
#include "BLI_polyfill_2d.h"
#include "draw_cache.h"
#include "draw_cache_impl.h"
#include "../engines/gpencil/gpencil_defines.h"

Go to the source code of this file.

Classes

struct  GpencilBatchCache
 
struct  gpStrokeVert
 
struct  gpEditVert
 
struct  gpEditCurveVert
 
struct  gpColorVert
 
struct  gpIterData
 
struct  gpEditIterData
 
struct  gpEditCurveIterData
 

Macros

#define BEZIER_HANDLE   (1 << 3)
 
#define COLOR_SHIFT   5
 

Typedefs

Internal Types
typedef struct GpencilBatchCache GpencilBatchCache
 

Functions

Internal Utilities
static bool gpencil_batch_cache_valid (GpencilBatchCache *cache, bGPdata *gpd, int cfra)
 
static GpencilBatchCachegpencil_batch_cache_init (Object *ob, int cfra)
 
static void gpencil_batch_cache_clear (GpencilBatchCache *cache)
 
static GpencilBatchCachegpencil_batch_cache_get (Object *ob, int cfra)
 
BKE Callbacks
void DRW_gpencil_batch_cache_dirty_tag (bGPdata *gpd)
 
void DRW_gpencil_batch_cache_free (bGPdata *gpd)
 
Sbuffer stroke batches.
bGPDstrokeDRW_cache_gpencil_sbuffer_stroke_data_get (Object *ob)
 
static void gpencil_sbuffer_stroke_ensure (bGPdata *gpd, bool do_stroke, bool do_fill)
 
GPUBatchDRW_cache_gpencil_sbuffer_stroke_get (Object *ob)
 
GPUBatchDRW_cache_gpencil_sbuffer_fill_get (Object *ob)
 
void DRW_cache_gpencil_sbuffer_clear (Object *ob)
 

Edit GPencil Batches

#define GP_EDIT_POINT_SELECTED   (1 << 0)
 
#define GP_EDIT_STROKE_SELECTED   (1 << 1)
 
#define GP_EDIT_MULTIFRAME   (1 << 2)
 
#define GP_EDIT_STROKE_START   (1 << 3)
 
#define GP_EDIT_STROKE_END   (1 << 4)
 
#define GP_EDIT_POINT_DIMMED   (1 << 5)
 
typedef struct gpEditIterData gpEditIterData
 
typedef struct gpEditCurveIterData gpEditCurveIterData
 
static uint32_t gpencil_point_edit_flag (const bool layer_lock, const bGPDspoint *pt, int v, int v_len)
 
static float gpencil_point_edit_weight (const MDeformVert *dvert, int v, int vgindex)
 
static void gpencil_edit_stroke_iter_cb (bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, void *thunk)
 
static void gpencil_edit_curve_stroke_count_cb (bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps, void *thunk)
 
static uint32_t gpencil_beztriple_vflag_get (char flag, char col_id, bool handle_point, const bool handle_selected)
 
static void gpencil_edit_curve_stroke_iter_cb (bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps, void *thunk)
 
static void gpencil_edit_batches_ensure (Object *ob, GpencilBatchCache *cache, int cfra)
 
GPUBatchDRW_cache_gpencil_edit_lines_get (Object *ob, int cfra)
 
GPUBatchDRW_cache_gpencil_edit_points_get (Object *ob, int cfra)
 
GPUBatchDRW_cache_gpencil_edit_curve_handles_get (Object *ob, int cfra)
 
GPUBatchDRW_cache_gpencil_edit_curve_points_get (Object *ob, int cfra)
 
int DRW_gpencil_material_count_get (bGPdata *gpd)
 

Vertex Formats

typedef struct gpStrokeVert gpStrokeVert
 
typedef struct gpEditVert gpEditVert
 
typedef struct gpEditCurveVert gpEditCurveVert
 
typedef struct gpColorVert gpColorVert
 
static GPUVertFormatgpencil_stroke_format (void)
 
static GPUVertFormatgpencil_edit_stroke_format (void)
 
static GPUVertFormatgpencil_edit_curve_format (void)
 
static GPUVertFormatgpencil_color_format (void)
 

Vertex Buffers

typedef struct gpIterData gpIterData
 
static GPUVertBufgpencil_dummy_buffer_get (void)
 
static int gpencil_stroke_is_cyclic (const bGPDstroke *gps)
 
BLI_INLINE int32_t pack_rotation_aspect_hardness (float rot, float asp, float hard)
 
static void gpencil_buffer_add_point (gpStrokeVert *verts, gpColorVert *cols, const bGPDstroke *gps, const bGPDspoint *pt, int v, bool is_endpoint)
 
static void gpencil_buffer_add_stroke (gpStrokeVert *verts, gpColorVert *cols, const bGPDstroke *gps)
 
static void gpencil_buffer_add_fill (GPUIndexBufBuilder *ibo, const bGPDstroke *gps)
 
static void gpencil_stroke_iter_cb (bGPDlayer *UNUSED(gpl), bGPDframe *UNUSED(gpf), bGPDstroke *gps, void *thunk)
 
static void gpencil_object_verts_count_cb (bGPDlayer *UNUSED(gpl), bGPDframe *UNUSED(gpf), bGPDstroke *gps, void *thunk)
 
static void gpencil_batches_ensure (Object *ob, GpencilBatchCache *cache, int cfra)
 
GPUBatchDRW_cache_gpencil_strokes_get (Object *ob, int cfra)
 
GPUBatchDRW_cache_gpencil_fills_get (Object *ob, int cfra)
 
static void gpencil_lines_indices_cb (bGPDlayer *UNUSED(gpl), bGPDframe *UNUSED(gpf), bGPDstroke *gps, void *thunk)
 
GPUBatchDRW_cache_gpencil_face_wireframe_get (Object *ob)
 

Macro Definition Documentation

◆ BEZIER_HANDLE

#define BEZIER_HANDLE   (1 << 3)

Definition at line 33 of file draw_cache_impl_gpencil.c.

◆ COLOR_SHIFT

#define COLOR_SHIFT   5

Definition at line 34 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_MULTIFRAME

#define GP_EDIT_MULTIFRAME   (1 << 2)

Definition at line 691 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_POINT_DIMMED

#define GP_EDIT_POINT_DIMMED   (1 << 5)

Definition at line 694 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_POINT_SELECTED

#define GP_EDIT_POINT_SELECTED   (1 << 0)

Definition at line 689 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_STROKE_END

#define GP_EDIT_STROKE_END   (1 << 4)

Definition at line 693 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_STROKE_SELECTED

#define GP_EDIT_STROKE_SELECTED   (1 << 1)

Definition at line 690 of file draw_cache_impl_gpencil.c.

◆ GP_EDIT_STROKE_START

#define GP_EDIT_STROKE_START   (1 << 3)

Definition at line 692 of file draw_cache_impl_gpencil.c.

Typedef Documentation

◆ gpColorVert

typedef struct gpColorVert gpColorVert

◆ gpEditCurveIterData

◆ gpEditCurveVert

◆ gpEditIterData

◆ gpEditVert

typedef struct gpEditVert gpEditVert

◆ GpencilBatchCache

◆ gpIterData

typedef struct gpIterData gpIterData

◆ gpStrokeVert

typedef struct gpStrokeVert gpStrokeVert

Function Documentation

◆ DRW_cache_gpencil_edit_curve_handles_get()

GPUBatch* DRW_cache_gpencil_edit_curve_handles_get ( Object ob,
int  cfra 
)

◆ DRW_cache_gpencil_edit_curve_points_get()

GPUBatch* DRW_cache_gpencil_edit_curve_points_get ( Object ob,
int  cfra 
)

◆ DRW_cache_gpencil_edit_lines_get()

GPUBatch* DRW_cache_gpencil_edit_lines_get ( Object ob,
int  cfra 
)

◆ DRW_cache_gpencil_edit_points_get()

GPUBatch* DRW_cache_gpencil_edit_points_get ( Object ob,
int  cfra 
)

◆ DRW_cache_gpencil_face_wireframe_get()

GPUBatch* DRW_cache_gpencil_face_wireframe_get ( Object ob)

◆ DRW_cache_gpencil_fills_get()

GPUBatch* DRW_cache_gpencil_fills_get ( Object ob,
int  cfra 
)

◆ DRW_cache_gpencil_sbuffer_clear()

void DRW_cache_gpencil_sbuffer_clear ( struct Object ob)

◆ DRW_cache_gpencil_sbuffer_fill_get()

GPUBatch* DRW_cache_gpencil_sbuffer_fill_get ( Object ob)

◆ DRW_cache_gpencil_sbuffer_stroke_data_get()

bGPDstroke* DRW_cache_gpencil_sbuffer_stroke_data_get ( Object ob)

◆ DRW_cache_gpencil_sbuffer_stroke_get()

GPUBatch* DRW_cache_gpencil_sbuffer_stroke_get ( Object ob)

◆ DRW_cache_gpencil_strokes_get()

GPUBatch* DRW_cache_gpencil_strokes_get ( Object ob,
int  cfra 
)

◆ DRW_gpencil_batch_cache_dirty_tag()

void DRW_gpencil_batch_cache_dirty_tag ( bGPdata gpd)

Definition at line 155 of file draw_cache_impl_gpencil.c.

References bGPdata::flag, and GP_DATA_CACHE_IS_DIRTY.

Referenced by DRW_engines_register().

◆ DRW_gpencil_batch_cache_free()

void DRW_gpencil_batch_cache_free ( bGPdata gpd)

◆ DRW_gpencil_material_count_get()

int DRW_gpencil_material_count_get ( bGPdata gpd)

Definition at line 957 of file draw_cache_impl_gpencil.c.

References max_ii(), and bGPdata::totcol.

Referenced by DRW_cache_object_material_count_get().

◆ gpencil_batch_cache_clear()

static void gpencil_batch_cache_clear ( GpencilBatchCache cache)
static

◆ gpencil_batch_cache_get()

static GpencilBatchCache* gpencil_batch_cache_get ( Object ob,
int  cfra 
)
static

◆ gpencil_batch_cache_init()

static GpencilBatchCache* gpencil_batch_cache_init ( Object ob,
int  cfra 
)
static

◆ gpencil_batch_cache_valid()

static bool gpencil_batch_cache_valid ( GpencilBatchCache cache,
bGPdata gpd,
int  cfra 
)
static

◆ gpencil_batches_ensure()

static void gpencil_batches_ensure ( Object ob,
GpencilBatchCache cache,
int  cfra 
)
static

◆ gpencil_beztriple_vflag_get()

static uint32_t gpencil_beztriple_vflag_get ( char  flag,
char  col_id,
bool  handle_point,
const bool  handle_selected 
)
static

◆ gpencil_buffer_add_fill()

static void gpencil_buffer_add_fill ( GPUIndexBufBuilder ibo,
const bGPDstroke gps 
)
static

◆ gpencil_buffer_add_point()

static void gpencil_buffer_add_point ( gpStrokeVert verts,
gpColorVert cols,
const bGPDstroke gps,
const bGPDspoint pt,
int  v,
bool  is_endpoint 
)
static

◆ gpencil_buffer_add_stroke()

static void gpencil_buffer_add_stroke ( gpStrokeVert verts,
gpColorVert cols,
const bGPDstroke gps 
)
static

◆ gpencil_color_format()

static GPUVertFormat* gpencil_color_format ( void  )
static

◆ gpencil_dummy_buffer_get()

static GPUVertBuf* gpencil_dummy_buffer_get ( void  )
static

◆ gpencil_edit_batches_ensure()

static void gpencil_edit_batches_ensure ( Object ob,
GpencilBatchCache cache,
int  cfra 
)
static

◆ gpencil_edit_curve_format()

static GPUVertFormat* gpencil_edit_curve_format ( void  )
static

◆ gpencil_edit_curve_stroke_count_cb()

static void gpencil_edit_curve_stroke_count_cb ( bGPDlayer gpl,
bGPDframe UNUSEDgpf,
bGPDstroke gps,
void thunk 
)
static

◆ gpencil_edit_curve_stroke_iter_cb()

static void gpencil_edit_curve_stroke_iter_cb ( bGPDlayer gpl,
bGPDframe UNUSEDgpf,
bGPDstroke gps,
void thunk 
)
static

◆ gpencil_edit_stroke_format()

static GPUVertFormat* gpencil_edit_stroke_format ( void  )
static

◆ gpencil_edit_stroke_iter_cb()

static void gpencil_edit_stroke_iter_cb ( bGPDlayer gpl,
bGPDframe gpf,
bGPDstroke gps,
void thunk 
)
static

◆ gpencil_lines_indices_cb()

static void gpencil_lines_indices_cb ( bGPDlayer UNUSEDgpl,
bGPDframe UNUSEDgpf,
bGPDstroke gps,
void thunk 
)
static

◆ gpencil_object_verts_count_cb()

static void gpencil_object_verts_count_cb ( bGPDlayer UNUSEDgpl,
bGPDframe UNUSEDgpf,
bGPDstroke gps,
void thunk 
)
static

◆ gpencil_point_edit_flag()

static uint32_t gpencil_point_edit_flag ( const bool  layer_lock,
const bGPDspoint pt,
int  v,
int  v_len 
)
static

◆ gpencil_point_edit_weight()

static float gpencil_point_edit_weight ( const MDeformVert dvert,
int  v,
int  vgindex 
)
static

Definition at line 719 of file draw_cache_impl_gpencil.c.

References BKE_defvert_find_weight(), and v.

Referenced by gpencil_edit_stroke_iter_cb().

◆ gpencil_sbuffer_stroke_ensure()

static void gpencil_sbuffer_stroke_ensure ( bGPdata gpd,
bool  do_stroke,
bool  do_fill 
)
static

◆ gpencil_stroke_format()

static GPUVertFormat* gpencil_stroke_format ( void  )
static

◆ gpencil_stroke_is_cyclic()

static int gpencil_stroke_is_cyclic ( const bGPDstroke gps)
static

◆ gpencil_stroke_iter_cb()

static void gpencil_stroke_iter_cb ( bGPDlayer UNUSEDgpl,
bGPDframe UNUSEDgpf,
bGPDstroke gps,
void thunk 
)
static

◆ pack_rotation_aspect_hardness()

BLI_INLINE int32_t pack_rotation_aspect_hardness ( float  rot,
float  asp,
float  hard 
)

Definition at line 275 of file draw_cache_impl_gpencil.c.

References cosf, rot, and unit_float_to_uchar_clamp().

Referenced by gpencil_buffer_add_point().