From e62f234e68000715b3cad89c0383bece90a14553 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 16 Feb 2010 22:00:09 -0500 Subject: [PATCH] start on cairo rendering --- Makefile.am | 6 +++++- configure.ac | 4 ++++ obrender/render.h | 1 + obrender/window.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ obrender/window.h | 29 +++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 obrender/window.c create mode 100644 obrender/window.h diff --git a/Makefile.am b/Makefile.am index d5e60b6d..e80f1918 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ obrender_libobrender_la_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(XML_CFLAGS) \ $(PANGO_CFLAGS) \ + $(CAIRO_CFLAGS) \ -DG_LOG_DOMAIN=\"ObRender\" \ -DDEFAULT_THEME=\"$(theme)\" obrender_libobrender_la_LDFLAGS = \ @@ -71,6 +72,7 @@ obrender_libobrender_la_LDFLAGS = \ obrender_libobrender_la_LIBADD = \ $(X_LIBS) \ $(PANGO_LIBS) \ + $(CAIRO_LIBS) \ $(GLIB_LIBS) \ $(XML_LIBS) obrender_libobrender_la_SOURCES = \ @@ -94,7 +96,9 @@ obrender_libobrender_la_SOURCES = \ obrender/render.h \ obrender/render.c \ obrender/theme.h \ - obrender/theme.c + obrender/theme.c \ + obrender/window.h \ + obrender/window.c ## obt ## diff --git a/configure.ac b/configure.ac index f58f7e5c..7a4d0b89 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,10 @@ PKG_CHECK_MODULES(PANGO, [pango >= 1.8.0 pangoxft >= 1.8.0]) AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_LIBS) +PKG_CHECK_MODULES(CAIRO, [cairo-xlib]) +AC_SUBST(CAIRO_CFLAGS) +AC_SUBST(CAIRO_LIBS) + PKG_CHECK_MODULES(XML, [libxml-2.0 >= 2.6.0]) AC_SUBST(XML_CFLAGS) AC_SUBST(XML_LIBS) diff --git a/obrender/render.h b/obrender/render.h index cf9883a9..d96d1e33 100644 --- a/obrender/render.h +++ b/obrender/render.h @@ -46,6 +46,7 @@ typedef struct _RrColor RrColor; typedef struct _RrImage RrImage; typedef struct _RrImagePic RrImagePic; typedef struct _RrImageCache RrImageCache; +typedef struct _RrWindow RrWindow; typedef guint32 RrPixel32; typedef guint16 RrPixel16; diff --git a/obrender/window.c b/obrender/window.c new file mode 100644 index 00000000..42d92a82 --- /dev/null +++ b/obrender/window.c @@ -0,0 +1,55 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + window.c for the Openbox window manager + Copyright (c) 2010 Dana Jansens + + 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. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#include "window.h" +#include "instance.h" +#include "render.h" +#include +#include + +struct _RrWindow { + guint ref; + cairo_surface_t *sur; + cairo_t *cr; +}; + + +RrWindow* RrWindowNew(RrInstance *inst) +{ + RrWindow *win; + + win = g_slice_new(RrWindow); + win->sur = cairo_xlib_surface_create(inst->display, None, inst->visual, + 1, 1); + win->cr = cairo_create(win->sur); + + return win; +} +void RrWindowRef(RrWindow *win) +{ + ++win->ref; +} + +void RrWindowUnref(RrWindow *win) +{ + if (win && --win->ref < 1) { + cairo_destroy(win->cr); + cairo_surface_destroy(win->sur); + g_slice_free(RrWindow, win); + } +} diff --git a/obrender/window.h b/obrender/window.h new file mode 100644 index 00000000..5d819307 --- /dev/null +++ b/obrender/window.h @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + window.h for the Openbox window manager + Copyright (c) 2010 Dana Jansens + + 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. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#ifndef __render_window_h +#define __render_window_h + +#include "render.h" +#include "geom.h" + +RrWindow* RrWindowNew(RrInstance *inst); +void RrWindowRef(RrWindow *win); +void RrWindowUnref(RrWindow *win); + +#endif -- 2.39.2