From c1c8a4ba0984b295625801354e3c8cdaf9a72a02 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 31 May 2024 16:59:36 +0200 Subject: [PATCH] cogl/output: Make it private to Cogl Don't expose its headers, remove all getters, and move the rest to cogl-output-private.h. Next commits will clean it up even more, but for now, just make it private. This will help next commits remove CoglOutput. Part-of: --- cogl/cogl/cogl-output-private.h | 23 ++- cogl/cogl/cogl-output.c | 48 ------ cogl/cogl/cogl-output.h | 222 ------------------------- cogl/cogl/cogl-xlib-renderer-private.h | 2 +- cogl/cogl/cogl-xlib-renderer.c | 1 - cogl/cogl/cogl.h | 1 - cogl/cogl/meson.build | 1 - cogl/cogl/winsys/cogl-onscreen-glx.c | 5 +- 8 files changed, 25 insertions(+), 278 deletions(-) delete mode 100644 cogl/cogl/cogl-output.h diff --git a/cogl/cogl/cogl-output-private.h b/cogl/cogl/cogl-output-private.h index 818501067..c9abfb270 100644 --- a/cogl/cogl/cogl-output-private.h +++ b/cogl/cogl/cogl-output-private.h @@ -30,7 +30,28 @@ #pragma once -#include "cogl/cogl-output.h" +#include "cogl/cogl-types.h" + +#include + +#define COGL_TYPE_OUTPUT (cogl_output_get_type ()) + +COGL_EXPORT +G_DECLARE_FINAL_TYPE (CoglOutput, + cogl_output, + COGL, + OUTPUT, + GObject) + +typedef enum +{ + COGL_SUBPIXEL_ORDER_UNKNOWN, + COGL_SUBPIXEL_ORDER_NONE, + COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB, + COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR, + COGL_SUBPIXEL_ORDER_VERTICAL_RGB, + COGL_SUBPIXEL_ORDER_VERTICAL_BGR +} CoglSubpixelOrder; struct _CoglOutput { diff --git a/cogl/cogl/cogl-output.c b/cogl/cogl/cogl-output.c index a161c999d..51c7cdd44 100644 --- a/cogl/cogl/cogl-output.c +++ b/cogl/cogl/cogl-output.c @@ -78,51 +78,3 @@ _cogl_output_values_equal (CoglOutput *output, (const char *)other + G_STRUCT_OFFSET (CoglOutput, x), sizeof (CoglOutput) - G_STRUCT_OFFSET (CoglOutput, x)) == 0; } - -int -cogl_output_get_x (CoglOutput *output) -{ - return output->x; -} - -int -cogl_output_get_y (CoglOutput *output) -{ - return output->y; -} - -int -cogl_output_get_width (CoglOutput *output) -{ - return output->width; -} - -int -cogl_output_get_height (CoglOutput *output) -{ - return output->height; -} - -int -cogl_output_get_mm_width (CoglOutput *output) -{ - return output->mm_width; -} - -int -cogl_output_get_mm_height (CoglOutput *output) -{ - return output->mm_height; -} - -CoglSubpixelOrder -cogl_output_get_subpixel_order (CoglOutput *output) -{ - return output->subpixel_order; -} - -float -cogl_output_get_refresh_rate (CoglOutput *output) -{ - return output->refresh_rate; -} diff --git a/cogl/cogl/cogl-output.h b/cogl/cogl/cogl-output.h deleted file mode 100644 index 3542755df..000000000 --- a/cogl/cogl/cogl-output.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2012 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - * - * Authors: - * Owen Taylor - */ - -#pragma once - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#include "cogl/cogl-types.h" - -#include - -G_BEGIN_DECLS - -/** - * CoglOutput: - * - * Information about an output device - * - * The #CoglOutput object holds information about an output device - * such as a monitor or laptop display. It can be queried to find - * out the position of the output with respect to the screen - * coordinate system and other information such as the resolution - * and refresh rate of the device. - * - * There can be any number of outputs which may overlap: the - * same area of the screen may be displayed by multiple output - * devices. - * - * XXX: though it's possible to query the position of the output - * with respect to screen coordinates, there is currently no way - * of finding out the position of a #CoglOnscreen in screen - * coordinates, at least without using windowing-system specific - * API's, so it's not easy to get the output positions relative - * to the #CoglOnscreen. - */ - -typedef struct _CoglOutput CoglOutput; - -#define COGL_TYPE_OUTPUT (cogl_output_get_type ()) - -COGL_EXPORT -G_DECLARE_FINAL_TYPE (CoglOutput, - cogl_output, - COGL, - OUTPUT, - GObject) - -/** - * CoglSubpixelOrder: - * @COGL_SUBPIXEL_ORDER_UNKNOWN: the layout of subpixel - * components for the device is unknown. - * @COGL_SUBPIXEL_ORDER_NONE: the device displays colors - * without geometrically-separated subpixel components, - * or the positioning or colors of the components do not - * match any of the values in the enumeration. - * @COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB: the device has - * horizontally arranged components in the order - * red-green-blue from left to right. - * @COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR: the device has - * horizontally arranged components in the order - * blue-green-red from left to right. - * @COGL_SUBPIXEL_ORDER_VERTICAL_RGB: the device has - * vertically arranged components in the order - * red-green-blue from top to bottom. - * @COGL_SUBPIXEL_ORDER_VERTICAL_BGR: the device has - * vertically arranged components in the order - * blue-green-red from top to bottom. - * - * Some output devices (such as LCD panels) display colors - * by making each pixel consist of smaller "subpixels" - * that each have a particular color. By using knowledge - * of the layout of this subpixel components, it is possible - * to create image content with higher resolution than the - * pixel grid. - */ -typedef enum -{ - COGL_SUBPIXEL_ORDER_UNKNOWN, - COGL_SUBPIXEL_ORDER_NONE, - COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB, - COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR, - COGL_SUBPIXEL_ORDER_VERTICAL_RGB, - COGL_SUBPIXEL_ORDER_VERTICAL_BGR -} CoglSubpixelOrder; - -/** - * cogl_output_get_x: - * @output: a #CoglOutput - * - * Gets the X position of the output with respect to the coordinate - * system of the screen. - * - * Return value: the X position of the output as a pixel offset - * from the left side of the screen coordinate space - */ -COGL_EXPORT int -cogl_output_get_x (CoglOutput *output); - -/** - * cogl_output_get_y: - * @output: a #CoglOutput - * - * Gets the Y position of the output with respect to the coordinate - * system of the screen. - * - * Return value: the Y position of the output as a pixel offset - * from the top side of the screen coordinate space - */ -COGL_EXPORT int -cogl_output_get_y (CoglOutput *output); - -/** - * cogl_output_get_width: - * @output: a #CoglOutput - * - * Gets the width of the output in pixels. - * - * Return value: the width of the output in pixels - */ -COGL_EXPORT int -cogl_output_get_width (CoglOutput *output); - -/** - * cogl_output_get_height: - * @output: a #CoglOutput - * - * Gets the height of the output in pixels. - * - * Return value: the height of the output in pixels - */ -COGL_EXPORT int -cogl_output_get_height (CoglOutput *output); - -/** - * cogl_output_get_mm_width: - * @output: a #CoglOutput - * - * Gets the physical width of the output. In some cases (such as - * as a projector), the value returned here might correspond to - * nominal resolution rather than the actual physical size of the - * output device. - * - * Return value: the height of the output in millimeters. A value - * of 0 indicates the width is unknown - */ -COGL_EXPORT int -cogl_output_get_mm_width (CoglOutput *output); - -/** - * cogl_output_get_mm_height: - * @output: a #CoglOutput - * - * Gets the physical height of the output. In some cases (such as - * as a projector), the value returned here might correspond to - * nominal resolution rather than the actual physical size of the - * output device. - * - * Return value: the height of the output in millimeters. A value - * of 0 indicates that the height is unknown - */ -COGL_EXPORT int -cogl_output_get_mm_height (CoglOutput *output); - -/** - * cogl_output_get_subpixel_order: - * @output: a #CoglOutput - * - * For an output device where each pixel is made up of smaller components - * with different colors, returns the layout of the subpixel - * components. - * - * Return value: the order of subpixel components for the output device - */ -COGL_EXPORT CoglSubpixelOrder -cogl_output_get_subpixel_order (CoglOutput *output); - -/** - * cogl_output_get_refresh_rate: - * @output: a #CoglOutput - * - * Gets the number of times per second that the output device refreshes - * the display contents. - * - * Return value: the refresh rate of the output device. A value of zero - * indicates that the refresh rate is unknown. - */ -COGL_EXPORT float -cogl_output_get_refresh_rate (CoglOutput *output); - -G_END_DECLS diff --git a/cogl/cogl/cogl-xlib-renderer-private.h b/cogl/cogl/cogl-xlib-renderer-private.h index 8169129ef..f8f8ba70f 100644 --- a/cogl/cogl/cogl-xlib-renderer-private.h +++ b/cogl/cogl/cogl-xlib-renderer-private.h @@ -34,7 +34,7 @@ #include "cogl/cogl-x11-renderer-private.h" #include "cogl/cogl-context.h" -#include "cogl/cogl-output.h" +#include "cogl/cogl-output-private.h" typedef struct _CoglXlibRenderer { diff --git a/cogl/cogl/cogl-xlib-renderer.c b/cogl/cogl/cogl-xlib-renderer.c index 71cb43eba..1c4cde93a 100644 --- a/cogl/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl/cogl-xlib-renderer.c @@ -34,7 +34,6 @@ #include "cogl/cogl-xlib-renderer.h" #include "cogl/cogl-util.h" -#include "cogl/cogl-output-private.h" #include "cogl/cogl-renderer-private.h" #include "cogl/cogl-xlib-renderer-private.h" #include "cogl/cogl-x11-renderer-private.h" diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index e3fcfbfd3..dfce7a861 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -63,7 +63,6 @@ #endif #include "cogl/cogl-renderer.h" -#include "cogl/cogl-output.h" #include "cogl/cogl-display.h" #include "cogl/cogl-context.h" #include "cogl/cogl-buffer.h" diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index a49aa4d15..137ccf7c2 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -44,7 +44,6 @@ cogl_headers = [ 'cogl-offscreen.h', 'cogl-onscreen.h', 'cogl-onscreen-template.h', - 'cogl-output.h', 'cogl-pipeline.h', 'cogl-pipeline-layer-state.h', 'cogl-pipeline-state.h', diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c index 07fad363a..5475cac82 100644 --- a/cogl/cogl/winsys/cogl-onscreen-glx.c +++ b/cogl/cogl/winsys/cogl-onscreen-glx.c @@ -553,9 +553,8 @@ set_frame_info_output (CoglOnscreen *onscreen, if (output) { - float refresh_rate = cogl_output_get_refresh_rate (output); - if (refresh_rate != 0.0) - info->refresh_rate = refresh_rate; + if (output->refresh_rate != 0.0) + info->refresh_rate = output->refresh_rate; } }