[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/14] ui/console: move DisplaySurface to its own header
From: |
marcandre . lureau |
Subject: |
[PULL 11/14] ui/console: move DisplaySurface to its own header |
Date: |
Tue, 12 Sep 2023 14:46:45 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Mostly for readability reasons.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/ui/console.h | 84 +--------------------------------------
include/ui/surface.h | 95 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 96 insertions(+), 83 deletions(-)
create mode 100644 include/ui/surface.h
diff --git a/include/ui/console.h b/include/ui/console.h
index 93bb03a9e2..79e4702912 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -6,11 +6,7 @@
#include "qemu/notify.h"
#include "qapi/qapi-types-ui.h"
#include "ui/input.h"
-
-#ifdef CONFIG_OPENGL
-# include <epoxy/gl.h>
-# include "ui/shader.h"
-#endif
+#include "ui/surface.h"
#define TYPE_QEMU_CONSOLE "qemu-console"
OBJECT_DECLARE_TYPE(QemuConsole, QemuConsoleClass, QEMU_CONSOLE)
@@ -136,9 +132,6 @@ struct QemuConsoleClass {
ObjectClass parent_class;
};
-#define QEMU_ALLOCATED_FLAG 0x01
-#define QEMU_PLACEHOLDER_FLAG 0x02
-
typedef struct ScanoutTexture {
uint32_t backing_id;
bool backing_y_0_top;
@@ -151,20 +144,6 @@ typedef struct ScanoutTexture {
void *d3d_tex2d;
} ScanoutTexture;
-typedef struct DisplaySurface {
- pixman_image_t *image;
- uint8_t flags;
-#ifdef CONFIG_OPENGL
- GLenum glformat;
- GLenum gltype;
- GLuint texture;
-#endif
-#ifdef WIN32
- HANDLE handle;
- uint32_t handle_offset;
-#endif
-} DisplaySurface;
-
typedef struct QemuUIInfo {
/* physical dimension */
uint16_t width_mm;
@@ -344,30 +323,6 @@ struct DisplayGLCtx {
};
DisplayState *init_displaystate(void);
-DisplaySurface *qemu_create_displaysurface_from(int width, int height,
- pixman_format_code_t format,
- int linesize, uint8_t *data);
-DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image);
-DisplaySurface *qemu_create_placeholder_surface(int w, int h,
- const char *msg);
-#ifdef WIN32
-void qemu_displaysurface_win32_set_handle(DisplaySurface *surface,
- HANDLE h, uint32_t offset);
-#endif
-PixelFormat qemu_default_pixelformat(int bpp);
-
-DisplaySurface *qemu_create_displaysurface(int width, int height);
-void qemu_free_displaysurface(DisplaySurface *surface);
-
-static inline int is_buffer_shared(DisplaySurface *surface)
-{
- return !(surface->flags & QEMU_ALLOCATED_FLAG);
-}
-
-static inline int is_placeholder(DisplaySurface *surface)
-{
- return surface->flags & QEMU_PLACEHOLDER_FLAG;
-}
void register_displaychangelistener(DisplayChangeListener *dcl);
void update_displaychangelistener(DisplayChangeListener *dcl,
@@ -415,43 +370,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con,
QEMUGLContext ctx);
bool console_has_gl(QemuConsole *con);
-static inline int surface_stride(DisplaySurface *s)
-{
- return pixman_image_get_stride(s->image);
-}
-
-static inline void *surface_data(DisplaySurface *s)
-{
- return pixman_image_get_data(s->image);
-}
-
-static inline int surface_width(DisplaySurface *s)
-{
- return pixman_image_get_width(s->image);
-}
-
-static inline int surface_height(DisplaySurface *s)
-{
- return pixman_image_get_height(s->image);
-}
-
-static inline pixman_format_code_t surface_format(DisplaySurface *s)
-{
- return pixman_image_get_format(s->image);
-}
-
-static inline int surface_bits_per_pixel(DisplaySurface *s)
-{
- int bits = PIXMAN_FORMAT_BPP(surface_format(s));
- return bits;
-}
-
-static inline int surface_bytes_per_pixel(DisplaySurface *s)
-{
- int bits = PIXMAN_FORMAT_BPP(surface_format(s));
- return DIV_ROUND_UP(bits, 8);
-}
-
typedef uint32_t console_ch_t;
static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
diff --git a/include/ui/surface.h b/include/ui/surface.h
new file mode 100644
index 0000000000..4244e0ca4a
--- /dev/null
+++ b/include/ui/surface.h
@@ -0,0 +1,95 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * QEMU UI Console
+ */
+#ifndef SURFACE_H
+#define SURFACE_H
+
+#include "ui/qemu-pixman.h"
+
+#ifdef CONFIG_OPENGL
+# include <epoxy/gl.h>
+# include "ui/shader.h"
+#endif
+
+#define QEMU_ALLOCATED_FLAG 0x01
+#define QEMU_PLACEHOLDER_FLAG 0x02
+
+typedef struct DisplaySurface {
+ pixman_image_t *image;
+ uint8_t flags;
+#ifdef CONFIG_OPENGL
+ GLenum glformat;
+ GLenum gltype;
+ GLuint texture;
+#endif
+#ifdef WIN32
+ HANDLE handle;
+ uint32_t handle_offset;
+#endif
+} DisplaySurface;
+
+PixelFormat qemu_default_pixelformat(int bpp);
+
+DisplaySurface *qemu_create_displaysurface_from(int width, int height,
+ pixman_format_code_t format,
+ int linesize, uint8_t *data);
+DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image);
+DisplaySurface *qemu_create_placeholder_surface(int w, int h,
+ const char *msg);
+#ifdef WIN32
+void qemu_displaysurface_win32_set_handle(DisplaySurface *surface,
+ HANDLE h, uint32_t offset);
+#endif
+
+DisplaySurface *qemu_create_displaysurface(int width, int height);
+void qemu_free_displaysurface(DisplaySurface *surface);
+
+static inline int is_buffer_shared(DisplaySurface *surface)
+{
+ return !(surface->flags & QEMU_ALLOCATED_FLAG);
+}
+
+static inline int is_placeholder(DisplaySurface *surface)
+{
+ return surface->flags & QEMU_PLACEHOLDER_FLAG;
+}
+
+static inline int surface_stride(DisplaySurface *s)
+{
+ return pixman_image_get_stride(s->image);
+}
+
+static inline void *surface_data(DisplaySurface *s)
+{
+ return pixman_image_get_data(s->image);
+}
+
+static inline int surface_width(DisplaySurface *s)
+{
+ return pixman_image_get_width(s->image);
+}
+
+static inline int surface_height(DisplaySurface *s)
+{
+ return pixman_image_get_height(s->image);
+}
+
+static inline pixman_format_code_t surface_format(DisplaySurface *s)
+{
+ return pixman_image_get_format(s->image);
+}
+
+static inline int surface_bits_per_pixel(DisplaySurface *s)
+{
+ int bits = PIXMAN_FORMAT_BPP(surface_format(s));
+ return bits;
+}
+
+static inline int surface_bytes_per_pixel(DisplaySurface *s)
+{
+ int bits = PIXMAN_FORMAT_BPP(surface_format(s));
+ return DIV_ROUND_UP(bits, 8);
+}
+
+#endif
--
2.41.0
- [PULL 01/14] docs: vhost-user-gpu: add protocol changes for dmabuf modifiers, (continued)
- [PULL 01/14] docs: vhost-user-gpu: add protocol changes for dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 02/14] contrib/vhost-user-gpu: add support for sending dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 03/14] vhost-user-gpu: support dmabuf modifiers, marcandre . lureau, 2023/09/12
- [PULL 04/14] vmmouse: replace DPRINTF with tracing, marcandre . lureau, 2023/09/12
- [PULL 05/14] vmmouse: use explicit code, marcandre . lureau, 2023/09/12
- [PULL 06/14] ui/vc: remove kbd_put_keysym() and update function calls, marcandre . lureau, 2023/09/12
- [PULL 07/14] ui/vc: rename kbd_put to qemu_text_console functions, marcandre . lureau, 2023/09/12
- [PULL 08/14] ui/console: remove redundant format field, marcandre . lureau, 2023/09/12
- [PULL 09/14] ui/vc: preliminary QemuTextConsole changes before split, marcandre . lureau, 2023/09/12
- [PULL 10/14] ui/vc: split off the VC part from console.c, marcandre . lureau, 2023/09/12
- [PULL 11/14] ui/console: move DisplaySurface to its own header,
marcandre . lureau <=
- [PULL 12/14] virtio-gpu/win32: set the destroy function on load, marcandre . lureau, 2023/09/12
- [PULL 13/14] ui: fix crash when there are no active_console, marcandre . lureau, 2023/09/12
- [PULL 14/14] ui: add precondition for dpy_get_ui_info(), marcandre . lureau, 2023/09/12