mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Remove dependency with Allegro library in config.h file
* Created base::write24bits() function (and detect endianness with a special base/config.h.cmakein) * Use _WIN32 instead of ALLEGRO_WINDOWS * Use _DEBUG instead of DEBUGMODE * Replaced AL_CONST with "const" in bmp_format.cpp * Replace stricmp() with base::utf8_icmp()
This commit is contained in:
parent
22f35ab249
commit
16da2512b4
@ -182,9 +182,6 @@ if(ENABLE_UPDATER)
|
|||||||
|
|
||||||
set(aseprite_libraries ${aseprite_libraries} updater-lib net-lib)
|
set(aseprite_libraries ${aseprite_libraries} updater-lib net-lib)
|
||||||
add_definitions(-DENABLE_UPDATER)
|
add_definitions(-DENABLE_UPDATER)
|
||||||
|
|
||||||
add_subdirectory(net)
|
|
||||||
add_subdirectory(updater)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_WEBSERVER)
|
if(ENABLE_WEBSERVER)
|
||||||
@ -193,8 +190,6 @@ if(ENABLE_WEBSERVER)
|
|||||||
|
|
||||||
set(aseprite_libraries ${aseprite_libraries} webserver-lib)
|
set(aseprite_libraries ${aseprite_libraries} webserver-lib)
|
||||||
add_definitions(-DENABLE_WEBSERVER)
|
add_definitions(-DENABLE_WEBSERVER)
|
||||||
|
|
||||||
add_subdirectory(webserver)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Full-version or trial-mode?
|
# Full-version or trial-mode?
|
||||||
@ -208,6 +203,8 @@ endif()
|
|||||||
# Aseprite Libraries (in preferred order to be built)
|
# Aseprite Libraries (in preferred order to be built)
|
||||||
|
|
||||||
add_subdirectory(base)
|
add_subdirectory(base)
|
||||||
|
include_directories(${BASE_INCLUDE_DIR})
|
||||||
|
|
||||||
add_subdirectory(cfg)
|
add_subdirectory(cfg)
|
||||||
add_subdirectory(css)
|
add_subdirectory(css)
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
@ -221,6 +218,15 @@ add_subdirectory(she)
|
|||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
||||||
add_subdirectory(undo)
|
add_subdirectory(undo)
|
||||||
|
|
||||||
|
if(ENABLE_UPDATER)
|
||||||
|
add_subdirectory(net)
|
||||||
|
add_subdirectory(updater)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_WEBSERVER)
|
||||||
|
add_subdirectory(webserver)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(app)
|
add_subdirectory(app)
|
||||||
|
|
||||||
if(V8_FOUND)
|
if(V8_FOUND)
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "ui/system.h"
|
#include "ui/system.h"
|
||||||
#include "ui/theme.h"
|
#include "ui/theme.h"
|
||||||
|
|
||||||
#if defined ALLEGRO_WINDOWS && defined DEBUGMODE
|
#if defined _WIN32 && defined _DEBUG
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Aseprite
|
/* Aseprite
|
||||||
* Copyright (C) 2001-2013 David Capello
|
* Copyright (C) 2001-2015 David Capello
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -354,7 +354,7 @@ static void read_32bit_line(int length, FILE *f, Image *image, int line)
|
|||||||
/* read_image:
|
/* read_image:
|
||||||
* For reading the noncompressed BMP image format.
|
* For reading the noncompressed BMP image format.
|
||||||
*/
|
*/
|
||||||
static void read_image(FILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader, FileOp *fop)
|
static void read_image(FILE *f, Image *image, const BITMAPINFOHEADER *infoheader, FileOp *fop)
|
||||||
{
|
{
|
||||||
int i, line, height, dir;
|
int i, line, height, dir;
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ static void read_image(FILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infohea
|
|||||||
* @note This support compressed top-down bitmaps, the MSDN says that
|
* @note This support compressed top-down bitmaps, the MSDN says that
|
||||||
* they can't exist, but Photoshop can create them.
|
* they can't exist, but Photoshop can create them.
|
||||||
*/
|
*/
|
||||||
static void read_rle8_compressed_image(FILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
static void read_rle8_compressed_image(FILE *f, Image *image, const BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
unsigned char count, val, val0;
|
unsigned char count, val, val0;
|
||||||
int j, pos, line, height, dir;
|
int j, pos, line, height, dir;
|
||||||
@ -460,7 +460,7 @@ static void read_rle8_compressed_image(FILE *f, Image *image, AL_CONST BITMAPINF
|
|||||||
* @note This support compressed top-down bitmaps, the MSDN says that
|
* @note This support compressed top-down bitmaps, the MSDN says that
|
||||||
* they can't exist, but Photoshop can create them.
|
* they can't exist, but Photoshop can create them.
|
||||||
*/
|
*/
|
||||||
static void read_rle4_compressed_image(FILE *f, Image *image, AL_CONST BITMAPINFOHEADER *infoheader)
|
static void read_rle4_compressed_image(FILE *f, Image *image, const BITMAPINFOHEADER *infoheader)
|
||||||
{
|
{
|
||||||
unsigned char b[8];
|
unsigned char b[8];
|
||||||
unsigned char count;
|
unsigned char count;
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "ui/alert.h"
|
#include "ui/alert.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "app/file/file_formats_manager.h"
|
#include "app/file/file_formats_manager.h"
|
||||||
#include "app/file/file_format.h"
|
#include "app/file/file_format.h"
|
||||||
#include "app/file/format_options.h"
|
#include "app/file/format_options.h"
|
||||||
|
#include "base/string.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
@ -91,10 +92,6 @@ FileFormatsList::iterator FileFormatsManager::end()
|
|||||||
return m_formats.end();
|
return m_formats.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning (disable: 4996) // Disable warning about 'stricmp'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FileFormat* FileFormatsManager::getFileFormatByExtension(const char* extension) const
|
FileFormat* FileFormatsManager::getFileFormatByExtension(const char* extension) const
|
||||||
{
|
{
|
||||||
char buf[512], *tok;
|
char buf[512], *tok;
|
||||||
@ -104,7 +101,7 @@ FileFormat* FileFormatsManager::getFileFormatByExtension(const char* extension)
|
|||||||
|
|
||||||
for (tok=strtok(buf, ","); tok;
|
for (tok=strtok(buf, ","); tok;
|
||||||
tok=strtok(NULL, ",")) {
|
tok=strtok(NULL, ",")) {
|
||||||
if (stricmp(extension, tok) == 0)
|
if (base::utf8_icmp(extension, tok) == 0)
|
||||||
return ff;
|
return ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
src/base/24bits.h
Normal file
37
src/base/24bits.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Aseprite Base Library
|
||||||
|
// Copyright (c) 2001-2015 David Capello
|
||||||
|
//
|
||||||
|
// This file is released under the terms of the MIT license.
|
||||||
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
#ifndef BASE_24BITS_H_INCLUDED
|
||||||
|
#define BASE_24BITS_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/config.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
#ifdef ASEPRITE_LITTLE_ENDIAN
|
||||||
|
|
||||||
|
template<typename PTR, typename VALUE>
|
||||||
|
inline void write24bits(PTR* ptr, VALUE value) {
|
||||||
|
((uint8_t*)ptr)[0] = value;
|
||||||
|
((uint8_t*)ptr)[1] = value >> 8;
|
||||||
|
((uint8_t*)ptr)[2] = value >> 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(ASEPRITE_BIG_ENDIAN)
|
||||||
|
|
||||||
|
template<typename PTR, typename VALUE>
|
||||||
|
inline void write24bits(PTR* ptr, VALUE value) {
|
||||||
|
((uint8_t*)ptr)[0] = value >> 16;
|
||||||
|
((uint8_t*)ptr)[1] = value >> 8;
|
||||||
|
((uint8_t*)ptr)[2] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif
|
@ -2,8 +2,16 @@
|
|||||||
# Copyright (c) 2001-2014 David Capello
|
# Copyright (c) 2001-2014 David Capello
|
||||||
|
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
CHECK_C_SOURCE_COMPILES("
|
check_c_source_compiles("
|
||||||
|
#include <stdint.h>
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_STDINT_H)
|
||||||
|
|
||||||
|
check_c_source_compiles("
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
int main() {
|
int main() {
|
||||||
sched_yield();
|
sched_yield();
|
||||||
@ -11,10 +19,26 @@ int main() {
|
|||||||
}
|
}
|
||||||
" HAVE_SCHED_YIELD)
|
" HAVE_SCHED_YIELD)
|
||||||
|
|
||||||
if(HAVE_SCHED_YIELD)
|
check_c_source_runs("
|
||||||
add_definitions(-DHAVE_SCHED_YIELD)
|
int main() {
|
||||||
|
unsigned long value = 0x40302010ul;
|
||||||
|
return (((unsigned char*)&value)[0] == 0x10) ? 0: 1;
|
||||||
|
}
|
||||||
|
" ASEPRITE_LITTLE_ENDIAN)
|
||||||
|
|
||||||
|
if(NOT ASEPRITE_LITTLE_ENDIAN)
|
||||||
|
set(ASEPRITE_BIG_ENDIAN TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Generate config.h file
|
||||||
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.cmakein
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/base/config.h @ONLY)
|
||||||
|
|
||||||
|
set(BASE_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
CACHE STRING "Extra include directory for base lib")
|
||||||
|
mark_as_advanced(${BASE_INCLUDE_DIR})
|
||||||
|
include_directories(${BASE_INCLUDE_DIR})
|
||||||
|
|
||||||
set(BASE_SOURCES
|
set(BASE_SOURCES
|
||||||
cfile.cpp
|
cfile.cpp
|
||||||
chrono.cpp
|
chrono.cpp
|
||||||
|
87
src/base/base.h
Normal file
87
src/base/base.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// Aseprite Base Library
|
||||||
|
// Copyright (c) 2001-2015 David Capello
|
||||||
|
//
|
||||||
|
// This file is released under the terms of the MIT license.
|
||||||
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
#ifndef BASE_BASE_H_INCLUDED
|
||||||
|
#define BASE_BASE_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/config.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef NULL
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define NULL nullptr
|
||||||
|
#else
|
||||||
|
#define NULL ((void*)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
|
#undef MID
|
||||||
|
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||||
|
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
||||||
|
#define MID(x,y,z) ((x) > (y) ? ((y) > (z) ? (y) : ((x) > (z) ? \
|
||||||
|
(z) : (x))) : ((y) > (z) ? ((z) > (x) ? (z) : \
|
||||||
|
(x)): (y)))
|
||||||
|
|
||||||
|
#undef CLAMP
|
||||||
|
#define CLAMP(x,y,z) MAX((x), MIN((y), (z)))
|
||||||
|
|
||||||
|
#undef ABS
|
||||||
|
#undef SGN
|
||||||
|
#define ABS(x) (((x) >= 0) ? (x) : (-(x)))
|
||||||
|
#define SGN(x) (((x) >= 0) ? 1 : -1)
|
||||||
|
|
||||||
|
#undef PI
|
||||||
|
#define PI 3.14159265358979323846
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Overloaded new/delete operators to detect memory-leaks
|
||||||
|
|
||||||
|
#if defined __cplusplus && defined MEMLEAK
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include "base/memory.h"
|
||||||
|
|
||||||
|
inline void* operator new(std::size_t size)
|
||||||
|
{
|
||||||
|
void* ptr = base_malloc(size);
|
||||||
|
if (!ptr)
|
||||||
|
throw std::bad_alloc();
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void operator delete(void* ptr)
|
||||||
|
{
|
||||||
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
base_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* operator new[](std::size_t size)
|
||||||
|
{
|
||||||
|
void* ptr = base_malloc(size);
|
||||||
|
if (!ptr)
|
||||||
|
throw std::bad_alloc();
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void operator delete[](void* ptr)
|
||||||
|
{
|
||||||
|
if (!ptr)
|
||||||
|
return;
|
||||||
|
base_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
17
src/base/config.h.cmakein
Normal file
17
src/base/config.h.cmakein
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Aseprite Base Library -*- C++ -*-
|
||||||
|
// Copyright (c) 2001-2015 David Capello
|
||||||
|
//
|
||||||
|
// This file is released under the terms of the MIT license.
|
||||||
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
#ifndef BASE_CONFIG_H_INCLUDED
|
||||||
|
#define BASE_CONFIG_H_INCLUDED
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#cmakedefine HAVE_STDINT_H
|
||||||
|
#cmakedefine HAVE_SCHED_YIELD
|
||||||
|
|
||||||
|
#cmakedefine ASEPRITE_LITTLE_ENDIAN
|
||||||
|
#cmakedefine ASEPRITE_BIG_ENDIAN
|
||||||
|
|
||||||
|
#endif
|
@ -11,6 +11,9 @@
|
|||||||
int base_assert(const char* condition, const char* file, int lineNum);
|
int base_assert(const char* condition, const char* file, int lineNum);
|
||||||
void base_trace(const char* msg, ...);
|
void base_trace(const char* msg, ...);
|
||||||
|
|
||||||
|
#undef ASSERT
|
||||||
|
#undef TRACE
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#else
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
|
52
src/config.h
52
src/config.h
@ -1,5 +1,5 @@
|
|||||||
/* Aseprite
|
/* Aseprite
|
||||||
* Copyright (C) 2001-2014 David Capello
|
* Copyright (C) 2001-2015 David Capello
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -49,53 +49,5 @@
|
|||||||
// verbose_printf is defined in src/app/log.cpp and used through PRINTF macro
|
// verbose_printf is defined in src/app/log.cpp and used through PRINTF macro
|
||||||
void verbose_printf(const char* format, ...);
|
void verbose_printf(const char* format, ...);
|
||||||
|
|
||||||
#include <math.h>
|
#include "base/base.h"
|
||||||
#undef PI
|
|
||||||
#define PI 3.14159265358979323846
|
|
||||||
|
|
||||||
#include <allegro/base.h>
|
|
||||||
#include <allegro/debug.h>
|
|
||||||
#undef ASSERT
|
|
||||||
#undef TRACE
|
|
||||||
|
|
||||||
#include "base/debug.h"
|
#include "base/debug.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Overloaded new/delete operators to detect memory-leaks
|
|
||||||
|
|
||||||
#if defined __cplusplus && defined MEMLEAK
|
|
||||||
|
|
||||||
#include <new>
|
|
||||||
#include "base/memory.h"
|
|
||||||
|
|
||||||
inline void* operator new(std::size_t size)
|
|
||||||
{
|
|
||||||
void* ptr = base_malloc(size);
|
|
||||||
if (!ptr)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator delete(void* ptr)
|
|
||||||
{
|
|
||||||
if (!ptr)
|
|
||||||
return;
|
|
||||||
base_free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void* operator new[](std::size_t size)
|
|
||||||
{
|
|
||||||
void* ptr = base_malloc(size);
|
|
||||||
if (!ptr)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator delete[](void* ptr)
|
|
||||||
{
|
|
||||||
if (!ptr)
|
|
||||||
return;
|
|
||||||
base_free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "doc/conversion_she.h"
|
#include "doc/conversion_she.h"
|
||||||
|
|
||||||
|
#include "base/24bits.h"
|
||||||
#include "doc/algo.h"
|
#include "doc/algo.h"
|
||||||
#include "doc/blend.h"
|
#include "doc/blend.h"
|
||||||
#include "doc/color_scales.h"
|
#include "doc/color_scales.h"
|
||||||
@ -100,7 +101,7 @@ struct Address24bpp
|
|||||||
Address24bpp& operator++() { m_ptr += 3; return *this; }
|
Address24bpp& operator++() { m_ptr += 3; return *this; }
|
||||||
Address24bpp& operator*() { return *this; }
|
Address24bpp& operator*() { return *this; }
|
||||||
Address24bpp& operator=(uint32_t c) {
|
Address24bpp& operator=(uint32_t c) {
|
||||||
WRITE3BYTES(m_ptr, c);
|
base::write24bits(m_ptr, c);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user