summaryrefslogtreecommitdiff
path: root/champlain/champlain-renderer.c
blob: c3ba18094e26b141a05046817ddd07943b19f45e (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
 *
 * This library 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 library 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
/**
 * SECTION:champlain-renderer
 * @short_description: A base class of renderers
 *
 * A renderer is used to render tiles textures. A tile is rendered based on
 * the provided data - this can be arbitrary data the given renderer understands
 * (e.g. raw bitmap data, vector xml map representation and so on).
 */

#include "champlain-renderer.h"

G_DEFINE_TYPE (ChamplainRenderer, champlain_renderer, G_TYPE_INITIALLY_UNOWNED)

static void
champlain_renderer_dispose (GObject *object)
{
  G_OBJECT_CLASS (champlain_renderer_parent_class)->dispose (object);
}


static void
champlain_renderer_finalize (GObject *object)
{
  G_OBJECT_CLASS (champlain_renderer_parent_class)->finalize (object);
}


static void
champlain_renderer_class_init (ChamplainRendererClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  object_class->finalize = champlain_renderer_finalize;
  object_class->dispose = champlain_renderer_dispose;

  klass->set_data = NULL;
  klass->render = NULL;
}


/**
 * champlain_renderer_set_data:
 * @renderer: a #ChamplainRenderer
 * @data: (array length=size): data used for tile rendering
 * @size: size of the data in bytes
 *
 * Sets the data which is used to render tiles by the renderer.
 *
 * Since: 0.8
 */
void
champlain_renderer_set_data (ChamplainRenderer *renderer,
    const guint8 *data,
    guint size)
{
  g_return_if_fail (CHAMPLAIN_IS_RENDERER (renderer));

  CHAMPLAIN_RENDERER_GET_CLASS (renderer)->set_data (renderer, data, size);
}


/**
 * champlain_renderer_render:
 * @renderer: a #ChamplainRenderer
 * @tile: the tile to render
 *
 * Renders the texture for the provided tile and calls champlain_tile_set_content()
 * to set the content of the tile. When the rendering is finished, the renderer
 * emits the #ChamplainTile::render-complete signal. The tile has to be displayed manually by
 * calling champlain_tile_display_content().
 *
 * Since: 0.8
 */
void
champlain_renderer_render (ChamplainRenderer *renderer,
    ChamplainTile *tile)
{
  g_return_if_fail (CHAMPLAIN_IS_RENDERER (renderer));

  CHAMPLAIN_RENDERER_GET_CLASS (renderer)->render (renderer, tile);
}


static void
champlain_renderer_init (ChamplainRenderer *self)
{
}