diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/draw/engines/external/external_engine.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/draw/engines/external/external_engine.c')
-rw-r--r-- | source/blender/draw/engines/external/external_engine.c | 237 |
1 files changed, 124 insertions, 113 deletions
diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index c1da7c4585c..29749ce6712 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -34,7 +34,7 @@ #include "GPU_shader.h" #include "GPU_viewport.h" -#include "external_engine.h" /* own include */ +#include "external_engine.h" /* own include */ /* Shaders */ @@ -45,87 +45,88 @@ /* GPUViewport.storage * Is freed everytime the viewport engine changes */ typedef struct EXTERNAL_Storage { - int dummy; + int dummy; } EXTERNAL_Storage; typedef struct EXTERNAL_StorageList { - struct EXTERNAL_Storage *storage; - struct EXTERNAL_PrivateData *g_data; + struct EXTERNAL_Storage *storage; + struct EXTERNAL_PrivateData *g_data; } EXTERNAL_StorageList; typedef struct EXTERNAL_FramebufferList { - struct GPUFrameBuffer *default_fb; + struct GPUFrameBuffer *default_fb; } EXTERNAL_FramebufferList; typedef struct EXTERNAL_TextureList { - /* default */ - struct GPUTexture *depth; + /* default */ + struct GPUTexture *depth; } EXTERNAL_TextureList; typedef struct EXTERNAL_PassList { - struct DRWPass *depth_pass; + struct DRWPass *depth_pass; } EXTERNAL_PassList; typedef struct EXTERNAL_Data { - void *engine_type; - EXTERNAL_FramebufferList *fbl; - EXTERNAL_TextureList *txl; - EXTERNAL_PassList *psl; - EXTERNAL_StorageList *stl; - char info[GPU_INFO_SIZE]; + void *engine_type; + EXTERNAL_FramebufferList *fbl; + EXTERNAL_TextureList *txl; + EXTERNAL_PassList *psl; + EXTERNAL_StorageList *stl; + char info[GPU_INFO_SIZE]; } EXTERNAL_Data; /* *********** STATIC *********** */ static struct { - /* Depth Pre Pass */ - struct GPUShader *depth_sh; + /* Depth Pre Pass */ + struct GPUShader *depth_sh; } e_data = {NULL}; /* Engine data */ typedef struct EXTERNAL_PrivateData { - DRWShadingGroup *depth_shgrp; + DRWShadingGroup *depth_shgrp; } EXTERNAL_PrivateData; /* Transient data */ /* Functions */ static void external_engine_init(void *UNUSED(vedata)) { - /* Depth prepass */ - if (!e_data.depth_sh) { - e_data.depth_sh = DRW_shader_create_3d_depth_only(GPU_SHADER_CFG_DEFAULT); - } + /* Depth prepass */ + if (!e_data.depth_sh) { + e_data.depth_sh = DRW_shader_create_3d_depth_only(GPU_SHADER_CFG_DEFAULT); + } } static void external_cache_init(void *vedata) { - EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; - EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; - - if (!stl->g_data) { - /* Alloc transient pointers */ - stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); - } - - /* Depth Pass */ - { - psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); - stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass); - } + EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; + EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; + + if (!stl->g_data) { + /* Alloc transient pointers */ + stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); + } + + /* Depth Pass */ + { + psl->depth_pass = DRW_pass_create("Depth Pass", + DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); + stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass); + } } static void external_cache_populate(void *vedata, Object *ob) { - EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; + EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; - if (!DRW_object_is_renderable(ob)) { - return; - } + if (!DRW_object_is_renderable(ob)) { + return; + } - struct GPUBatch *geom = DRW_cache_object_surface_get(ob); - if (geom) { - /* Depth Prepass */ - DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat); - } + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); + if (geom) { + /* Depth Prepass */ + DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat); + } } static void external_cache_finish(void *UNUSED(vedata)) @@ -134,94 +135,104 @@ static void external_cache_finish(void *UNUSED(vedata)) static void external_draw_scene_do(void *vedata) { - const DRWContextState *draw_ctx = DRW_context_state_get(); - Scene *scene = draw_ctx->scene; - RegionView3D *rv3d = draw_ctx->rv3d; - ARegion *ar = draw_ctx->ar; - RenderEngineType *type; - - DRW_state_reset_ex(DRW_STATE_DEFAULT & ~DRW_STATE_DEPTH_LESS_EQUAL); - - /* Create render engine. */ - if (!rv3d->render_engine) { - RenderEngineType *engine_type = draw_ctx->engine_type; - - if (!(engine_type->view_update && engine_type->view_draw)) { - return; - } - - RenderEngine *engine = RE_engine_create_ex(engine_type, true); - engine->tile_x = scene->r.tilex; - engine->tile_y = scene->r.tiley; - engine_type->view_update(engine, draw_ctx->evil_C); - rv3d->render_engine = engine; - } - - /* Rendered draw. */ - GPU_matrix_push_projection(); - ED_region_pixelspace(ar); - - /* Render result draw. */ - type = rv3d->render_engine->type; - type->view_draw(rv3d->render_engine, draw_ctx->evil_C); - - GPU_matrix_pop_projection(); - - /* Set render info. */ - EXTERNAL_Data *data = vedata; - if (rv3d->render_engine->text[0] != '\0') { - BLI_strncpy(data->info, rv3d->render_engine->text, sizeof(data->info)); - } - else { - data->info[0] = '\0'; - } + const DRWContextState *draw_ctx = DRW_context_state_get(); + Scene *scene = draw_ctx->scene; + RegionView3D *rv3d = draw_ctx->rv3d; + ARegion *ar = draw_ctx->ar; + RenderEngineType *type; + + DRW_state_reset_ex(DRW_STATE_DEFAULT & ~DRW_STATE_DEPTH_LESS_EQUAL); + + /* Create render engine. */ + if (!rv3d->render_engine) { + RenderEngineType *engine_type = draw_ctx->engine_type; + + if (!(engine_type->view_update && engine_type->view_draw)) { + return; + } + + RenderEngine *engine = RE_engine_create_ex(engine_type, true); + engine->tile_x = scene->r.tilex; + engine->tile_y = scene->r.tiley; + engine_type->view_update(engine, draw_ctx->evil_C); + rv3d->render_engine = engine; + } + + /* Rendered draw. */ + GPU_matrix_push_projection(); + ED_region_pixelspace(ar); + + /* Render result draw. */ + type = rv3d->render_engine->type; + type->view_draw(rv3d->render_engine, draw_ctx->evil_C); + + GPU_matrix_pop_projection(); + + /* Set render info. */ + EXTERNAL_Data *data = vedata; + if (rv3d->render_engine->text[0] != '\0') { + BLI_strncpy(data->info, rv3d->render_engine->text, sizeof(data->info)); + } + else { + data->info[0] = '\0'; + } } static void external_draw_scene(void *vedata) { - const DRWContextState *draw_ctx = DRW_context_state_get(); - EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; - - /* Will be NULL during OpenGL render. - * OpenGL render is used for quick preview (thumbnails or sequencer preview) - * where using the rendering engine to preview doesn't make so much sense. */ - if (draw_ctx->evil_C) { - external_draw_scene_do(vedata); - } - DRW_draw_pass(psl->depth_pass); + const DRWContextState *draw_ctx = DRW_context_state_get(); + EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; + + /* Will be NULL during OpenGL render. + * OpenGL render is used for quick preview (thumbnails or sequencer preview) + * where using the rendering engine to preview doesn't make so much sense. */ + if (draw_ctx->evil_C) { + external_draw_scene_do(vedata); + } + DRW_draw_pass(psl->depth_pass); } static void external_engine_free(void) { - /* All shaders are builtin. */ + /* All shaders are builtin. */ } static const DrawEngineDataSize external_data_size = DRW_VIEWPORT_DATA_SIZE(EXTERNAL_Data); static DrawEngineType draw_engine_external_type = { - NULL, NULL, - N_("External"), - &external_data_size, - &external_engine_init, - &external_engine_free, - &external_cache_init, - &external_cache_populate, - &external_cache_finish, - NULL, - &external_draw_scene, - NULL, - NULL, - NULL, + NULL, + NULL, + N_("External"), + &external_data_size, + &external_engine_init, + &external_engine_free, + &external_cache_init, + &external_cache_populate, + &external_cache_finish, + NULL, + &external_draw_scene, + NULL, + NULL, + NULL, }; /* Note: currently unused, we should not register unless we want to see this when debugging the view. */ RenderEngineType DRW_engine_viewport_external_type = { - NULL, NULL, - EXTERNAL_ENGINE, N_("External"), RE_INTERNAL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - &draw_engine_external_type, - {NULL, NULL, NULL}, + NULL, + NULL, + EXTERNAL_ENGINE, + N_("External"), + RE_INTERNAL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &draw_engine_external_type, + {NULL, NULL, NULL}, }; #undef EXTERNAL_ENGINE |