| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef _TVG_COMMON_H_ |
| 24 |
#define _TVG_COMMON_H_ |
| 25 |
|
| 26 |
#include "config.h" |
| 27 |
#include "thorvg.h" |
| 28 |
|
| 29 |
using namespace std; |
| 30 |
using namespace tvg; |
| 31 |
|
| 32 |
|
| 33 |
#ifdef _MSC_VER |
| 34 |
#define TVG_UNUSED |
| 35 |
#define strncasecmp _strnicmp |
| 36 |
#define strcasecmp _stricmp |
| 37 |
#else |
| 38 |
#define TVG_UNUSED __attribute__ ((__unused__)) |
| 39 |
#endif |
| 40 |
|
| 41 |
|
| 42 |
#if __has_cpp_attribute(fallthrough) |
| 43 |
#ifdef _MSC_VER |
| 44 |
#define TVG_FALLTHROUGH [[fallthrough]]; |
| 45 |
#else |
| 46 |
#define TVG_FALLTHROUGH __attribute__ ((fallthrough)); |
| 47 |
#endif |
| 48 |
#else |
| 49 |
#define TVG_FALLTHROUGH |
| 50 |
#endif |
| 51 |
|
| 52 |
#if defined(_MSC_VER) && defined(__clang__) |
| 53 |
#define strncpy strncpy_s |
| 54 |
#define strdup _strdup |
| 55 |
#endif |
| 56 |
|
| 57 |
enum class FileType { Png = 0, Jpg, Webp, Tvg, Svg, Lottie, Ttf, Raw, Gif, Unknown }; |
| 58 |
|
| 59 |
#ifdef THORVG_LOG_ENABLED |
| 60 |
constexpr auto ErrorColor = "\033[31m"; |
| 61 |
constexpr auto ErrorBgColor = "\033[41m"; |
| 62 |
constexpr auto LogColor = "\033[32m"; |
| 63 |
constexpr auto LogBgColor = "\033[42m"; |
| 64 |
constexpr auto GreyColor = "\033[90m"; |
| 65 |
constexpr auto ResetColors = "\033[0m"; |
| 66 |
#define TVGERR(tag, fmt, ...) fprintf(stderr, "%s[E]%s %s" tag "%s (%s %d): %s" fmt "\n", ErrorBgColor, ResetColors, ErrorColor, GreyColor, __FILE__, __LINE__, ResetColors, ##__VA_ARGS__) |
| 67 |
#define TVGLOG(tag, fmt, ...) fprintf(stdout, "%s[L]%s %s" tag "%s (%s %d): %s" fmt "\n", LogBgColor, ResetColors, LogColor, GreyColor, __FILE__, __LINE__, ResetColors, ##__VA_ARGS__) |
| 68 |
#else |
| 69 |
#define TVGERR(...) do {} while(0) |
| 70 |
#define TVGLOG(...) do {} while(0) |
| 71 |
#endif |
| 72 |
|
| 73 |
uint16_t THORVG_VERSION_NUMBER(); |
| 74 |
|
| 75 |
|
| 76 |
#define P(A) ((A)->pImpl) //Access to pimpl. |
| 77 |
#define PP(A) (((Paint*)(A))->pImpl) //Access to pimpl. |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
#if 0 |
| 82 |
#include <sys/time.h> |
| 83 |
static inline double THORVG_TIMESTAMP() |
| 84 |
{ |
| 85 |
struct timeval tv; |
| 86 |
gettimeofday(&tv, NULL); |
| 87 |
return (tv.tv_sec + tv.tv_usec / 1000000.0); |
| 88 |
} |
| 89 |
#endif |
| 90 |
|
| 91 |
#endif |