sdis_tile.h (1837B)
1 /* Copyright (C) 2016-2025 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #ifndef SDIS_TILE_H 17 #define SDIS_TILE_H 18 19 #include "sdis_misc.h" 20 21 #include <rsys/list.h> 22 #include <rsys/ref_count.h> 23 24 /* Forward declarations */ 25 struct mem_allocator; 26 27 #define TILE_SIZE 4 /* definition in X & Y of a tile */ 28 STATIC_ASSERT(IS_POW2(TILE_SIZE), TILE_SIZE_must_be_a_power_of_2); 29 30 struct pixel { 31 struct accum acc_temp; /* Temperature accumulator */ 32 struct accum acc_time; /* Time accumulator */ 33 }; 34 35 /* Tile of row ordered pixels */ 36 struct tile { 37 struct list_node node; 38 struct mem_allocator* allocator; 39 ref_T ref; 40 41 struct tile_data { 42 uint16_t x, y; /* 2D coordinates of the tile in tile space */ 43 struct pixel ALIGN(16) pixels[TILE_SIZE*TILE_SIZE]; 44 } data; 45 }; 46 47 extern LOCAL_SYM res_T 48 tile_create 49 (struct mem_allocator* allocator, 50 struct tile** tile); 51 52 extern LOCAL_SYM void 53 tile_ref_get 54 (struct tile* tile); 55 56 extern LOCAL_SYM void 57 tile_ref_put 58 (struct tile* tile); 59 60 static INLINE struct pixel* 61 tile_at(struct tile* tile, const uint16_t x, const uint16_t y) 62 { 63 ASSERT(tile && x < TILE_SIZE && y < TILE_SIZE); 64 return tile->data.pixels + y*TILE_SIZE + x; 65 } 66 67 #endif /* SDIS_TILE_H */