Branch data Line data Source code
1 : : /* 2 : : * This file is part of libplacebo. 3 : : * 4 : : * libplacebo is free software; you can redistribute it and/or 5 : : * modify it under the terms of the GNU Lesser General Public 6 : : * License as published by the Free Software Foundation; either 7 : : * version 2.1 of the License, or (at your option) any later version. 8 : : * 9 : : * libplacebo is distributed in the hope that it will be useful, 10 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : : * GNU Lesser General Public License for more details. 13 : : * 14 : : * You should have received a copy of the GNU Lesser General Public 15 : : * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>. 16 : : */ 17 : : 18 : : #include "common.h" 19 : : #include "log.h" 20 : : #include "swapchain.h" 21 : : 22 : 5 : void pl_swapchain_destroy(pl_swapchain *ptr) 23 : : { 24 : 5 : pl_swapchain sw = *ptr; 25 [ + - ]: 5 : if (!sw) 26 : : return; 27 : : 28 : 5 : const struct pl_sw_fns *impl = PL_PRIV(sw); 29 : 5 : impl->destroy(sw); 30 : 5 : *ptr = NULL; 31 : : } 32 : : 33 : 0 : int pl_swapchain_latency(pl_swapchain sw) 34 : : { 35 : 0 : const struct pl_sw_fns *impl = PL_PRIV(sw); 36 [ # # ]: 0 : if (!impl->latency) 37 : : return 0; 38 : : 39 : 0 : return impl->latency(sw); 40 : : } 41 : : 42 : 6 : bool pl_swapchain_resize(pl_swapchain sw, int *width, int *height) 43 : : { 44 : 6 : int dummy[2] = {0}; 45 [ + - ]: 6 : width = PL_DEF(width, &dummy[0]); 46 [ + - ]: 6 : height = PL_DEF(height, &dummy[1]); 47 : : 48 : 6 : const struct pl_sw_fns *impl = PL_PRIV(sw); 49 [ - + ]: 6 : if (!impl->resize) { 50 : 0 : *width = *height = 0; 51 : 0 : return true; 52 : : } 53 : : 54 : 6 : return impl->resize(sw, width, height); 55 : : } 56 : : 57 : 0 : void pl_swapchain_colorspace_hint(pl_swapchain sw, const struct pl_color_space *csp) 58 : : { 59 : 0 : const struct pl_sw_fns *impl = PL_PRIV(sw); 60 [ # # ]: 0 : if (!impl->colorspace_hint) 61 : 0 : return; 62 : : 63 : 0 : struct pl_swapchain_colors fix = {0}; 64 [ # # ]: 0 : if (csp) { 65 : 0 : fix = *csp; 66 : : // Ensure we have valid values set for all the fields 67 : 0 : pl_color_space_infer(&fix); 68 : : } 69 : : 70 : 0 : impl->colorspace_hint(sw, &fix); 71 : : } 72 : : 73 : 50 : bool pl_swapchain_start_frame(pl_swapchain sw, 74 : : struct pl_swapchain_frame *out_frame) 75 : : { 76 : 50 : *out_frame = (struct pl_swapchain_frame) {0}; // sanity 77 : : 78 : 50 : const struct pl_sw_fns *impl = PL_PRIV(sw); 79 : 50 : return impl->start_frame(sw, out_frame); 80 : : } 81 : : 82 : 50 : bool pl_swapchain_submit_frame(pl_swapchain sw) 83 : : { 84 : 50 : const struct pl_sw_fns *impl = PL_PRIV(sw); 85 : 50 : return impl->submit_frame(sw); 86 : : } 87 : : 88 : 50 : void pl_swapchain_swap_buffers(pl_swapchain sw) 89 : : { 90 : 50 : const struct pl_sw_fns *impl = PL_PRIV(sw); 91 : 50 : impl->swap_buffers(sw); 92 : 50 : }