[sapwood] add a convenience function sapwood_create_surface()
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] add a convenience function sapwood_create_surface()
- Date: Fri, 13 Aug 2010 11:40:31 +0000 (UTC)
commit 808a51384958c5970b986484a203afc80f561934
Author: Sven Herzberg <herzi gnome-de org>
Date: Fri Aug 13 10:10:41 2010 +0200
add a convenience function sapwood_create_surface()
This function is a convenience function to create a cairo_surface_t*
from a GdkDrawable*.
* Makefile.am,
* sapwood/Makefile.inc: build system updates
* sapwood/sapwood-cairo.c,
* sapwood/sapwood-cairo.h: new shared library (this one can be used for
the server and the engine at some point)
* engine/Makefile.am: let libsapwood-private.la depend on libsapwood.la
* engine/sapwood-pixmap.c: use the new function in order to create the
temporary surfaces
Makefile.am | 4 ++++
engine/Makefile.am | 5 ++++-
engine/sapwood-pixmap.c | 7 ++++---
sapwood/Makefile.inc | 18 ++++++++++++++++++
sapwood/sapwood-cairo.c | 40 ++++++++++++++++++++++++++++++++++++++++
sapwood/sapwood-cairo.h | 35 +++++++++++++++++++++++++++++++++++
6 files changed, 105 insertions(+), 4 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index bc25c93..5e30320 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,10 @@
+noinst_LTLIBRARIES=
+
include $(top_srcdir)/Makefile.decl
+include sapwood/Makefile.inc
SUBDIRS=\
+ . \
protocol \
engine \
server \
diff --git a/engine/Makefile.am b/engine/Makefile.am
index 692a7bb..c969526 100644
--- a/engine/Makefile.am
+++ b/engine/Makefile.am
@@ -36,8 +36,11 @@ libsapwood_client_la_LIBADD=\
libsapwood_private_la_CPPFLAGS=\
-DG_LOG_DOMAIN=\""sapwood-private"\" \
- $(AM_CPPFLAGS)
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/sapwood \
+ $(NULL)
libsapwood_private_la_LIBADD=\
+ ../libsapwood.la \
libsapwood-client.la \
$(NULL)
libsapwood_private_la_SOURCES=\
diff --git a/engine/sapwood-pixmap.c b/engine/sapwood-pixmap.c
index 5f9b2d0..f06c0fb 100644
--- a/engine/sapwood-pixmap.c
+++ b/engine/sapwood-pixmap.c
@@ -20,6 +20,7 @@
*/
#include <config.h>
+#include "sapwood-cairo.h"
#include "sapwood-debug.h"
#include "sapwood-pixmap-priv.h"
#include "sapwood-proto.h"
@@ -542,10 +543,10 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
if ((width > 0 && width < tmp_width) || (height > 0 && height < tmp_height))
{
- cairo_t* tmp_cr = gdk_cairo_create (tmp_mask);
- sapwood_crop_pixmap (tmp, cairo_get_target (tmp_cr), width, height,
+ cairo_surface_t* mask_surface = sapwood_create_surface (tmp_mask);
+ sapwood_crop_pixmap (tmp, mask_surface, width, height,
self->width, self->height);
- cairo_destroy (tmp_cr);
+ cairo_surface_destroy (mask_surface);
cairo_rectangle (cr, 0, 0, width, height);
cairo_clip (cr);
diff --git a/sapwood/Makefile.inc b/sapwood/Makefile.inc
new file mode 100644
index 0000000..18e0d1b
--- /dev/null
+++ b/sapwood/Makefile.inc
@@ -0,0 +1,18 @@
+# vim:set ft=automake:
+
+AM_CPPFLAGS=$(WARN_CFLAGS)
+
+noinst_LTLIBRARIES+=libsapwood.la
+libsapwood_la_CPPFLAGS=\
+ -DG_LOG_DOMAIN=\""libsapwood"\" \
+ $(AM_CPPFLAGS) \
+ $(GDK_CFLAGS) \
+ $(NULL)
+libsapwood_la_LIBADD=\
+ $(LIBADD) \
+ $(GDK_LIBS) \
+ $(NULL)
+libsapwood_la_SOURCES=\
+ sapwood/sapwood-cairo.c \
+ sapwood/sapwood-cairo.h \
+ $(NULL)
diff --git a/sapwood/sapwood-cairo.c b/sapwood/sapwood-cairo.c
new file mode 100644
index 0000000..669d773
--- /dev/null
+++ b/sapwood/sapwood-cairo.c
@@ -0,0 +1,40 @@
+/* This file is part of ...
+ *
+ * AUTHORS
+ * Sven Herzberg <set the EMAIL_ADDRESS environment variable>
+ *
+ * Copyright (C) 2010 Sven Herzberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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
+ */
+
+#include "sapwood-cairo.h"
+
+cairo_surface_t*
+sapwood_create_surface (GdkDrawable* drawable)
+{
+ cairo_surface_t* result;
+ cairo_t * cr;
+
+ cr = gdk_cairo_create (drawable);
+ result = cairo_get_target (cr);
+ cairo_surface_reference (result);
+ cairo_destroy (cr);
+
+ return result;
+}
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
diff --git a/sapwood/sapwood-cairo.h b/sapwood/sapwood-cairo.h
new file mode 100644
index 0000000..cd0d02a
--- /dev/null
+++ b/sapwood/sapwood-cairo.h
@@ -0,0 +1,35 @@
+/* This file is part of sapwood
+ *
+ * Copyright (C) 2010 Sven Herzberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 SAPWOOD_CAIRO_H
+#define SAPWOOD_CAIRO_H
+
+#include <cairo.h>
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+cairo_surface_t* sapwood_create_surface (GdkDrawable* drawable);
+
+G_END_DECLS
+
+#endif /* !SAPWOOD_CAIRO_H */
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]