From a18d88213fbf0d123c254643e220f3db82f1f7b6 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 31 Aug 2021 12:20:28 +0200 Subject: Cleanup: Converted draw_color_management to CPP. --- source/blender/draw/CMakeLists.txt | 2 +- source/blender/draw/intern/draw_cache.h | 8 +++ source/blender/draw/intern/draw_color_management.c | 63 ---------------------- .../blender/draw/intern/draw_color_management.cc | 63 ++++++++++++++++++++++ source/blender/draw/intern/draw_color_management.h | 8 +++ source/blender/draw/intern/draw_manager.h | 8 +++ 6 files changed, 88 insertions(+), 64 deletions(-) delete mode 100644 source/blender/draw/intern/draw_color_management.c create mode 100644 source/blender/draw/intern/draw_color_management.cc (limited to 'source') diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 257eb80ae0b..8bf74dae7f8 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -91,7 +91,7 @@ set(SRC intern/draw_cache_impl_particles.c intern/draw_cache_impl_pointcloud.c intern/draw_cache_impl_volume.c - intern/draw_color_management.c + intern/draw_color_management.cc intern/draw_common.c intern/draw_debug.c intern/draw_fluid.c diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index c58dd85b6ed..6b2b0a173fe 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -22,6 +22,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + struct GPUBatch; struct GPUMaterial; struct ModifierData; @@ -263,3 +267,7 @@ struct GPUBatch *DRW_cache_gpencil_face_wireframe_get(struct Object *ob); struct bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(struct Object *ob); void DRW_cache_gpencil_sbuffer_clear(struct Object *ob); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/draw/intern/draw_color_management.c b/source/blender/draw/intern/draw_color_management.c deleted file mode 100644 index bd851dc4ba7..00000000000 --- a/source/blender/draw/intern/draw_color_management.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2020, Blender Foundation. - */ - -/** \file - * \ingroup draw - */ - -#include - -#include "draw_manager.h" - -#include "DRW_render.h" - -#include "GPU_batch.h" -#include "GPU_framebuffer.h" -#include "GPU_matrix.h" -#include "GPU_texture.h" - -#include "BKE_colortools.h" - -#include "IMB_colormanagement.h" - -#include "draw_color_management.h" - -/* -------------------------------------------------------------------- */ -/** \name Color Management - * \{ */ - -/* Draw texture to framebuffer without any color transforms */ -void DRW_transform_none(GPUTexture *tex) -{ - drw_state_set(DRW_STATE_WRITE_COLOR); - - GPU_matrix_identity_set(); - GPU_matrix_identity_projection_set(); - - /* Draw as texture for final render (without immediate mode). */ - GPUBatch *geom = DRW_cache_fullscreen_quad_get(); - GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); - GPU_batch_uniform_4f(geom, "color", 1.0f, 1.0f, 1.0f, 1.0f); - GPU_batch_texture_bind(geom, "image", tex); - - GPU_batch_draw(geom); - - GPU_texture_unbind(tex); -} - -/** \} */ diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc new file mode 100644 index 00000000000..bd851dc4ba7 --- /dev/null +++ b/source/blender/draw/intern/draw_color_management.cc @@ -0,0 +1,63 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2020, Blender Foundation. + */ + +/** \file + * \ingroup draw + */ + +#include + +#include "draw_manager.h" + +#include "DRW_render.h" + +#include "GPU_batch.h" +#include "GPU_framebuffer.h" +#include "GPU_matrix.h" +#include "GPU_texture.h" + +#include "BKE_colortools.h" + +#include "IMB_colormanagement.h" + +#include "draw_color_management.h" + +/* -------------------------------------------------------------------- */ +/** \name Color Management + * \{ */ + +/* Draw texture to framebuffer without any color transforms */ +void DRW_transform_none(GPUTexture *tex) +{ + drw_state_set(DRW_STATE_WRITE_COLOR); + + GPU_matrix_identity_set(); + GPU_matrix_identity_projection_set(); + + /* Draw as texture for final render (without immediate mode). */ + GPUBatch *geom = DRW_cache_fullscreen_quad_get(); + GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); + GPU_batch_uniform_4f(geom, "color", 1.0f, 1.0f, 1.0f, 1.0f); + GPU_batch_texture_bind(geom, "image", tex); + + GPU_batch_draw(geom); + + GPU_texture_unbind(tex); +} + +/** \} */ diff --git a/source/blender/draw/intern/draw_color_management.h b/source/blender/draw/intern/draw_color_management.h index 3150ec72138..771da80e120 100644 --- a/source/blender/draw/intern/draw_color_management.h +++ b/source/blender/draw/intern/draw_color_management.h @@ -22,4 +22,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + void DRW_transform_none(struct GPUTexture *tex); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index a7015b25770..33e1a57198c 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -43,6 +43,10 @@ #include "draw_instance_data.h" +#ifdef __cplusplus +extern "C" { +#endif + struct DupliObject; struct Object; @@ -626,3 +630,7 @@ void drw_uniform_attrs_pool_update(struct GHash *table, struct Object *ob, struct Object *dupli_parent, struct DupliObject *dupli_source); + +#ifdef __cplusplus +} +#endif -- cgit v1.2.3