champlain-renderer.c 2.91 KB
Newer Older
1
/*
Jiří Techet's avatar
Jiří Techet committed
2
 * Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * 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
 */
Jiří Techet's avatar
Jiří Techet committed
18 19 20 21 22 23 24 25
/**
 * 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).
 */
26 27 28

#include "champlain-renderer.h"

29
G_DEFINE_TYPE (ChamplainRenderer, champlain_renderer, G_TYPE_INITIALLY_UNOWNED)
30 31 32 33 34 35 36

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

37

38 39 40 41 42 43 44
static void
champlain_renderer_finalize (GObject *object)
{
  G_OBJECT_CLASS (champlain_renderer_parent_class)->finalize (object);
}


45 46
static void
champlain_renderer_class_init (ChamplainRendererClass *klass)
47
{
48
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
49 50 51 52 53 54 55 56 57

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

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


Jiří Techet's avatar
Jiří Techet committed
58 59 60 61 62 63 64 65 66 67
/**
 * champlain_renderer_set_data:
 * @renderer: a #ChamplainRenderer
 * @data: 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
 */
68 69
void
champlain_renderer_set_data (ChamplainRenderer *renderer,
70
    const gchar *data,
71
    guint size)
72 73 74 75 76 77 78
{
  g_return_if_fail (CHAMPLAIN_IS_RENDERER (renderer));

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


Jiří Techet's avatar
Jiří Techet committed
79 80 81 82 83 84 85
/**
 * 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
Jiří Techet's avatar
Jiří Techet committed
86
 * emits the #ChamplainTile::render-complete signal. The tile has to be displayed manually by
Jiří Techet's avatar
Jiří Techet committed
87 88 89 90
 * calling champlain_tile_display_content().
 *
 * Since: 0.8
 */
91 92 93
void
champlain_renderer_render (ChamplainRenderer *renderer,
    ChamplainTile *tile)
94 95 96 97 98 99 100
{
  g_return_if_fail (CHAMPLAIN_IS_RENDERER (renderer));

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


101 102
static void
champlain_renderer_init (ChamplainRenderer *self)
103 104
{
}