summaryrefslogtreecommitdiff
path: root/backend/impress/render.c
blob: 67b80756e2ade2b86f5602a94a45b5f0db48e662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* imposter (OO.org Impress viewer)
** Copyright (C) 2003-2005 Gurer Ozen
** This code is free software; you can redistribute it and/or
** modify it under the terms of GNU General Public License.
*/

#include <config.h>
#include "common.h"
#include "internal.h"

ImpRenderCtx *
imp_create_context(const ImpDrawer *drw)
{
	ImpRenderCtx *ctx;

	ctx = calloc(1, sizeof(ImpRenderCtx));
	if (!ctx) return NULL;
	ctx->drw = drw;
	return ctx;
}

void
imp_context_set_page(ImpRenderCtx *ctx, ImpPage *page)
{
	ctx->page = page;
	ctx->content = page->doc->content;
	ctx->styles = page->doc->styles;
}

void
imp_context_set_step(ImpRenderCtx *ctx, int step)
{
	ctx->step = step;
}

void
imp_render(ImpRenderCtx *ctx, void *drw_data)
{
	// find drawing area size
	ctx->drw->get_size(drw_data, &ctx->pix_w, &ctx->pix_h);
	// find page size
	ctx->page->doc->get_geometry(ctx);
	// calculate ratio
	ctx->fact_x = ctx->pix_w / ctx->cm_w;
	ctx->fact_y = ctx->pix_h / ctx->cm_h;
	// call renderer
	ctx->page->doc->render_page(ctx, drw_data);
}

void
imp_delete_context(ImpRenderCtx *ctx)
{
	free(ctx);
}