backends/native: Introduce MetaRendererViewNative

MetaRendererViewNative is a MetaRendererView which contains logic
specific to views of the native backend. It will be used by following
commits.

In the future, per-view logic from MetaRendererNative can be moved to
MetaRendererViewNative where it makes more sense to have it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
This commit is contained in:
Dor Askayo 2020-07-10 18:40:07 +03:00 committed by Robert Mader
parent 2dfbbf0068
commit 1abd930c56
6 changed files with 136 additions and 34 deletions

View File

@ -49,28 +49,32 @@ enum
static GParamSpec *obj_props[PROP_LAST]; static GParamSpec *obj_props[PROP_LAST];
struct _MetaRendererView typedef struct _MetaRendererViewPrivate
{ {
MetaStageView parent;
MetaMonitorTransform transform; MetaMonitorTransform transform;
MetaCrtc *crtc; MetaCrtc *crtc;
}; } MetaRendererViewPrivate;
G_DEFINE_TYPE (MetaRendererView, meta_renderer_view, G_DEFINE_TYPE_WITH_PRIVATE (MetaRendererView, meta_renderer_view,
META_TYPE_STAGE_VIEW) META_TYPE_STAGE_VIEW)
MetaMonitorTransform MetaMonitorTransform
meta_renderer_view_get_transform (MetaRendererView *view) meta_renderer_view_get_transform (MetaRendererView *view)
{ {
return view->transform; MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (view);
return priv->transform;
} }
MetaCrtc * MetaCrtc *
meta_renderer_view_get_crtc (MetaRendererView *view) meta_renderer_view_get_crtc (MetaRendererView *view)
{ {
return view->crtc; MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (view);
return priv->crtc;
} }
static void static void
@ -78,10 +82,13 @@ meta_renderer_view_get_offscreen_transformation_matrix (ClutterStageView *view,
graphene_matrix_t *matrix) graphene_matrix_t *matrix)
{ {
MetaRendererView *renderer_view = META_RENDERER_VIEW (view); MetaRendererView *renderer_view = META_RENDERER_VIEW (view);
MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (renderer_view);
graphene_matrix_init_identity (matrix); graphene_matrix_init_identity (matrix);
meta_monitor_transform_transform_matrix ( meta_monitor_transform_transform_matrix (
meta_monitor_transform_invert (renderer_view->transform), matrix); meta_monitor_transform_invert (priv->transform), matrix);
} }
static void static void
@ -102,9 +109,11 @@ meta_renderer_view_transform_rect_to_onscreen (ClutterStageView *view
cairo_rectangle_int_t *dst_rect) cairo_rectangle_int_t *dst_rect)
{ {
MetaRendererView *renderer_view = META_RENDERER_VIEW (view); MetaRendererView *renderer_view = META_RENDERER_VIEW (view);
MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (renderer_view);
return meta_rectangle_transform (src_rect, return meta_rectangle_transform (src_rect,
renderer_view->transform, priv->transform,
dst_width, dst_width,
dst_height, dst_height,
dst_rect); dst_rect);
@ -114,10 +123,13 @@ static void
meta_renderer_view_set_transform (MetaRendererView *view, meta_renderer_view_set_transform (MetaRendererView *view,
MetaMonitorTransform transform) MetaMonitorTransform transform)
{ {
if (view->transform == transform) MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (view);
if (priv->transform == transform)
return; return;
view->transform = transform; priv->transform = transform;
clutter_stage_view_invalidate_offscreen_blit_pipeline (CLUTTER_STAGE_VIEW (view)); clutter_stage_view_invalidate_offscreen_blit_pipeline (CLUTTER_STAGE_VIEW (view));
} }
@ -128,14 +140,16 @@ meta_renderer_view_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaRendererView *view = META_RENDERER_VIEW (object); MetaRendererView *view = META_RENDERER_VIEW (object);
MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (view);
switch (prop_id) switch (prop_id)
{ {
case PROP_TRANSFORM: case PROP_TRANSFORM:
g_value_set_uint (value, view->transform); g_value_set_uint (value, priv->transform);
break; break;
case PROP_CRTC: case PROP_CRTC:
g_value_set_object (value, view->crtc); g_value_set_object (value, priv->crtc);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -150,6 +164,8 @@ meta_renderer_view_set_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaRendererView *view = META_RENDERER_VIEW (object); MetaRendererView *view = META_RENDERER_VIEW (object);
MetaRendererViewPrivate *priv =
meta_renderer_view_get_instance_private (view);
switch (prop_id) switch (prop_id)
{ {
@ -157,7 +173,7 @@ meta_renderer_view_set_property (GObject *object,
meta_renderer_view_set_transform (view, g_value_get_uint (value)); meta_renderer_view_set_transform (view, g_value_get_uint (value));
break; break;
case PROP_CRTC: case PROP_CRTC:
view->crtc = g_value_get_object (value); priv->crtc = g_value_get_object (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View File

@ -24,9 +24,14 @@
#define META_TYPE_RENDERER_VIEW (meta_renderer_view_get_type ()) #define META_TYPE_RENDERER_VIEW (meta_renderer_view_get_type ())
META_EXPORT_TEST META_EXPORT_TEST
G_DECLARE_FINAL_TYPE (MetaRendererView, meta_renderer_view, G_DECLARE_DERIVABLE_TYPE (MetaRendererView, meta_renderer_view,
META, RENDERER_VIEW, META, RENDERER_VIEW,
MetaStageView) MetaStageView)
struct _MetaRendererViewClass
{
MetaStageViewClass parent_class;
};
MetaMonitorTransform meta_renderer_view_get_transform (MetaRendererView *view); MetaMonitorTransform meta_renderer_view_get_transform (MetaRendererView *view);

View File

@ -62,6 +62,7 @@
#include "backends/native/meta-render-device-gbm.h" #include "backends/native/meta-render-device-gbm.h"
#include "backends/native/meta-render-device-surfaceless.h" #include "backends/native/meta-render-device-surfaceless.h"
#include "backends/native/meta-renderer-native-private.h" #include "backends/native/meta-renderer-native-private.h"
#include "backends/native/meta-renderer-view-native.h"
#include "cogl/cogl.h" #include "cogl/cogl.h"
#include "core/boxes-private.h" #include "core/boxes-private.h"
@ -1258,7 +1259,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
int onscreen_width; int onscreen_width;
int onscreen_height; int onscreen_height;
MetaRectangle view_layout; MetaRectangle view_layout;
MetaRendererView *view; MetaRendererViewNative *view_native;
EGLSurface egl_surface; EGLSurface egl_surface;
GError *error = NULL; GError *error = NULL;
@ -1371,26 +1372,27 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
meta_rectangle_from_graphene_rect (&crtc_config->layout, meta_rectangle_from_graphene_rect (&crtc_config->layout,
META_ROUNDING_STRATEGY_ROUND, META_ROUNDING_STRATEGY_ROUND,
&view_layout); &view_layout);
view = g_object_new (META_TYPE_RENDERER_VIEW, view_native = g_object_new (META_TYPE_RENDERER_VIEW_NATIVE,
"name", meta_output_get_name (output), "name", meta_output_get_name (output),
"stage", meta_backend_get_stage (backend), "stage", meta_backend_get_stage (backend),
"layout", &view_layout, "layout", &view_layout,
"crtc", crtc, "crtc", crtc,
"scale", scale, "scale", scale,
"framebuffer", framebuffer, "framebuffer", framebuffer,
"offscreen", offscreen, "offscreen", offscreen,
"use-shadowfb", use_shadowfb, "use-shadowfb", use_shadowfb,
"transform", view_transform, "transform", view_transform,
"refresh-rate", crtc_mode_info->refresh_rate, "refresh-rate", crtc_mode_info->refresh_rate,
"vblank-duration-us", crtc_mode_info->vblank_duration_us, "vblank-duration-us", crtc_mode_info->vblank_duration_us,
NULL); NULL);
if (META_IS_ONSCREEN_NATIVE (framebuffer)) if (META_IS_ONSCREEN_NATIVE (framebuffer))
{ {
CoglDisplayEGL *cogl_display_egl; CoglDisplayEGL *cogl_display_egl;
CoglOnscreenEgl *onscreen_egl; CoglOnscreenEgl *onscreen_egl;
meta_onscreen_native_set_view (COGL_ONSCREEN (framebuffer), view); meta_onscreen_native_set_view (COGL_ONSCREEN (framebuffer),
META_RENDERER_VIEW (view_native));
/* Ensure we don't point to stale surfaces when creating the offscreen */ /* Ensure we don't point to stale surfaces when creating the offscreen */
cogl_display_egl = cogl_display->winsys; cogl_display_egl = cogl_display->winsys;
@ -1402,7 +1404,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
cogl_display_egl->egl_context); cogl_display_egl->egl_context);
} }
return view; return META_RENDERER_VIEW (view_native);
} }
static void static void

View File

@ -0,0 +1,43 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2020-2022 Dor Askayo
*
* 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.
*
* Written by:
* Dor Askayo <dor.askayo@gmail.com>
*/
#include "backends/native/meta-renderer-view-native.h"
struct _MetaRendererViewNative
{
MetaRendererView parent;
};
G_DEFINE_TYPE (MetaRendererViewNative, meta_renderer_view_native,
META_TYPE_RENDERER_VIEW)
static void
meta_renderer_view_native_class_init (MetaRendererViewNativeClass *klass)
{
}
static void
meta_renderer_view_native_init (MetaRendererViewNative *view_native)
{
}

View File

@ -0,0 +1,34 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2020-2022 Dor Askayo
*
* 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.
*
* Written by:
* Dor Askayo <dor.askayo@gmail.com>
*/
#ifndef META_RENDERER_VIEW_NATIVE_H
#define META_RENDERER_VIEW_NATIVE_H
#include "backends/meta-renderer-view.h"
#define META_TYPE_RENDERER_VIEW_NATIVE (meta_renderer_view_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaRendererViewNative, meta_renderer_view_native,
META, RENDERER_VIEW_NATIVE, MetaRendererView)
#endif /* META_RENDERER_VIEW_NATIVE_H */

View File

@ -813,6 +813,8 @@ if have_native_backend
'backends/native/meta-renderer-native-private.h', 'backends/native/meta-renderer-native-private.h',
'backends/native/meta-renderer-native.c', 'backends/native/meta-renderer-native.c',
'backends/native/meta-renderer-native.h', 'backends/native/meta-renderer-native.h',
'backends/native/meta-renderer-view-native.c',
'backends/native/meta-renderer-view-native.h',
'backends/native/meta-seat-impl.c', 'backends/native/meta-seat-impl.c',
'backends/native/meta-seat-impl.h', 'backends/native/meta-seat-impl.h',
'backends/native/meta-seat-native.c', 'backends/native/meta-seat-native.c',