renderer/native: Move out CoglOnscreen code to separate file

To get meta-renderer-native.c down to a bit more managable size, and to
isolate "onscreen" functionality from other (at least partly), move out
the things related to CoglOnscreen to meta-onscreen-native.[ch].

A couple of structs are moved to a new shared header file, as
abstracting those types (e.g. (primary, secondary) render devices) will
be dealt with later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-17 23:08:28 +02:00 committed by Robert Mader
parent b5afa6db23
commit 3e4ece50d3
6 changed files with 2498 additions and 2276 deletions

View File

@ -25,5 +25,7 @@ typedef struct _MetaBackendNative MetaBackendNative;
typedef struct _MetaSeatNative MetaSeatNative;
typedef struct _MetaSeatImpl MetaSeatImpl;
typedef struct _MetaKeymapNative MetaKeymapNative;
typedef struct _MetaRendererNative MetaRendererNative;
typedef struct _MetaGpuKms MetaGpuKms;
#endif /* META_BACKEND_NATIVE_TYPES_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2016-2020 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#ifndef META_ONSCREEN_NATIVE_H
#define META_ONSCREEN_NATIVE_H
#include <glib.h>
#include "backends/meta-backend-types.h"
#include "backends/native/meta-backend-native-types.h"
#include "clutter/clutter.h"
#include "cogl/cogl.h"
gboolean
meta_renderer_native_init_onscreen (CoglOnscreen *onscreen,
GError **error);
void meta_renderer_native_release_onscreen (CoglOnscreen *onscreen);
gboolean meta_onscreen_native_allocate (CoglOnscreen *onscreen,
GError **error);
void meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *frame_info,
gpointer user_data);
gboolean meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
CoglScanout *scanout,
CoglFrameInfo *frame_info,
gpointer user_data,
GError **error);
void meta_onscreen_native_finish_frame (CoglOnscreen *onscreen,
ClutterFrame *frame);
void meta_onscreen_native_dummy_power_save_page_flip (CoglOnscreen *onscreen);
void meta_onscreen_native_set_view (CoglOnscreen *onscreen,
MetaRendererView *view);
CoglOnscreen * meta_onscreen_native_new (MetaRendererNative *renderer_native,
MetaGpuKms *render_gpu,
MetaOutput *output,
MetaCrtc *crtc,
CoglContext *cogl_context,
int width,
int height,
GError **error);
#endif /* META_ONSCREEN_NATIVE_H */

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 2011 Intel Corporation.
* Copyright (C) 2016-2020 Red Hat
* Copyright (c) 2018,2019 DisplayLink (UK) Ltd.
*
* 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.
*
*/
#ifndef META_RENDERER_NATIVE_PRIVATE_H
#define META_RENDERER_NATIVE_PRIVATE_H
#include "backends/meta-gles3.h"
#include "backends/native/meta-renderer-native.h"
typedef enum _MetaSharedFramebufferCopyMode
{
/* Zero-copy: primary GPU exports, secondary GPU imports as KMS FB */
META_SHARED_FRAMEBUFFER_COPY_MODE_ZERO,
/* the secondary GPU will make the copy */
META_SHARED_FRAMEBUFFER_COPY_MODE_SECONDARY_GPU,
/*
* The copy is made in the primary GPU rendering context, either
* as a CPU copy through Cogl read-pixels or as primary GPU copy
* using glBlitFramebuffer.
*/
META_SHARED_FRAMEBUFFER_COPY_MODE_PRIMARY
} MetaSharedFramebufferCopyMode;
typedef struct _MetaRendererNativeGpuData
{
MetaRendererNative *renderer_native;
struct {
struct gbm_device *device;
} gbm;
#ifdef HAVE_EGL_DEVICE
struct {
EGLDeviceEXT device;
} egl;
#endif
MetaRendererNativeMode mode;
EGLDisplay egl_display;
/*
* Fields used for blitting iGPU framebuffer content onto dGPU framebuffers.
*/
struct {
MetaSharedFramebufferCopyMode copy_mode;
gboolean is_hardware_rendering;
gboolean has_EGL_EXT_image_dma_buf_import_modifiers;
/* For GPU blit mode */
EGLContext egl_context;
EGLConfig egl_config;
} secondary;
} MetaRendererNativeGpuData;
MetaEgl * meta_renderer_native_get_egl (MetaRendererNative *renderer_native);
MetaGles3 * meta_renderer_native_get_gles3 (MetaRendererNative *renderer_native);
MetaRendererNativeGpuData * meta_renderer_native_get_gpu_data (MetaRendererNative *renderer_native,
MetaGpuKms *gpu_kms);
gboolean meta_renderer_native_has_pending_mode_sets (MetaRendererNative *renderer_native);
gboolean meta_renderer_native_has_pending_mode_set (MetaRendererNative *renderer_native);
void meta_renderer_native_notify_mode_sets_reset (MetaRendererNative *renderer_native);
void meta_renderer_native_post_mode_set_updates (MetaRendererNative *renderer_native);
void meta_renderer_native_queue_power_save_page_flip (MetaRendererNative *renderer_native,
CoglOnscreen *onscreen);
CoglFramebuffer * meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_native,
int dmabuf_fd,
uint32_t width,
uint32_t height,
uint32_t stride,
uint32_t offset,
uint64_t modifier,
uint32_t drm_format,
GError **error);
gboolean meta_renderer_native_pop_pending_mode_set (MetaRendererNative *renderer_native,
MetaRendererView *view);
const CoglWinsysVtable * meta_get_renderer_native_parent_vtable (void);
#endif /* META_RENDERER_NATIVE_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -669,7 +669,6 @@ if have_native_backend
'backends/native/meta-monitor-manager-kms.h',
'backends/native/meta-output-kms.c',
'backends/native/meta-output-kms.h',
'backends/native/meta-renderer-native.c',
'backends/native/meta-kms-connector-private.h',
'backends/native/meta-kms-connector.c',
'backends/native/meta-kms-connector.h',
@ -703,10 +702,14 @@ if have_native_backend
'backends/native/meta-kms-utils.h',
'backends/native/meta-kms.c',
'backends/native/meta-kms.h',
'backends/native/meta-onscreen-native.c',
'backends/native/meta-onscreen-native.h',
'backends/native/meta-pointer-constraint-native.c',
'backends/native/meta-pointer-constraint-native.h',
'backends/native/meta-renderer-native-gles3.c',
'backends/native/meta-renderer-native-gles3.h',
'backends/native/meta-renderer-native-private.h',
'backends/native/meta-renderer-native.c',
'backends/native/meta-renderer-native.h',
'backends/native/meta-seat-impl.c',
'backends/native/meta-seat-impl.h',