From cb4190616fc5c4d104d018779293ca53f9d04ea1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 1 Jun 2024 10:20:47 +0200 Subject: [PATCH] cogl/xlib-renderer: Use SubpixelFormat enums directly No need to convert from / to CoglSubpixelFormat. Part-of: --- cogl/cogl/cogl-xlib-renderer-private.h | 4 +- cogl/cogl/cogl-xlib-renderer.c | 64 +++++++++----------------- 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/cogl/cogl/cogl-xlib-renderer-private.h b/cogl/cogl/cogl-xlib-renderer-private.h index ca94cad0e..f4a6ec7db 100644 --- a/cogl/cogl/cogl-xlib-renderer-private.h +++ b/cogl/cogl/cogl-xlib-renderer-private.h @@ -31,10 +31,10 @@ #pragma once #include +#include #include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-context.h" -#include "cogl/cogl-output-private.h" typedef struct _CoglXlibOutput { @@ -46,7 +46,7 @@ typedef struct _CoglXlibOutput int mm_width; int mm_height; float refresh_rate; - CoglSubpixelOrder subpixel_order; + SubpixelOrder subpixel_order; } CoglXlibOutput; typedef struct _CoglXlibRenderer diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index c88898a00..3de88ae6e 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -146,20 +146,20 @@ compare_outputs (CoglXlibOutput *a, return strcmp (a->name, b->name); } -#define CSO(X) COGL_SUBPIXEL_ORDER_ ## X -static CoglSubpixelOrder subpixel_map[6][6] = { - { CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR), - CSO(VERTICAL_RGB), CSO(VERTICAL_BGR) }, /* 0 */ - { CSO(UNKNOWN), CSO(NONE), CSO(VERTICAL_RGB), CSO(VERTICAL_BGR), - CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB) }, /* 90 */ - { CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB), - CSO(VERTICAL_BGR), CSO(VERTICAL_RGB) }, /* 180 */ - { CSO(UNKNOWN), CSO(NONE), CSO(VERTICAL_BGR), CSO(VERTICAL_RGB), - CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR) }, /* 270 */ - { CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB), - CSO(VERTICAL_RGB), CSO(VERTICAL_BGR) }, /* Reflect_X */ - { CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR), - CSO(VERTICAL_BGR), CSO(VERTICAL_RGB) }, /* Reflect_Y */ +#define CSO(X) SubPixel ## X +static SubpixelOrder subpixel_map[6][6] = { + { CSO(Unknown), CSO(None), CSO(HorizontalRGB), CSO(HorizontalBGR), + CSO(VerticalRGB), CSO(VerticalBGR) }, /* 0 */ + { CSO(Unknown), CSO(None), CSO(VerticalRGB), CSO(VerticalBGR), + CSO(HorizontalBGR), CSO(HorizontalRGB) }, /* 90 */ + { CSO(Unknown), CSO(None), CSO(HorizontalBGR), CSO(HorizontalRGB), + CSO(VerticalBGR), CSO(VerticalRGB) }, /* 180 */ + { CSO(Unknown), CSO(None), CSO(VerticalBGR), CSO(VerticalRGB), + CSO(HorizontalRGB), CSO(HorizontalBGR) }, /* 270 */ + { CSO(Unknown), CSO(None), CSO(HorizontalBGR), CSO(HorizontalRGB), + CSO(VerticalRGB), CSO(VerticalBGR) }, /* Reflect_X */ + { CSO(Unknown), CSO(None), CSO(HorizontalRGB), CSO(HorizontalBGR), + CSO(VerticalBGR), CSO(VerticalRGB) }, /* Reflect_Y */ }; #undef CSO @@ -237,29 +237,7 @@ update_outputs (CoglRenderer *renderer, } output->refresh_rate = refresh_rate; - - switch (output_info->subpixel_order) - { - case SubPixelUnknown: - default: - output->subpixel_order = COGL_SUBPIXEL_ORDER_UNKNOWN; - break; - case SubPixelNone: - output->subpixel_order = COGL_SUBPIXEL_ORDER_NONE; - break; - case SubPixelHorizontalRGB: - output->subpixel_order = COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB; - break; - case SubPixelHorizontalBGR: - output->subpixel_order = COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR; - break; - case SubPixelVerticalRGB: - output->subpixel_order = COGL_SUBPIXEL_ORDER_VERTICAL_RGB; - break; - case SubPixelVerticalBGR: - output->subpixel_order = COGL_SUBPIXEL_ORDER_VERTICAL_BGR; - break; - } + output->subpixel_order = output_info->subpixel_order; /* Handle the effect of rotation and reflection on subpixel order (ugh) */ for (j = 0; j < 6; j++) @@ -359,23 +337,23 @@ update_outputs (CoglRenderer *renderer, switch (output->subpixel_order) { - case COGL_SUBPIXEL_ORDER_UNKNOWN: + case SubPixelUnknown: default: subpixel_string = "unknown"; break; - case COGL_SUBPIXEL_ORDER_NONE: + case SubPixelNone: subpixel_string = "none"; break; - case COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB: + case SubPixelHorizontalRGB: subpixel_string = "horizontal_rgb"; break; - case COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR: + case SubPixelHorizontalBGR: subpixel_string = "horizontal_bgr"; break; - case COGL_SUBPIXEL_ORDER_VERTICAL_RGB: + case SubPixelVerticalRGB: subpixel_string = "vertical_rgb"; break; - case COGL_SUBPIXEL_ORDER_VERTICAL_BGR: + case SubPixelVerticalBGR: subpixel_string = "vertical_bgr"; break; }