[lasem] dom_view: remove lsm_dom_view_set_cairo.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] dom_view: remove lsm_dom_view_set_cairo.
- Date: Sun, 12 Sep 2010 18:09:36 +0000 (UTC)
commit 451726895ef8c53d5a2729ebc46a97676192c871
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sun Sep 12 20:04:46 2010 +0200
dom_view: remove lsm_dom_view_set_cairo.
Fix https://bugzilla.gnome.org/show_bug.cgi?id=628912
src/lasemrender.c | 4 +--
src/lasemtest.c | 8 ++---
src/lsmdomview.c | 76 ++++++++++++++++++++++++++++-------------------------
src/lsmdomview.h | 3 +-
4 files changed, 45 insertions(+), 46 deletions(-)
---
diff --git a/src/lasemrender.c b/src/lasemrender.c
index 7bf3d9e..ea811ab 100644
--- a/src/lasemrender.c
+++ b/src/lasemrender.c
@@ -211,9 +211,7 @@ int main(int argc, char **argv)
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
- lsm_dom_view_set_cairo (view, cairo);
-
- lsm_dom_view_render (view, 0, 0);
+ lsm_dom_view_render (view, cairo, 0, 0);
switch (format) {
case FORMAT_PNG:
diff --git a/src/lasemtest.c b/src/lasemtest.c
index 835f549..410b616 100644
--- a/src/lasemtest.c
+++ b/src/lasemtest.c
@@ -146,14 +146,12 @@ lasem_test_render (char const *filename)
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
- lsm_dom_view_set_cairo (LSM_DOM_VIEW (view), cairo);
-
- cairo_destroy (cairo);
-
- lsm_dom_view_render (LSM_DOM_VIEW (view), 1, 1);
+ lsm_dom_view_render (LSM_DOM_VIEW (view), cairo, 1, 1);
cairo_surface_write_to_png (surface, png_filename);
+ cairo_destroy (cairo);
+
g_object_unref (view);
g_object_unref (document);
diff --git a/src/lsmdomview.c b/src/lsmdomview.c
index e8db2ea..5d75a16 100644
--- a/src/lsmdomview.c
+++ b/src/lsmdomview.c
@@ -70,42 +70,8 @@ lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned in
*height = (double) (0.5 + height_pt * resolution_ppi / 72.0);
}
-void
-lsm_dom_view_render (LsmDomView *view, double x, double y)
-{
- LsmDomViewClass *view_class;
- double resolution_ppi;
-
- g_return_if_fail (LSM_IS_DOM_VIEW (view));
- g_return_if_fail (LSM_IS_DOM_DOCUMENT (view->document));
- g_return_if_fail (view->cairo != NULL);
-
- resolution_ppi = lsm_dom_document_get_resolution (view->document);
-
- cairo_save (view->cairo);
-
- cairo_translate (view->cairo, x, y);
-
- view_class = LSM_DOM_VIEW_GET_CLASS (view);
- if (view_class->render != NULL)
- view_class->render (view);
-
- cairo_restore (view->cairo);
-
- lsm_debug ("render", "[LsmDomView::render] cairo status = %s",
- cairo_status_to_string (cairo_status (view->cairo)));
-}
-
-void
-lsm_dom_view_set_debug (LsmDomView *view, gboolean debug)
-{
- g_return_if_fail (LSM_IS_DOM_VIEW (view));
-
- view->debug = debug;
-}
-
-void
-lsm_dom_view_set_cairo (LsmDomView *view, cairo_t *cairo)
+static void
+lsm_dom_view_set_cairo_context (LsmDomView *view, cairo_t *cairo)
{
PangoContext *context;
PangoFontDescription *font_description;
@@ -159,6 +125,44 @@ lsm_dom_view_set_cairo (LsmDomView *view, cairo_t *cairo)
}
void
+lsm_dom_view_render (LsmDomView *view, cairo_t *cairo, double x, double y)
+{
+ LsmDomViewClass *view_class;
+ double resolution_ppi;
+
+ g_return_if_fail (LSM_IS_DOM_VIEW (view));
+ g_return_if_fail (LSM_IS_DOM_DOCUMENT (view->document));
+ g_return_if_fail (cairo != NULL);
+
+ lsm_dom_view_set_cairo_context (view, cairo);
+
+ resolution_ppi = lsm_dom_document_get_resolution (view->document);
+
+ cairo_save (view->cairo);
+
+ cairo_translate (view->cairo, x, y);
+
+ view_class = LSM_DOM_VIEW_GET_CLASS (view);
+ if (view_class->render != NULL)
+ view_class->render (view);
+
+ cairo_restore (view->cairo);
+
+ lsm_debug ("render", "[LsmDomView::render] cairo status = %s",
+ cairo_status_to_string (cairo_status (view->cairo)));
+
+ lsm_dom_view_set_cairo_context (view, NULL);
+}
+
+void
+lsm_dom_view_set_debug (LsmDomView *view, gboolean debug)
+{
+ g_return_if_fail (LSM_IS_DOM_VIEW (view));
+
+ view->debug = debug;
+}
+
+void
lsm_dom_view_set_document (LsmDomView *view, LsmDomDocument *document)
{
g_return_if_fail (LSM_IS_DOM_VIEW (view));
diff --git a/src/lsmdomview.h b/src/lsmdomview.h
index a5ef870..e74e1f0 100644
--- a/src/lsmdomview.h
+++ b/src/lsmdomview.h
@@ -63,12 +63,11 @@ struct _LsmDomViewClass {
GType lsm_dom_view_get_type (void);
-void lsm_dom_view_render (LsmDomView *view, double x, double y);
+void lsm_dom_view_render (LsmDomView *view, cairo_t *cairo, double x, double y);
void lsm_dom_view_get_size (LsmDomView *view, double *width, double *height);
void lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned int *height);
void lsm_dom_view_set_document (LsmDomView *view, LsmDomDocument *document);
-void lsm_dom_view_set_cairo (LsmDomView *view, cairo_t *cr);
void lsm_dom_view_set_debug (LsmDomView *view, gboolean debug);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]