summaryrefslogtreecommitdiff
path: root/src/compositor/meta-surface-xrender.c
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2019-10-06 16:29:52 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2019-10-06 16:29:52 +0300
commit887153ee9ad8485845bc70b1a11437c10425af18 (patch)
treeb06e5f3dd9ce8b3e054b0436f08867fde9b4494a /src/compositor/meta-surface-xrender.c
parent69f3e047d9a546a413f696468f5c99ba3e7d3017 (diff)
downloadmetacity-887153ee9ad8485845bc70b1a11437c10425af18.tar.gz
compositor-xrender: move picture to MetaSurfaceXRender
Diffstat (limited to 'src/compositor/meta-surface-xrender.c')
-rw-r--r--src/compositor/meta-surface-xrender.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/compositor/meta-surface-xrender.c b/src/compositor/meta-surface-xrender.c
index f4c88841..a6e95e2b 100644
--- a/src/compositor/meta-surface-xrender.c
+++ b/src/compositor/meta-surface-xrender.c
@@ -18,25 +18,129 @@
#include "config.h"
#include "meta-surface-xrender.h"
+#include "display.h"
+#include "errors.h"
+
struct _MetaSurfaceXRender
{
MetaSurface parent;
+
+ Picture picture;
};
G_DEFINE_TYPE (MetaSurfaceXRender, meta_surface_xrender, META_TYPE_SURFACE)
static void
+free_picture (MetaSurfaceXRender *self)
+{
+ MetaWindow *window;
+ MetaDisplay *display;
+ Display *xdisplay;
+
+ if (self->picture == None)
+ return;
+
+ window = meta_surface_get_window (META_SURFACE (self));
+
+ display = meta_window_get_display (window);
+ xdisplay = meta_display_get_xdisplay (display);
+
+ XRenderFreePicture (xdisplay, self->picture);
+ self->picture = None;
+}
+
+static Picture
+get_window_picture (MetaSurfaceXRender *self)
+{
+ MetaWindow *window;
+ MetaDisplay *display;
+ Display *xdisplay;
+ Window xwindow;
+ Visual *xvisual;
+ XRenderPictFormat *format;
+ Pixmap pixmap;
+ Drawable drawable;
+ XRenderPictureAttributes pa;
+ unsigned int pa_mask;
+ Picture picture;
+
+ window = meta_surface_get_window (META_SURFACE (self));
+
+ display = meta_window_get_display (window);
+ xdisplay = meta_display_get_xdisplay (display);
+
+ xwindow = meta_window_get_toplevel_xwindow (window);
+ xvisual = meta_window_get_toplevel_xvisual (window);
+
+ format = XRenderFindVisualFormat (xdisplay, xvisual);
+
+ if (format == NULL)
+ {
+ xvisual = DefaultVisual (xdisplay, DefaultScreen (xdisplay));
+ format = XRenderFindVisualFormat (xdisplay, xvisual);
+ }
+
+ if (format == NULL)
+ return None;
+
+ pixmap = meta_surface_get_pixmap (META_SURFACE (self));
+ drawable = pixmap != None ? pixmap : xwindow;
+
+ pa.subwindow_mode = IncludeInferiors;
+ pa_mask = CPSubwindowMode;
+
+ meta_error_trap_push (display);
+ picture = XRenderCreatePicture (xdisplay, drawable, format, pa_mask, &pa);
+ meta_error_trap_pop (display);
+
+ return picture;
+}
+
+static void
+meta_surface_xrender_finalize (GObject *object)
+{
+ MetaSurfaceXRender *self;
+
+ self = META_SURFACE_XRENDER (object);
+
+ free_picture (self);
+
+ G_OBJECT_CLASS (meta_surface_xrender_parent_class)->finalize (object);
+}
+
+static void
+meta_surface_xrender_free_pixmap (MetaSurface *surface)
+{
+ MetaSurfaceXRender *self;
+
+ self = META_SURFACE_XRENDER (surface);
+
+ free_picture (self);
+}
+
+static void
meta_surface_xrender_pre_paint (MetaSurface *surface)
{
+ MetaSurfaceXRender *self;
+
+ self = META_SURFACE_XRENDER (surface);
+
+ if (self->picture == None)
+ self->picture = get_window_picture (self);
}
static void
meta_surface_xrender_class_init (MetaSurfaceXRenderClass *self_class)
{
+ GObjectClass *object_class;
MetaSurfaceClass *surface_class;
+ object_class = G_OBJECT_CLASS (self_class);
surface_class = META_SURFACE_CLASS (self_class);
+ object_class->finalize = meta_surface_xrender_finalize;
+
+ surface_class->free_pixmap = meta_surface_xrender_free_pixmap;
surface_class->pre_paint = meta_surface_xrender_pre_paint;
}
@@ -44,3 +148,9 @@ static void
meta_surface_xrender_init (MetaSurfaceXRender *self)
{
}
+
+Picture
+meta_surface_xrender_get_picture (MetaSurfaceXRender *self)
+{
+ return self->picture;
+}