Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_engine.c
| Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | void GPENCIL_cache_init(void *ved) | ||||
| GPENCIL_PassList *psl = vedata->psl; | GPENCIL_PassList *psl = vedata->psl; | ||||
| GPENCIL_TextureList *txl = vedata->txl; | GPENCIL_TextureList *txl = vedata->txl; | ||||
| GPENCIL_FramebufferList *fbl = vedata->fbl; | GPENCIL_FramebufferList *fbl = vedata->fbl; | ||||
| GPENCIL_PrivateData *pd = vedata->stl->pd; | GPENCIL_PrivateData *pd = vedata->stl->pd; | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| pd->cfra = (int)DEG_get_ctime(draw_ctx->depsgraph); | pd->cfra = (int)DEG_get_ctime(draw_ctx->depsgraph); | ||||
| pd->simplify_antialias = GPENCIL_SIMPLIFY_AA(draw_ctx->scene); | |||||
| #if 0 | |||||
| if (pd->is_render) { | |||||
| pd->anti_aliasing_mode = GPENCIL_AA_MODE_TAA; | |||||
| } | |||||
| else { | |||||
| if (GPENCIL_SIMPLIFY_AA(draw_ctx->scene)) { | |||||
| pd->anti_aliasing_mode = GPENCIL_AA_MODE_SIMPLIFIED; | |||||
| } | |||||
| else { | |||||
| pd->anti_aliasing_mode = GPENCIL_AA_MODE_SMAA; | |||||
| } | |||||
| } | |||||
| #else | |||||
| pd->anti_aliasing_mode = GPENCIL_AA_MODE_TAA; | |||||
| #endif | |||||
| pd->use_layer_fb = false; | pd->use_layer_fb = false; | ||||
| pd->use_object_fb = false; | pd->use_object_fb = false; | ||||
| pd->use_mask_fb = false; | pd->use_mask_fb = false; | ||||
| /* Always use high precision for render. */ | /* Always use high precision for render. */ | ||||
| pd->use_signed_fb = !pd->is_viewport; | pd->use_signed_fb = !pd->is_viewport; | ||||
| if (draw_ctx->v3d) { | if (draw_ctx->v3d) { | ||||
| const bool hide_overlay = ((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) != 0); | const bool hide_overlay = ((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) != 0); | ||||
| ▲ Show 20 Lines • Show All 705 Lines • ▼ Show 20 Lines | if (pd->snapshot_buffer_dirty) { | ||||
| pd->snapshot_buffer_dirty = false; | pd->snapshot_buffer_dirty = false; | ||||
| } | } | ||||
| /* Draw the sbuffer stroke(s). */ | /* Draw the sbuffer stroke(s). */ | ||||
| LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->sbuffer_tobjects) { | LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->sbuffer_tobjects) { | ||||
| GPENCIL_draw_object(vedata, ob); | GPENCIL_draw_object(vedata, ob); | ||||
| } | } | ||||
| } | } | ||||
| void GPENCIL_draw_scene(void *ved) | static void gpencil_draw_sample(void *ved) | ||||
| { | { | ||||
| GPENCIL_Data *vedata = (GPENCIL_Data *)ved; | GPENCIL_Data *vedata = (GPENCIL_Data *)ved; | ||||
| GPENCIL_PrivateData *pd = vedata->stl->pd; | GPENCIL_PrivateData *pd = vedata->stl->pd; | ||||
| GPENCIL_FramebufferList *fbl = vedata->fbl; | GPENCIL_FramebufferList *fbl = vedata->fbl; | ||||
| float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}; | float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}; | ||||
| /* Fade 3D objects. */ | /* Fade 3D objects. */ | ||||
| if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != NULL) && | if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != NULL) && | ||||
| Show All 30 Lines | static void gpencil_draw_sample(void *ved) | ||||
| if (pd->do_fast_drawing) { | if (pd->do_fast_drawing) { | ||||
| GPENCIL_fast_draw_end(vedata); | GPENCIL_fast_draw_end(vedata); | ||||
| } | } | ||||
| if (pd->scene_fb) { | if (pd->scene_fb) { | ||||
| GPENCIL_antialiasing_draw(vedata); | GPENCIL_antialiasing_draw(vedata); | ||||
| } | } | ||||
| } | |||||
| static void gpencil_draw_finish(void *ved) | |||||
| { | |||||
| GPENCIL_Data *vedata = (GPENCIL_Data *)ved; | |||||
| GPENCIL_PrivateData *pd = vedata->stl->pd; | |||||
| pd->gp_object_pool = pd->gp_layer_pool = pd->gp_vfx_pool = pd->gp_maskbit_pool = NULL; | pd->gp_object_pool = pd->gp_layer_pool = pd->gp_vfx_pool = pd->gp_maskbit_pool = NULL; | ||||
| /* Free temp stroke buffers. */ | /* Free temp stroke buffers. */ | ||||
| if (pd->sbuffer_gpd) { | if (pd->sbuffer_gpd) { | ||||
| DRW_cache_gpencil_sbuffer_clear(pd->obact); | DRW_cache_gpencil_sbuffer_clear(pd->obact); | ||||
| } | } | ||||
| } | } | ||||
| void GPENCIL_draw_scene(void *ved) | |||||
| { | |||||
| GPENCIL_Data *vedata = (GPENCIL_Data *)ved; | |||||
| GPENCIL_PrivateData *pd = vedata->stl->pd; | |||||
| if (pd->anti_aliasing_mode == GPENCIL_AA_MODE_TAA) { | |||||
| const int taa_samples_len = GPENCIL_antialiasing_sample_count_get(pd); | |||||
| pd->taa_sample_len = taa_samples_len; | |||||
| for (int taa_sample = 0; taa_sample < taa_samples_len; taa_sample++) { | |||||
| DRW_stats_group_start("TAA Sample"); | |||||
| pd->taa_sample = taa_sample; | |||||
| GPENCIL_antialiasing_setup(vedata); | |||||
| gpencil_draw_sample(ved); | |||||
| DRW_stats_group_end(); | |||||
| } | |||||
| } | |||||
| else { | |||||
| gpencil_draw_sample(ved); | |||||
| } | |||||
| gpencil_draw_finish(ved); | |||||
| } | |||||
| static void GPENCIL_engine_free(void) | static void GPENCIL_engine_free(void) | ||||
| { | { | ||||
| GPENCIL_shader_free(); | GPENCIL_shader_free(); | ||||
| } | } | ||||
| static const DrawEngineDataSize GPENCIL_data_size = DRW_VIEWPORT_DATA_SIZE(GPENCIL_Data); | static const DrawEngineDataSize GPENCIL_data_size = DRW_VIEWPORT_DATA_SIZE(GPENCIL_Data); | ||||
| DrawEngineType draw_engine_gpencil_type = { | DrawEngineType draw_engine_gpencil_type = { | ||||
| Show All 15 Lines | |||||