htrdr_draw_map.h (3884B)
1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique 2 * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux 3 * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace 4 * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris 5 * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 6 * Copyright (C) 2022-2025 Observatoire de Paris 7 * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne 8 * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin 9 * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 23 24 #ifndef HTRDR_DRAW_MAP_H 25 #define HTRDR_DRAW_MAP_H 26 27 #include "core/htrdr.h" 28 #include "core/htrdr_buffer.h" 29 30 #include <rsys/rsys.h> 31 32 struct htrdr_draw_pixel_args { 33 size_t pixel_coord[2]; /* Image plane pixel coordinates */ 34 double pixel_normalized_size[2]; /* Pixel size in the normalized img plane */ 35 struct ssp_rng* rng; /* Random Number Generator */ 36 size_t spp; /* #samples per pixel */ 37 size_t ithread; /* Id of the thread drawing the pixel */ 38 void* context; /* User defined data */ 39 }; 40 41 #define HTRDR_DRAW_PIXEL_ARGS_NULL__ { \ 42 {0, 0}, /* Image plane pixel coordinates */ \ 43 {0, 0}, /* Pixel size in the normalized img plane */ \ 44 NULL, /* RNG */ \ 45 0, /* SPP */ \ 46 0, /* Thread id */ \ 47 NULL /* User data */ \ 48 } 49 static const struct htrdr_draw_pixel_args HTRDR_DRAW_PIXEL_ARGS_NULL = 50 HTRDR_DRAW_PIXEL_ARGS_NULL__; 51 52 typedef void 53 (*htrdr_draw_pixel_T) 54 (struct htrdr* htrdr, 55 const struct htrdr_draw_pixel_args* args, 56 void* pixel); /* Output data */ 57 58 struct htrdr_draw_map_args { 59 htrdr_draw_pixel_T draw_pixel; 60 struct htrdr_buffer_layout buffer_layout; 61 size_t spp; /* Samples per pixel */ 62 void* context; /* User defined data */ 63 }; 64 65 #define HTRDR_DRAW_MAP_ARGS_NULL__ { \ 66 NULL, /* Draw pixel functor */ \ 67 HTRDR_BUFFER_LAYOUT_NULL__, /* Layout of the destination buffer */ \ 68 0, /* #Samples per pixel */ \ 69 NULL /* User defined data */ \ 70 } 71 static const struct htrdr_draw_map_args HTRDR_DRAW_MAP_ARGS_NULL = 72 HTRDR_DRAW_MAP_ARGS_NULL__; 73 74 static INLINE int 75 htrdr_draw_pixel_args_check(const struct htrdr_draw_pixel_args* args) 76 { 77 return args 78 && args->pixel_normalized_size[0] > 0 79 && args->pixel_normalized_size[1] > 0 80 && args->rng 81 && args->spp > 0; 82 } 83 84 /******************************************************************************* 85 * Exported symbols 86 ******************************************************************************/ 87 BEGIN_DECLS 88 89 HTRDR_API res_T 90 htrdr_draw_map 91 (struct htrdr* htrdr, 92 const struct htrdr_draw_map_args* args, 93 struct htrdr_buffer* buf); /* May be NULL for non master processes */ 94 95 END_DECLS 96 97 #endif /* HTRDR_DRAW_MAP_H */ 98