Commit 9d55747f authored by Corentin Noël's avatar Corentin Noël
Browse files

Add build-system infrastructure for the memphis library

parent c012f31c
Pipeline #265274 failed with stage
in 1 minute and 55 seconds
Makefile
Makefile.in
aclocal.m4
autom4te.cache
*.pc
.deps
.libs
*.o
*.lo
*.la
*.stamp
*.gir
*.typelib
*.gi
*~
*#*
*.sw?
*.pyc
build
shumate-gtk/shumate-gtk-marshal.c
shumate-gtk/shumate-gtk-marshal.h
shumate-gtk/stamp-marshal
shumate-gtk/shumate-gtk-enum-types.c
shumate-gtk/shumate-gtk-enum-types.h
shumate-gtk/stamp-enum-types
shumate/shumate-marshal.c
shumate/shumate-marshal.h
shumate/stamp-marshal
shumate/shumate-enum-types.c
shumate/shumate-enum-types.h
shumate/stamp-enum-types
shumate/shumate-version.h
shumate/shumate-features.h
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
demos/animated-marker
demos/launcher
demos/launcher-gtk
demos/polygons
demos/url-marker
demos/local-rendering
demos/minimal
demos/minimal-gtk
demos/create-destroy-test
demos/launcher-vala
demos/launcher-vala.c
demos/markers-vala.c
depcomp
compile
docs/reference-gtk/libshumate-gtk-undeclared.txt
docs/reference-gtk/libshumate-gtk-undocumented.txt
docs/reference-gtk/libshumate-gtk-unused.txt
docs/reference-gtk/libshumate-gtk.args
docs/reference-gtk/libshumate-gtk.hierarchy
docs/reference-gtk/libshumate-gtk.interfaces
docs/reference-gtk/libshumate-gtk.prerequisites
docs/reference-gtk/libshumate-gtk.signals
docs/reference-gtk/version.xml
docs/reference-gtk/libshumate-gtk-decl-list.txt
docs/reference-gtk/libshumate-gtk-decl.txt
docs/reference-gtk/libshumate-gtk-overrides.txt
docs/reference-gtk/libshumate-gtk-types.txt
docs/reference-gtk/html/*.*
docs/reference-gtk/tmpl/*.*
docs/reference-gtk/xml/*.*
docs/reference/version.xml
docs/reference/libshumate-undeclared.txt
docs/reference/libshumate-undocumented.txt
docs/reference/libshumate-unused.txt
docs/reference/libshumate.args
docs/reference/libshumate.hierarchy
docs/reference/libshumate.interfaces
docs/reference/libshumate.prerequisites
docs/reference/libshumate.signals
docs/reference/libshumate-decl-list.txt
docs/reference/libshumate-decl.txt
docs/reference/libshumate-overrides.txt
docs/reference/libshumate-types.txt
docs/reference/html/*.*
docs/reference/tmpl/*.*
docs/reference/xml/*.*
gtk-doc.make
install-sh
libtool
ltmain.sh
missing
stamp-h1
tags
INSTALL
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
m4/gtk-doc.m4
\ No newline at end of file
subprojects/memphis
......@@ -15,6 +15,10 @@ libshumate_reference_ignored_h = [
'shumate.h',
]
if not memphis_support
libshumate_reference_ignored_h += 'shumate-memphis-map-source.h'
endif
libshumate_reference_source_folders = [
join_paths(srcdir, 'shumate'),
join_paths(builddir, 'shumate'),
......@@ -54,6 +58,7 @@ gnome.gtkdoc(
main_sgml: 'libshumate-docs.sgml',
gobject_typesfile: files('libshumate.types'),
src_dir: libshumate_reference_source_folders,
c_args: extra_cflags,
dependencies: libshumate_dep,
scan_args: libshumate_reference_scan_args,
mkdb_args: libshumate_reference_mkdb_args,
......
......@@ -100,6 +100,13 @@ if generate_vapi and not vapigen_dep.found()
generate_vapi = false
endif
memphis_support = get_option('memphis')
if memphis_support
memphis_dep = dependency('memphis',
fallback : ['memphis', 'memphis_dep'])
add_project_arguments('-DHAS_MEMPHIS=1', language: 'c')
endif
subdir('data')
subdir('shumate')
......@@ -121,6 +128,7 @@ summary = [
' Documentation: @0@'.format(build_gtk_doc),
' Introspection: @0@'.format(generate_gir),
' Vala API: @0@'.format(generate_vapi),
' Memphis support: @0@'.format(memphis_support),
'',
'Directories:',
' prefix: @0@'.format(prefix),
......
......@@ -11,4 +11,8 @@ option('gtk_doc',
option('demos',
type: 'boolean', value: false,
description: 'Build demonstration programs')
\ No newline at end of file
description: 'Build demonstration programs')
option('memphis',
type: 'boolean', value: false,
description: 'Build memphis support')
......@@ -67,9 +67,15 @@ libshumate_deps = [
gtk_dep,
cairo_dep,
sqlite_dep,
libsoup_dep,
libsoup_dep
]
if memphis_support
libshumate_public_h += 'shumate-memphis-map-source.h'
libshumate_sources += 'shumate-memphis-map-source.c'
libshumate_deps += memphis_dep
endif
libshumate_c_args = [
'-DHAVE_CONFIG_H',
'-DSHUMATE_COMPILATION',
......@@ -225,6 +231,10 @@ libshumate_dep = declare_dependency(
sources: libshumate_dep_sources,
)
extra_cflags = []
if memphis_support
extra_cflags += '-DHAS_MEMPHIS=1'
endif
libshumate_pc = pkg.generate(
libshumate_lib,
name: package_string,
......@@ -232,4 +242,5 @@ libshumate_pc = pkg.generate(
requires: [glib_dep, gobject_dep, gtk_dep],
subdirs: package_string,
install_dir: pkgconfigdir,
extra_cflags: extra_cflags,
)
......@@ -44,6 +44,7 @@
#include "shumate-file-cache.h"
#include "shumate-enum-types.h"
#include "shumate-map-source.h"
#include "shumate-memphis-map-source.h"
#include "shumate-marshal.h"
#include "shumate-map-source-chain.h"
......@@ -333,7 +334,8 @@ shumate_map_source_factory_create_cached_source (ShumateMapSourceFactory *factor
shumate_map_source_chain_push (source_chain, file_cache);
shumate_map_source_chain_push (source_chain, memory_cache);
return SHUMATE_MAP_SOURCE (source_chain);
//return SHUMATE_MAP_SOURCE (source_chain);
return SHUMATE_MAP_SOURCE (shumate_memphis_map_source_new ());
}
......
/*
* Copyright 2021 Collabora Ltd. (https://www.collabora.com)
* Copyright 2021 Corentin Noël <corentin.noel@collabora.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
*/
#include "shumate-memphis-map-source.h"
#include <memphis/memphis.h>
struct _ShumateMemphisMapSource
{
ShumateMapSource parent_instance;
MemphisRuleSet *rules;
MemphisMap *map;
MemphisRenderer *renderer;
};
G_DEFINE_TYPE (ShumateMemphisMapSource, shumate_memphis_map_source, SHUMATE_TYPE_MAP_SOURCE)
enum {
PROP_0,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
static const char *
shumate_memphis_map_source_get_id (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), NULL);
return "memphis";
}
static const char *
shumate_memphis_map_source_get_name (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), NULL);
return "Memphis";
}
static const char *
shumate_memphis_map_source_get_license (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), NULL);
return "NONE";
}
static const char *
shumate_memphis_map_source_get_license_uri (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), NULL);
return "NONE";
}
static guint
shumate_memphis_map_source_get_min_zoom_level (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), 0);
return 12;
}
static guint
shumate_memphis_map_source_get_max_zoom_level (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), 0);
return 14;
}
static guint
shumate_memphis_map_source_get_tile_size (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), 0);
return 512;
}
static ShumateMapProjection
shumate_memphis_map_source_get_projection (ShumateMapSource *map_source)
{
g_return_val_if_fail (SHUMATE_IS_MEMPHIS_MAP_SOURCE (map_source), SHUMATE_MAP_PROJECTION_MERCATOR);
return SHUMATE_MAP_PROJECTION_MERCATOR;
}
static void
shumate_memphis_map_source_fill_tile (ShumateMapSource *map_source,
ShumateTile *tile,
GCancellable *cancellable)
{
ShumateMemphisMapSource *self = (ShumateMemphisMapSource *)map_source;
g_autoptr(GdkTexture) texture = NULL;
g_autoptr(GBytes) bytes = NULL;
int width = gtk_widget_get_width (GTK_WIDGET (tile));
int height = gtk_widget_get_width (GTK_WIDGET (tile));
int x = shumate_tile_get_x (tile);
int y = shumate_tile_get_y (tile);
int zoom_level = shumate_tile_get_zoom_level (tile);
cairo_surface_t *surface;
cairo_t *cr;
if (!memphis_renderer_tile_has_data (self->renderer, x, y, zoom_level)) {
g_critical ("Unable to render tile at: %d %d %d", x, y, zoom_level);
}
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 512, 512);
cr = cairo_create(surface);
memphis_renderer_draw_tile (self->renderer, cr, x, y, zoom_level);
cairo_destroy(cr);
cairo_surface_flush(surface);
int stride = cairo_image_surface_get_stride (surface);
bytes = g_bytes_new (cairo_image_surface_get_data (surface), cairo_image_surface_get_width (surface) * stride);
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
cairo_surface_destroy(surface);
shumate_tile_set_texture (tile, texture);
shumate_tile_set_fade_in (tile, TRUE);
shumate_tile_set_state (tile, SHUMATE_STATE_DONE);
}
static void
shumate_memphis_map_source_dispose (GObject *object)
{
ShumateMemphisMapSource *self = (ShumateMemphisMapSource *)object;
g_clear_object (&self->renderer);
g_clear_object (&self->map);
g_clear_object (&self->rules);
G_OBJECT_CLASS (shumate_memphis_map_source_parent_class)->dispose (object);
}
static void
shumate_memphis_map_source_finalize (GObject *object)
{
ShumateMemphisMapSource *self = (ShumateMemphisMapSource *)object;
G_OBJECT_CLASS (shumate_memphis_map_source_parent_class)->finalize (object);
}
static void
shumate_memphis_map_source_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ShumateMemphisMapSource *self = SHUMATE_MEMPHIS_MAP_SOURCE (object);
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
shumate_memphis_map_source_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ShumateMemphisMapSource *self = SHUMATE_MEMPHIS_MAP_SOURCE (object);
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
shumate_memphis_map_source_class_init (ShumateMemphisMapSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ShumateMapSourceClass *map_source_class = SHUMATE_MAP_SOURCE_CLASS (klass);
object_class->dispose = shumate_memphis_map_source_dispose;
object_class->finalize = shumate_memphis_map_source_finalize;
object_class->get_property = shumate_memphis_map_source_get_property;
object_class->set_property = shumate_memphis_map_source_set_property;
map_source_class->get_id = shumate_memphis_map_source_get_id;
map_source_class->get_name = shumate_memphis_map_source_get_name;
map_source_class->get_license = shumate_memphis_map_source_get_license;
map_source_class->get_license_uri = shumate_memphis_map_source_get_license_uri;
map_source_class->get_min_zoom_level = shumate_memphis_map_source_get_min_zoom_level;
map_source_class->get_max_zoom_level = shumate_memphis_map_source_get_max_zoom_level;
map_source_class->get_tile_size = shumate_memphis_map_source_get_tile_size;
map_source_class->get_projection = shumate_memphis_map_source_get_projection;
map_source_class->fill_tile = shumate_memphis_map_source_fill_tile;
}
static gchar *map_file = "map.osm";
static gchar *rule_file = "default-rules.xml";
static void
shumate_memphis_map_source_init (ShumateMemphisMapSource *self)
{
g_autoptr(GError) error = NULL;
self->rules = memphis_rule_set_new ();
if (!memphis_rule_set_load_from_file (self->rules, rule_file, &error)) {
g_critical ("%s", error->message);
g_clear_error (&error);
return;
}
self->map = memphis_map_new ();
if (!memphis_map_load_from_file (self->map, map_file, &error)) {
g_critical ("%s", error->message);
g_clear_error (&error);
return;
}
self->renderer = memphis_renderer_new_full (self->rules, self->map);
memphis_renderer_set_resolution (self->renderer, 512);
}
/**
* shumate_memphis_map_source_new:
*
* Create a new #ShumateMemphisMapSource.
*
* Returns: (transfer full): a newly created #ShumateMemphisMapSource
*/
ShumateMemphisMapSource *
shumate_memphis_map_source_new (void)
{
return g_object_new (SHUMATE_TYPE_MEMPHIS_MAP_SOURCE, NULL);
}
/*
* Copyright 2021 Collabora Ltd. (https://www.collabora.com)
* Copyright 2021 Corentin Noël <corentin.noel@collabora.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
*/
#if !defined (__SHUMATE_SHUMATE_H_INSIDE__) && !defined (SHUMATE_COMPILATION)
#error "Only <shumate/shumate.h> can be included directly."
#endif
#ifndef _SHUMATE_MEMPHIS_MAP_SOURCE_H_
#define _SHUMATE_MEMPHIS_MAP_SOURCE_H_
#include <shumate/shumate-map-source.h>
G_BEGIN_DECLS
#define SHUMATE_TYPE_MEMPHIS_MAP_SOURCE shumate_memphis_map_source_get_type()
G_DECLARE_FINAL_TYPE (ShumateMemphisMapSource, shumate_memphis_map_source, SHUMATE, MEMPHIS_MAP_SOURCE, ShumateMapSource)
ShumateMemphisMapSource *shumate_memphis_map_source_new (void);
G_END_DECLS
#endif
......@@ -49,6 +49,10 @@
#include "shumate/shumate-map-source-chain.h"
#if HAS_MEMPHIS
#include "shumate/shumate-memphis-map-source.h"
#endif
#include "shumate/shumate-network-tile-source.h"
#include "shumate/shumate-error-tile-source.h"
......
[wrap-git]
directory=memphis
url=https://github.com/tintou/memphis.git
push-url=ssh://git@github.com:tintou/memphis.git
revision=master
depth=1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment