Cleanup: Remove unused grease pencil legacy draw cache
See #123468. Pull Request: https://projects.blender.org/blender/blender/pulls/129787
This commit is contained in:
@@ -80,9 +80,6 @@ void BKE_gpencil_free_layer_masks(struct bGPDlayer *gpl);
|
||||
*/
|
||||
void BKE_gpencil_tag(struct bGPdata *gpd);
|
||||
|
||||
void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
|
||||
void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
|
||||
|
||||
/**
|
||||
* Add a new gp-frame to the given layer.
|
||||
* \param gpl: Grease pencil layer
|
||||
@@ -294,9 +291,6 @@ void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGP
|
||||
*/
|
||||
void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene);
|
||||
|
||||
extern void (*BKE_gpencil_batch_cache_dirty_tag_cb)(struct bGPdata *gpd);
|
||||
extern void (*BKE_gpencil_batch_cache_free_cb)(struct bGPdata *gpd);
|
||||
|
||||
/**
|
||||
* Update original pointers in evaluated frame.
|
||||
* \param gpf_orig: Original grease-pencil frame.
|
||||
|
||||
@@ -293,27 +293,6 @@ IDTypeInfo IDType_ID_GD_LEGACY = {
|
||||
/*lib_override_apply_post*/ nullptr,
|
||||
};
|
||||
|
||||
/* ************************************************** */
|
||||
/* Draw Engine */
|
||||
|
||||
void (*BKE_gpencil_batch_cache_dirty_tag_cb)(bGPdata *gpd) = nullptr;
|
||||
void (*BKE_gpencil_batch_cache_free_cb)(bGPdata *gpd) = nullptr;
|
||||
|
||||
void BKE_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
|
||||
{
|
||||
if (gpd) {
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
|
||||
BKE_gpencil_batch_cache_dirty_tag_cb(gpd);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_gpencil_batch_cache_free(bGPdata *gpd)
|
||||
{
|
||||
if (gpd) {
|
||||
BKE_gpencil_batch_cache_free_cb(gpd);
|
||||
}
|
||||
}
|
||||
|
||||
/* ************************************************** */
|
||||
/* Memory Management */
|
||||
|
||||
@@ -454,7 +433,7 @@ void BKE_gpencil_free_legacy_palette_data(ListBase *list)
|
||||
BLI_listbase_clear(list);
|
||||
}
|
||||
|
||||
void BKE_gpencil_free_data(bGPdata *gpd, bool free_all)
|
||||
void BKE_gpencil_free_data(bGPdata *gpd, bool /*free_all*/)
|
||||
{
|
||||
/* free layers */
|
||||
BKE_gpencil_free_layers(&gpd->layers);
|
||||
@@ -464,12 +443,6 @@ void BKE_gpencil_free_data(bGPdata *gpd, bool free_all)
|
||||
MEM_SAFE_FREE(gpd->mat);
|
||||
|
||||
BLI_freelistN(&gpd->vertex_group_names);
|
||||
|
||||
/* free all data */
|
||||
if (free_all) {
|
||||
/* clear cache */
|
||||
BKE_gpencil_batch_cache_free(gpd);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_gpencil_tag(bGPdata *gpd)
|
||||
|
||||
@@ -76,7 +76,6 @@ set(SRC
|
||||
intern/draw_attributes.cc
|
||||
intern/draw_cache_impl_curve.cc
|
||||
intern/draw_cache_impl_curves.cc
|
||||
intern/draw_cache_impl_gpencil_legacy.cc
|
||||
intern/draw_cache_impl_grease_pencil.cc
|
||||
intern/draw_cache_impl_lattice.cc
|
||||
intern/draw_cache_impl_mesh.cc
|
||||
|
||||
@@ -266,12 +266,6 @@ typedef struct GPENCIL_PrivateData {
|
||||
|
||||
/* Active object. */
|
||||
Object *obact;
|
||||
/* Object being in draw mode. */
|
||||
struct bGPdata *sbuffer_gpd;
|
||||
/* Layer to append the temp stroke to. */
|
||||
struct bGPDlayer *sbuffer_layer;
|
||||
/* Temporary stroke currently being drawn. */
|
||||
struct bGPDstroke *sbuffer_stroke;
|
||||
/* List of temp objects containing the stroke. */
|
||||
struct {
|
||||
GPENCIL_tObject *first, *last;
|
||||
|
||||
@@ -236,9 +236,6 @@ void GPENCIL_cache_init(void *ved)
|
||||
}
|
||||
|
||||
{
|
||||
pd->sbuffer_stroke = nullptr;
|
||||
pd->sbuffer_gpd = nullptr;
|
||||
pd->sbuffer_layer = nullptr;
|
||||
pd->stroke_batch = nullptr;
|
||||
pd->fill_batch = nullptr;
|
||||
pd->do_fast_drawing = false;
|
||||
@@ -736,11 +733,6 @@ static void GPENCIL_draw_scene_depth_only(void *ved)
|
||||
}
|
||||
|
||||
pd->gp_object_pool = pd->gp_layer_pool = pd->gp_vfx_pool = pd->gp_maskbit_pool = nullptr;
|
||||
|
||||
/* Free temp stroke buffers. */
|
||||
if (pd->sbuffer_gpd) {
|
||||
DRW_cache_gpencil_sbuffer_clear(pd->obact);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpencil_draw_mask(GPENCIL_Data *vedata, GPENCIL_tObject *ob, GPENCIL_tLayer *layer)
|
||||
@@ -933,11 +925,6 @@ void GPENCIL_draw_scene(void *ved)
|
||||
}
|
||||
|
||||
pd->gp_object_pool = pd->gp_layer_pool = pd->gp_vfx_pool = pd->gp_maskbit_pool = nullptr;
|
||||
|
||||
/* Free temp stroke buffers. */
|
||||
if (pd->sbuffer_gpd) {
|
||||
DRW_cache_gpencil_sbuffer_clear(pd->obact);
|
||||
}
|
||||
}
|
||||
|
||||
static void GPENCIL_engine_free()
|
||||
|
||||
@@ -258,11 +258,6 @@ DRWVolumeGrid *DRW_volume_batch_cache_get_grid(Volume *volume,
|
||||
blender::gpu::Batch *DRW_cache_volume_face_wireframe_get(Object *ob);
|
||||
blender::gpu::Batch *DRW_cache_volume_selection_surface_get(Object *ob);
|
||||
|
||||
/**
|
||||
* Sbuffer batches are temporary. We need to clear it after drawing.
|
||||
*/
|
||||
void DRW_cache_gpencil_sbuffer_clear(Object *ob);
|
||||
|
||||
/* Grease Pencil */
|
||||
|
||||
blender::gpu::Batch *DRW_cache_grease_pencil_get(const Scene *scene, Object *ob);
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2020 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup draw
|
||||
*/
|
||||
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_gpencil_legacy_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_deform.hh"
|
||||
#include "BKE_gpencil_geom_legacy.h"
|
||||
#include "BKE_gpencil_legacy.h"
|
||||
|
||||
#include "DRW_engine.hh"
|
||||
#include "DRW_render.hh"
|
||||
|
||||
#include "ED_gpencil_legacy.hh"
|
||||
#include "GPU_batch.hh"
|
||||
|
||||
#include "DEG_depsgraph_query.hh"
|
||||
|
||||
#include "BLI_hash.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_polyfill_2d.h"
|
||||
|
||||
#include "draw_cache.hh"
|
||||
#include "draw_cache_impl.hh"
|
||||
|
||||
#include "../engines/gpencil/gpencil_defines.h"
|
||||
#include "../engines/gpencil/gpencil_shader_shared.h"
|
||||
|
||||
#define BEZIER_HANDLE (1 << 3)
|
||||
#define COLOR_SHIFT 5
|
||||
|
||||
struct GpencilBatchCache {
|
||||
/** Instancing Data */
|
||||
blender::gpu::VertBuf *vbo;
|
||||
blender::gpu::VertBuf *vbo_col;
|
||||
/** Indices in material order, then stroke order with fill first.
|
||||
* Strokes can be individually rendered using `gps->runtime.stroke_start` and
|
||||
* `gps->runtime.fill_start`. */
|
||||
blender::gpu::IndexBuf *ibo;
|
||||
/** Batches */
|
||||
blender::gpu::Batch *geom_batch;
|
||||
/** Stroke lines only */
|
||||
blender::gpu::Batch *lines_batch;
|
||||
|
||||
/** Edit Mode */
|
||||
blender::gpu::VertBuf *edit_vbo;
|
||||
blender::gpu::Batch *edit_lines_batch;
|
||||
blender::gpu::Batch *edit_points_batch;
|
||||
/** Edit Curve Mode */
|
||||
blender::gpu::VertBuf *edit_curve_vbo;
|
||||
blender::gpu::Batch *edit_curve_handles_batch;
|
||||
blender::gpu::Batch *edit_curve_points_batch;
|
||||
|
||||
/** Cache is dirty */
|
||||
bool is_dirty;
|
||||
};
|
||||
|
||||
namespace blender::draw {
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Utilities
|
||||
* \{ */
|
||||
|
||||
static void gpencil_batch_cache_clear(GpencilBatchCache *cache)
|
||||
{
|
||||
if (!cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->lines_batch);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->geom_batch);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->vbo);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->vbo_col);
|
||||
GPU_INDEXBUF_DISCARD_SAFE(cache->ibo);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->edit_lines_batch);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->edit_points_batch);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->edit_vbo);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->edit_curve_handles_batch);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->edit_curve_points_batch);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->edit_curve_vbo);
|
||||
|
||||
cache->is_dirty = true;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name BKE Callbacks
|
||||
* \{ */
|
||||
|
||||
void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
|
||||
{
|
||||
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
|
||||
}
|
||||
|
||||
void DRW_gpencil_batch_cache_free(bGPdata *gpd)
|
||||
{
|
||||
gpencil_batch_cache_clear(gpd->runtime.gpencil_cache);
|
||||
MEM_SAFE_FREE(gpd->runtime.gpencil_cache);
|
||||
gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/** \name Sbuffer stroke batches.
|
||||
* \{ */
|
||||
|
||||
void DRW_cache_gpencil_sbuffer_clear(Object *ob)
|
||||
{
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
MEM_SAFE_FREE(gpd->runtime.sbuffer_gps);
|
||||
GPU_BATCH_DISCARD_SAFE(gpd->runtime.sbuffer_batch);
|
||||
GPU_VERTBUF_DISCARD_SAFE(gpd->runtime.sbuffer_position_buf);
|
||||
GPU_VERTBUF_DISCARD_SAFE(gpd->runtime.sbuffer_color_buf);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::draw
|
||||
@@ -3106,9 +3106,6 @@ void DRW_engines_register()
|
||||
BKE_particle_batch_cache_dirty_tag_cb = DRW_particle_batch_cache_dirty_tag;
|
||||
BKE_particle_batch_cache_free_cb = DRW_particle_batch_cache_free;
|
||||
|
||||
BKE_gpencil_batch_cache_dirty_tag_cb = DRW_gpencil_batch_cache_dirty_tag;
|
||||
BKE_gpencil_batch_cache_free_cb = DRW_gpencil_batch_cache_free;
|
||||
|
||||
BKE_curves_batch_cache_dirty_tag_cb = DRW_curves_batch_cache_dirty_tag;
|
||||
BKE_curves_batch_cache_free_cb = DRW_curves_batch_cache_free;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user