Skip to content

Commit

Permalink
Fix various --border problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mtheall committed Jan 7, 2022
1 parent e03b6e1 commit 70e1ed3
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 165 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ AC_PROG_CXX

AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-Wall -pthread -flto -pipe])
AX_APPEND_LINK_FLAGS([-flto])
AX_CXX_COMPILE_STDCXX_11(noext, mandatory)
AC_LANG_POP()

AC_DEFINE(NDEBUG)

AC_CHECK_PROGS([DOXYGEN], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([Doxyfile])])
Expand Down
4 changes: 2 additions & 2 deletions include/atlas.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------
* Copyright (c) 2017-2019
* Copyright (c) 2017-2021
* Michael Theall (mtheall)
*
* This file is part of tex3ds.
Expand Down Expand Up @@ -42,5 +42,5 @@ struct Atlas
Atlas &operator= (const Atlas &other) = delete;
Atlas &operator= (Atlas &&other) = delete;

static Atlas build (const std::vector<std::string> &paths, bool trim, bool border);
static Atlas build (const std::vector<std::string> &paths, bool trim, unsigned int border);
};
61 changes: 57 additions & 4 deletions include/subimage.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------
* Copyright (c) 2017-2019
* Copyright (c) 2017-2021
* Michael Theall (mtheall)
*
* This file is part of tex3ds.
Expand All @@ -26,6 +26,8 @@

#include <libgen.h>

#include <cassert>
#include <cstdio>
#include <string>
#include <vector>

Expand All @@ -37,22 +39,73 @@ struct SubImage
float top; ///< Top v-coordinate
float right; ///< Right u-coordinate
float bottom; ///< Bottom v-coordinate
bool rotated; ///< Whether sub-image is rotated

SubImage (size_t index,
const std::string &name,
float left,
float top,
float right,
float bottom)
: index (index), left (left), top (top), right (right), bottom (bottom)
float bottom,
bool rotated)
: index (index),
name (name),
left (left),
top (top),
right (right),
bottom (bottom),
rotated (rotated)
{
assert (rotated == (top < bottom));

if (name.empty ())
return;

std::vector<char> path (name.begin (), name.end ());
path.push_back (0);
path.emplace_back (0);
this->name = ::basename (path.data ());
}

bool operator< (const SubImage &rhs) const
{
return index < rhs.index;
}

void print (unsigned int width, unsigned int height) const
{
if (rotated)
std::printf ("%4zu \"%s\"\n"
"\ttl %5.1lf %5.1lf\n"
"\ttr %5.1lf %5.1lf\n"
"\tbl %5.1lf %5.1lf\n"
"\tbr %5.1lf %5.1lf\n"
"\trotated\n",
index,
name.c_str (),
top * width,
left * height,
top * width,
right * height,
bottom * width,
left * height,
bottom * width,
right * height);

else
std::printf ("%4zu \"%s\"\n"
"\ttl %5.1lf %5.1lf\n"
"\ttr %5.1lf %5.1lf\n"
"\tbl %5.1lf %5.1lf\n"
"\tbr %5.1lf %5.1lf\n",
index,
name.c_str (),
left * width,
top * height,
right * width,
top * height,
left * width,
bottom * height,
right * width,
bottom * height);
}
};
44 changes: 44 additions & 0 deletions m4/ax_append_link_flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the linker works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
# used. During the check the flag is always added to the linker's flags.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 7

AC_DEFUN([AX_APPEND_LINK_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
done
])dnl AX_APPEND_LINK_FLAGS
18 changes: 16 additions & 2 deletions m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
# preference for no added switch, and then for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
Expand All @@ -34,13 +34,15 @@
# Copyright (c) 2015 Paul Norman <[email protected]>
# Copyright (c) 2015 Moritz Klammler <[email protected]>
# Copyright (c) 2016, 2018 Krzesimir Nowak <[email protected]>
# Copyright (c) 2019 Enji Cooper <[email protected]>
# Copyright (c) 2020 Jason Merrill <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 10
#serial 12

dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
Expand All @@ -61,6 +63,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
AC_LANG_PUSH([C++])dnl
ac_success=no
m4_if([$2], [], [dnl
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
ax_cv_cxx_compile_cxx$1,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[ax_cv_cxx_compile_cxx$1=yes],
[ax_cv_cxx_compile_cxx$1=no])])
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
ac_success=yes
fi])
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
Expand Down Expand Up @@ -189,11 +201,13 @@ namespace cxx11
struct Base
{
virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
virtual ~Derived() override {}
virtual void f() override {}
};
Expand Down
6 changes: 6 additions & 0 deletions m4/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

for i in *.m4
do
wget "http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/$i" -O $i
done
Loading

0 comments on commit 70e1ed3

Please sign in to comment.