1
0
Fork 0

cogl/xlib-renderer: Use SubpixelFormat enums directly

No need to convert from / to CoglSubpixelFormat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3792>
This commit is contained in:
Georges Basile Stavracas Neto 2024-06-01 10:20:47 +02:00 committed by Marge Bot
parent 4f3631eae4
commit cb4190616f
2 changed files with 23 additions and 45 deletions

View file

@ -31,10 +31,10 @@
#pragma once #pragma once
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>
#include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-x11-renderer-private.h"
#include "cogl/cogl-context.h" #include "cogl/cogl-context.h"
#include "cogl/cogl-output-private.h"
typedef struct _CoglXlibOutput typedef struct _CoglXlibOutput
{ {
@ -46,7 +46,7 @@ typedef struct _CoglXlibOutput
int mm_width; int mm_width;
int mm_height; int mm_height;
float refresh_rate; float refresh_rate;
CoglSubpixelOrder subpixel_order; SubpixelOrder subpixel_order;
} CoglXlibOutput; } CoglXlibOutput;
typedef struct _CoglXlibRenderer typedef struct _CoglXlibRenderer

View file

@ -146,20 +146,20 @@ compare_outputs (CoglXlibOutput *a,
return strcmp (a->name, b->name); return strcmp (a->name, b->name);
} }
#define CSO(X) COGL_SUBPIXEL_ORDER_ ## X #define CSO(X) SubPixel ## X
static CoglSubpixelOrder subpixel_map[6][6] = { static SubpixelOrder subpixel_map[6][6] = {
{ CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR), { CSO(Unknown), CSO(None), CSO(HorizontalRGB), CSO(HorizontalBGR),
CSO(VERTICAL_RGB), CSO(VERTICAL_BGR) }, /* 0 */ CSO(VerticalRGB), CSO(VerticalBGR) }, /* 0 */
{ CSO(UNKNOWN), CSO(NONE), CSO(VERTICAL_RGB), CSO(VERTICAL_BGR), { CSO(Unknown), CSO(None), CSO(VerticalRGB), CSO(VerticalBGR),
CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB) }, /* 90 */ CSO(HorizontalBGR), CSO(HorizontalRGB) }, /* 90 */
{ CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB), { CSO(Unknown), CSO(None), CSO(HorizontalBGR), CSO(HorizontalRGB),
CSO(VERTICAL_BGR), CSO(VERTICAL_RGB) }, /* 180 */ CSO(VerticalBGR), CSO(VerticalRGB) }, /* 180 */
{ CSO(UNKNOWN), CSO(NONE), CSO(VERTICAL_BGR), CSO(VERTICAL_RGB), { CSO(Unknown), CSO(None), CSO(VerticalBGR), CSO(VerticalRGB),
CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR) }, /* 270 */ CSO(HorizontalRGB), CSO(HorizontalBGR) }, /* 270 */
{ CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_BGR), CSO(HORIZONTAL_RGB), { CSO(Unknown), CSO(None), CSO(HorizontalBGR), CSO(HorizontalRGB),
CSO(VERTICAL_RGB), CSO(VERTICAL_BGR) }, /* Reflect_X */ CSO(VerticalRGB), CSO(VerticalBGR) }, /* Reflect_X */
{ CSO(UNKNOWN), CSO(NONE), CSO(HORIZONTAL_RGB), CSO(HORIZONTAL_BGR), { CSO(Unknown), CSO(None), CSO(HorizontalRGB), CSO(HorizontalBGR),
CSO(VERTICAL_BGR), CSO(VERTICAL_RGB) }, /* Reflect_Y */ CSO(VerticalBGR), CSO(VerticalRGB) }, /* Reflect_Y */
}; };
#undef CSO #undef CSO
@ -237,29 +237,7 @@ update_outputs (CoglRenderer *renderer,
} }
output->refresh_rate = refresh_rate; output->refresh_rate = refresh_rate;
output->subpixel_order = output_info->subpixel_order;
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;
}
/* Handle the effect of rotation and reflection on subpixel order (ugh) */ /* Handle the effect of rotation and reflection on subpixel order (ugh) */
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
@ -359,23 +337,23 @@ update_outputs (CoglRenderer *renderer,
switch (output->subpixel_order) switch (output->subpixel_order)
{ {
case COGL_SUBPIXEL_ORDER_UNKNOWN: case SubPixelUnknown:
default: default:
subpixel_string = "unknown"; subpixel_string = "unknown";
break; break;
case COGL_SUBPIXEL_ORDER_NONE: case SubPixelNone:
subpixel_string = "none"; subpixel_string = "none";
break; break;
case COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB: case SubPixelHorizontalRGB:
subpixel_string = "horizontal_rgb"; subpixel_string = "horizontal_rgb";
break; break;
case COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR: case SubPixelHorizontalBGR:
subpixel_string = "horizontal_bgr"; subpixel_string = "horizontal_bgr";
break; break;
case COGL_SUBPIXEL_ORDER_VERTICAL_RGB: case SubPixelVerticalRGB:
subpixel_string = "vertical_rgb"; subpixel_string = "vertical_rgb";
break; break;
case COGL_SUBPIXEL_ORDER_VERTICAL_BGR: case SubPixelVerticalBGR:
subpixel_string = "vertical_bgr"; subpixel_string = "vertical_bgr";
break; break;
} }