Merge branch 'master' (early part) into medusa

This commit is contained in:
Vicki Pfau 2019-06-28 16:25:24 -07:00
commit 8b04eca8f0
399 changed files with 23174 additions and 7515 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/build
/build-*
*.user*
*~
*.swp

View File

@ -11,6 +11,7 @@ env:
- DOCKER_TAG=3ds
- DOCKER_TAG=wii
- DOCKER_TAG=vita
- DOCKER_TAG=switch
- DOCKER_TAG=windows:w32
- DOCKER_TAG=windows:w64

11
CHANGES
View File

@ -36,6 +36,8 @@ Features:
- Optional automatic state saving/loading
- Access to ur0 and uma0 partitions on the Vita
- Partial support for MBC6, MMM01, TAMA and HuC-1 GB mappers
- GBA: ARMIPS/A22i-style and ELF symbol table support
- Initial Switch port
Bugfixes:
- GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749)
- GB Serialize: Fix audio state loading
@ -66,6 +68,13 @@ Bugfixes:
- GB, GBA Savedata: Fix savestate loading overwriting saves on reset
- GBA Video: Make layer disabling work consistently
- GB: Fix IRQ disabling on the same T-cycle as an assert
- Core: Fix ordering events when scheduling during events
- GBA: Reset WAITCNT properly
- GBA Serialize: Fix loading states in Hblank
- PSP2: Fix more issues causing poor audio
- GBA Memory: Fix Vast Fame support (taizou) (fixes mgba.io/i/1170)
- GB, GBA Savedata: Fix unmasking savedata crash
- GBA DMA: Fix temporal sorting of DMAs of different priorities
Misc:
- GBA Timer: Use global cycles for timers
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
@ -97,6 +106,8 @@ Misc:
- Feature: Added loading savestates from command line
- Qt: Allow pausing game at load (fixes mgba.io/i/1129)
- Wii: Move audio handling to callbacks (fixes mgba.io/i/803)
- Qt: Clean up FPS target UI (fixes mgba.io/i/436)
- Core: Remove broken option for whether rewinding restores save games
0.6.3: (2017-04-14)
Bugfixes:

View File

@ -6,7 +6,9 @@ project(medusa)
set(BINARY_NAME medusa-emu CACHE INTERNAL "Name of output binaries")
if(NOT MSVC)
set(GCC_STD "c99")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.3")
if(SWITCH)
set(GCC_STD "gnu11")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_COMPILER_VERSION VERSION_LESS "4.3")
set(GCC_STD "gnu99")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -std=${GCC_STD}")
@ -45,8 +47,8 @@ set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings")
set(BUILD_STATIC OFF CACHE BOOL "Build a static library")
set(BUILD_SHARED ON CACHE BOOL "Build a shared library")
set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)")
set(BUILD_GL ON CACHE STRING "Build with OpenGL")
set(BUILD_GLES2 OFF CACHE STRING "Build with OpenGL|ES 2")
set(BUILD_GL ON CACHE BOOL "Build with OpenGL")
set(BUILD_GLES2 OFF CACHE BOOL "Build with OpenGL|ES 2")
set(USE_EPOXY ON CACHE STRING "Build with libepoxy")
set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies")
set(DISTBUILD OFF CACHE BOOL "Build distribution packages")
@ -67,7 +69,7 @@ file(GLOB GBA_CHEATS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/cheats/*.c)
file(GLOB GBA_RR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/rr/*.c)
file(GLOB CORE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/core/*.c)
file(GLOB CORE_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/core/test/*.c)
file(GLOB UTIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.[cSs])
file(GLOB UTIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.c)
file(GLOB UTIL_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/test/*.c)
file(GLOB GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/gui/*.c)
file(GLOB GBA_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/renderers/*.c)
@ -288,7 +290,7 @@ if(PSP2 OR WII)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
endif()
if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII)
if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII OR DEFINED SWITCH)
set(IS_EMBEDDED ON)
set(USE_DEBUGGERS OFF)
set(USE_SQLITE3 OFF)
@ -298,6 +300,10 @@ if(DEFINED 3DS)
add_definitions(-DFIXED_ROM_BUFFER)
endif()
if(DEFINED SWITCH)
set(BUILD_GLES2 ON CACHE BOOL "Build with OpenGL|ES 2" FORCE)
endif()
if(NOT M_CORE_GBA)
set(USE_GDB_STUB OFF)
endif()
@ -336,7 +342,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
check_function_exists(uselocale HAVE_USELOCALE)
check_function_exists(setlocale HAVE_SETLOCALE)
else()
if(DEFINED 3DS OR DEFINED WII)
if(DEFINED 3DS OR DEFINED WII OR DEFINED SWITCH)
set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,snprintf_l)
check_function_exists(snprintf_l HAVE_SNPRINTF_L)
set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,strtof_l)
@ -601,10 +607,13 @@ if(WANT_PNG AND USE_ZLIB AND NOT USE_PNG)
set(PNG_SHARED OFF CACHE BOOL "" FORCE)
set(PNG_TESTS OFF CACHE BOOL "" FORCE)
set(SKIP_INSTALL_ALL ON)
if (SWITCH)
set(PNG_ARM_NEON "off" CACHE STRING "" FORCE)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng libpng)
set_property(TARGET png16_static PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/libpng;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng;${ZLIB_INCLUDE_DIRS})
set_property(TARGET png_static PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/libpng;${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng;${ZLIB_INCLUDE_DIRS})
set(PNG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/libpng ${CMAKE_CURRENT_BINARY_DIR}/libpng)
list(APPEND DEPENDENCY_LIB png16_static)
list(APPEND DEPENDENCY_LIB png_static)
set(USE_PNG ON)
endif()
@ -806,6 +815,10 @@ if(DEFINED PSP2)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/psp2 ${CMAKE_CURRENT_BINARY_DIR}/psp2)
endif()
if(DEFINED SWITCH)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/switch ${CMAKE_CURRENT_BINARY_DIR}/switch)
endif()
# Binaries
list(APPEND CORE_SRC
${UTIL_SRC}
@ -985,7 +998,7 @@ if(BUILD_EXAMPLE)
target_link_libraries(${BINARY_NAME}-example-server ${BINARY_NAME})
set_target_properties(${BINARY_NAME}-example-server PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
if(FOUND_SDL)
if(SDL_FOUND)
add_executable(${BINARY_NAME}-example-client ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/client.c)
target_link_libraries(${BINARY_NAME}-example-client ${BINARY_NAME} ${SDL_LIBRARY} ${SDLMAIN_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY})
set_target_properties(${BINARY_NAME}-example-client PROPERTIES
@ -1058,6 +1071,8 @@ if(DISTBUILD)
set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-wii)
elseif(PSP2)
set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-psp2)
elseif(SWITCH)
set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-switch)
endif()
endif()
@ -1082,22 +1097,24 @@ elseif(PSP2)
cpack_add_component(${BINARY_NAME}-psp2 GROUP base)
elseif(WII)
cpack_add_component(${BINARY_NAME}-wii GROUP base)
elseif(SWITCH)
cpack_add_component(${BINARY_NAME}-switch GROUP base)
endif()
if(BUILD_QT)
cpack_add_component_group(qt PARENT_GROUP base)
cpack_add_component(${BINARY_NAME}-qt GROUP qt DEPENDS base)
cpack_add_component(${BINARY_NAME}-qt GROUP qt)
endif()
if(FOUND_SDL)
if(SDL_FOUND)
cpack_add_component_group(sdl PARENT_GROUP base)
cpack_add_component(${BINARY_NAME}-sdl GROUP sdl DEPENDS base)
cpack_add_component(${BINARY_NAME}-sdl GROUP sdl)
endif()
cpack_add_component_group(test PARENT_GROUP dev)
cpack_add_component(${BINARY_NAME}-perf GROUP test DEPENDS dev)
cpack_add_component(${BINARY_NAME}-fuzz GROUP test DEPENDS dev)
cpack_add_component(tbl-fuzz GROUP test DEPENDS dev)
cpack_add_component(${BINARY_NAME}-perf GROUP test)
cpack_add_component(${BINARY_NAME}-fuzz GROUP test)
cpack_add_component(tbl-fuzz GROUP test)
# Summaries
set(SUMMARY_GL_LIST)

View File

@ -14,7 +14,7 @@ CXX_GUARD_START
struct VFile;
bool GUISelectFile(struct GUIParams*, char* outPath, size_t outLen, bool (*filter)(struct VFile*));
bool GUISelectFile(struct GUIParams*, char* outPath, size_t outLen, bool (*filterName)(const char* name), bool (*filterContents)(struct VFile*));
CXX_GUARD_END

View File

@ -0,0 +1,87 @@
/* Copyright (c) 2013-2018 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SWITCH_THREADING_H
#define SWITCH_THREADING_H
#include <mgba-util/common.h>
#include <switch.h>
#define THREAD_ENTRY void
typedef ThreadFunc ThreadEntry;
typedef CondVar Condition;
static inline int MutexInit(Mutex* mutex) {
mutexInit(mutex);
return 0;
}
static inline int MutexDeinit(Mutex* mutex) {
UNUSED(mutex);
return 0;
}
static inline int MutexLock(Mutex* mutex) {
mutexLock(mutex);
return 0;
}
static inline int MutexTryLock(Mutex* mutex) {
return mutexTryLock(mutex);
}
static inline int MutexUnlock(Mutex* mutex) {
mutexUnlock(mutex);
return 0;
}
static inline int ConditionInit(Condition* cond) {
condvarInit(cond);
return 0;
}
static inline int ConditionDeinit(Condition* cond) {
UNUSED(cond);
return 0;
}
static inline int ConditionWait(Condition* cond, Mutex* mutex) {
return condvarWait(cond, mutex);
}
static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) {
return condvarWaitTimeout(cond, mutex, timeoutMs * 1000000LL);
}
static inline int ConditionWake(Condition* cond) {
return condvarWakeOne(cond);
}
static inline int ThreadCreate(Thread* thread, ThreadEntry entry, void* context) {
if (!entry || !thread) {
return 1;
}
int res = threadCreate(thread, entry, context, 0x8000, 0x3B, 1);
if(R_FAILED(res)) {
return res;
}
return threadStart(thread);
}
static inline int ThreadJoin(Thread thread) {
int res = threadWaitForExit(&thread);
if(R_FAILED(res)) {
return res;
}
return threadClose(&thread);
}
static inline void ThreadSetName(const char* name) {
UNUSED(name);
// Unimplemented
}
#endif

View File

@ -42,6 +42,8 @@ png_structp PNGReadOpen(struct VFile* source, unsigned offset);
bool PNGInstallChunkHandler(png_structp png, void* context, ChunkHandler handler, const char* chunkName);
bool PNGReadHeader(png_structp png, png_infop info);
bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
bool PNGReadPixelsA(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
bool PNGReadPixels8(png_structp png, png_infop info, void* pixels, unsigned width, unsigned height, unsigned stride);
bool PNGIgnorePixels(png_structp png, png_infop info);
bool PNGReadFooter(png_structp png, png_infop end);
void PNGReadClose(png_structp png, png_infop info, png_infop end);

View File

@ -55,6 +55,9 @@ struct Address {
extern u32* SOCUBuffer;
#endif
#ifdef __SWITCH__
#include <switch.h>
#endif
static inline void SocketSubsystemInit() {
#ifdef _WIN32
@ -65,6 +68,8 @@ static inline void SocketSubsystemInit() {
SOCUBuffer = memalign(SOCU_ALIGN, SOCU_BUFFERSIZE);
socInit(SOCUBuffer, SOCU_BUFFERSIZE);
}
#elif defined(__SWITCH__)
socketInitializeDefault();
#endif
}
@ -75,6 +80,8 @@ static inline void SocketSubsystemDeinit() {
socExit();
free(SOCUBuffer);
SOCUBuffer = NULL;
#elif defined(__SWITCH__)
socketExit();
#endif
}
@ -103,7 +110,7 @@ static inline ssize_t SocketSend(Socket socket, const void* buffer, size_t size)
}
static inline ssize_t SocketRecv(Socket socket, void* buffer, size_t size) {
#ifdef _WIN32
#if defined(_WIN32) || defined(__SWITCH__)
return recv(socket, (char*) buffer, size, 0);
#else
return read(socket, buffer, size);

View File

@ -13,12 +13,14 @@ CXX_GUARD_START
#ifndef DISABLE_THREADING
#ifdef USE_PTHREADS
#include <mgba-util/platform/posix/threading.h>
#elif _WIN32
#elif defined(_WIN32)
#include <mgba-util/platform/windows/threading.h>
#elif PSP2
#elif defined(PSP2)
#include <mgba-util/platform/psp2/threading.h>
#elif _3DS
#elif defined(_3DS)
#include <mgba-util/platform/3ds/threading.h>
#elif defined(__SWITCH__)
#include <mgba-util/platform/switch/threading.h>
#else
#define DISABLE_THREADING
#endif

View File

@ -22,7 +22,6 @@ struct mCoreRewindContext {
struct mCoreRewindPatches patchMemory;
size_t current;
size_t size;
int stateFlags;
struct VFile* previousState;
struct VFile* currentState;

View File

@ -20,6 +20,9 @@ bool mDebuggerSymbolLookup(const struct mDebuggerSymbols*, const char* name, int
void mDebuggerSymbolAdd(struct mDebuggerSymbols*, const char* name, int32_t value, int segment);
void mDebuggerSymbolRemove(struct mDebuggerSymbols*, const char* name);
struct VFile;
void mDebuggerLoadARMIPSSymbols(struct mDebuggerSymbols*, struct VFile* vf);
CXX_GUARD_END
#endif

View File

@ -77,6 +77,7 @@ struct GBVideoRenderer {
void (*drawRange)(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj* objOnLine, size_t nObj);
void (*finishScanline)(struct GBVideoRenderer* renderer, int y);
void (*finishFrame)(struct GBVideoRenderer* renderer);
void (*enableSGBBorder)(struct GBVideoRenderer* renderer, bool enable);
void (*getPixels)(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels);
void (*putPixels)(struct GBVideoRenderer* renderer, size_t stride, const void* pixels);

View File

@ -98,28 +98,28 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
* | 0x00202 - 0x00203: Old reload value
* | 0x00204 - 0x00207: Last event
* | 0x00208 - 0x0020B: Next event
* | 0x0020C - 0x0020F: Overflow interval
* | 0x0020C - 0x0020F: Next IRQ
* | 0x00210 - 0x00213: Miscellaneous flags
* 0x00214 - 0x00227: Timer 1
* | 0x00214 - 0x00215: Reload value
* | 0x00216 - 0x00217: Old reload value
* | 0x00218 - 0x0021B: Last event
* | 0x0021C - 0x0021F: Next event
* | 0x00220 - 0x00223: Overflow interval
* | 0x00220 - 0x00223: Next IRQ
* | 0x00224 - 0x00227: Miscellaneous flags
* 0x00228 - 0x0023B: Timer 2
* | 0x00228 - 0x00229: Reload value
* | 0x0022A - 0x0022B: Old reload value
* | 0x0022C - 0x0022F: Last event
* | 0x00230 - 0x00233: Next event
* | 0x00234 - 0x00237: Overflow interval
* | 0x00234 - 0x00237: Next IRQ
* | 0x00238 - 0x0023B: Miscellaneous flags
* 0x0023C - 0x00250: Timer 3
* | 0x0023C - 0x0023D: Reload value
* | 0x0023E - 0x0023F: Old reload value
* | 0x00240 - 0x00243: Last event
* | 0x00244 - 0x00247: Next event
* | 0x00248 - 0x0024B: Overflow interval
* | 0x00248 - 0x0024B: Next IRQ
* | 0x0024C - 0x0024F: Miscellaneous flags
* 0x00250 - 0x0025F: DMA 0
* | 0x00250 - 0x00253: DMA next source
@ -195,6 +195,7 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
* 0x00318 - 0x0031B: Last prefetched program counter
* 0x0031C - 0x0031F: Miscellaneous flags
* | bit 0: Is CPU halted?
* | bit 1: POSTFLG
* 0x00320 - 0x003FF: Reserved (leave zero)
* 0x00400 - 0x007FF: I/O memory
* 0x00800 - 0x00BFF: Palette
@ -225,6 +226,7 @@ DECL_BIT(GBASerializedSavedataFlags, DustSettling, 5);
DECL_BITFIELD(GBASerializedMiscFlags, uint32_t);
DECL_BIT(GBASerializedMiscFlags, Halted, 0);
DECL_BIT(GBASerializedMiscFlags, POSTFLG, 1);
struct GBASerializedState {
uint32_t versionMagic;

BIN
res/font-new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -179,7 +179,7 @@ void mCoreConfigMakePortable(const struct mCoreConfig* config) {
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, MAX_PATH, 0, 0);
StringCchCatA(out, MAX_PATH, "\\portable.ini");
portable = VFileOpen(out, O_WRONLY | O_CREAT);
#elif defined(PSP2) || defined(_3DS) || defined(GEKKO)
#elif defined(PSP2) || defined(_3DS) || defined(__SWITCH__) || defined(GEKKO)
// Already portable
#else
char out[PATH_MAX];
@ -219,7 +219,7 @@ void mCoreConfigDirectory(char* out, size_t outLength) {
UNUSED(portable);
snprintf(out, outLength, "ux0:data/%s", projectName);
sceIoMkdir(out, 0777);
#elif defined(GEKKO)
#elif defined(GEKKO) || defined(__SWITCH__)
UNUSED(portable);
snprintf(out, outLength, "/%s", projectName);
mkdir(out, 0777);

View File

@ -209,6 +209,7 @@ void mLibraryDestroy(struct mLibrary* library) {
sqlite3_finalize(library->select);
sqlite3_finalize(library->count);
sqlite3_close(library->db);
free(library);
}
void mLibraryLoadDirectory(struct mLibrary* library, const char* base) {

View File

@ -20,6 +20,7 @@ static bool _op(int32_t value, int32_t match, enum mCoreMemorySearchOp op) {
case mCORE_MEMORY_SEARCH_DELTA:
return value == match;
}
return false;
}
static size_t _search32(const void* mem, size_t size, const struct mCoreMemoryBlock* block, uint32_t value32, enum mCoreMemorySearchOp op, struct mCoreMemorySearchResults* out, size_t limit) {
@ -213,6 +214,7 @@ static size_t _search(const void* mem, size_t size, const struct mCoreMemoryBloc
case mCORE_MEMORY_SEARCH_GUESS:
return _searchGuess(mem, size, block, params, out, limit);
}
return 0;
}
void mCoreMemorySearch(struct mCore* core, const struct mCoreMemorySearchParams* params, struct mCoreMemorySearchResults* out, size_t limit) {

View File

@ -30,7 +30,6 @@ void mCoreRewindContextInit(struct mCoreRewindContext* context, size_t entries,
context->previousState = VFileMemChunk(0, 0);
context->currentState = VFileMemChunk(0, 0);
context->size = 0;
context->stateFlags = SAVESTATE_SAVEDATA;
#ifndef DISABLE_THREADING
context->onThread = onThread;
context->ready = false;
@ -77,7 +76,7 @@ void mCoreRewindAppend(struct mCoreRewindContext* context, struct mCore* core) {
}
#endif
struct VFile* nextState = context->previousState;
mCoreSaveStateNamed(core, nextState, context->stateFlags);
mCoreSaveStateNamed(core, nextState, SAVESTATE_SAVEDATA | SAVESTATE_RTC);
context->previousState = context->currentState;
context->currentState = nextState;
#ifndef DISABLE_THREADING
@ -131,7 +130,7 @@ bool mCoreRewindRestore(struct mCoreRewindContext* context, struct mCore* core)
}
--context->size;
mCoreLoadStateNamed(core, context->previousState, context->stateFlags);
mCoreLoadStateNamed(core, context->previousState, SAVESTATE_SAVEDATA | SAVESTATE_RTC);
if (context->current == 0) {
context->current = mCoreRewindPatchesSize(&context->patchMemory);
}

View File

@ -304,20 +304,20 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
size_t stateSize = core->stateSize(core);
if (flags & SAVESTATE_METADATA) {
uint64_t creationUsec;
uint64_t* creationUsec = malloc(sizeof(*creationUsec));
#ifndef _MSC_VER
struct timeval tv;
if (!gettimeofday(&tv, 0)) {
uint64_t usec = tv.tv_usec;
usec += tv.tv_sec * 1000000LL;
STORE_64LE(usec, 0, &creationUsec);
STORE_64LE(usec, 0, creationUsec);
}
#else
struct timespec ts;
if (timespec_get(&ts, TIME_UTC)) {
uint64_t usec = ts.tv_nsec / 1000;
usec += ts.tv_sec * 1000000LL;
STORE_64LE(usec, 0, &creationUsec);
STORE_64LE(usec, 0, creationUsec);
}
#endif
else {
@ -325,9 +325,9 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
}
struct mStateExtdataItem item = {
.size = sizeof(creationUsec),
.data = &creationUsec,
.clean = NULL
.size = sizeof(*creationUsec),
.data = creationUsec,
.clean = free
};
mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item);
}

View File

@ -60,6 +60,11 @@ static void _waitUntilNotState(struct mCoreThreadInternal* threadContext, enum m
threadContext->sync.videoFrameWait = false;
MutexUnlock(&threadContext->sync.videoFrameMutex);
MutexLock(&threadContext->sync.audioBufferMutex);
bool audioWait = threadContext->sync.audioWait;
threadContext->sync.audioWait = false;
MutexUnlock(&threadContext->sync.audioBufferMutex);
while (threadContext->state == oldState) {
MutexUnlock(&threadContext->stateMutex);
@ -77,6 +82,10 @@ static void _waitUntilNotState(struct mCoreThreadInternal* threadContext, enum m
ConditionWake(&threadContext->stateCond);
}
MutexLock(&threadContext->sync.audioBufferMutex);
threadContext->sync.audioWait = audioWait;
MutexUnlock(&threadContext->sync.audioBufferMutex);
MutexLock(&threadContext->sync.videoFrameMutex);
threadContext->sync.videoFrameWait = videoFrameWait;
MutexUnlock(&threadContext->sync.videoFrameMutex);
@ -228,8 +237,10 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
ConditionWait(&impl->stateCond, &impl->stateMutex);
if (impl->sync.audioWait) {
MutexUnlock(&impl->stateMutex);
mCoreSyncLockAudio(&impl->sync);
mCoreSyncProduceAudio(&impl->sync, core->getAudioChannel(core, 0), core->getAudioBufferSize(core));
MutexLock(&impl->stateMutex);
}
}
}
@ -583,7 +594,6 @@ void mCoreThreadRewindParamsChanged(struct mCoreThread* threadContext) {
struct mCore* core = threadContext->core;
if (core->opts.rewindEnable && core->opts.rewindBufferCapacity > 0) {
mCoreRewindContextInit(&threadContext->impl->rewind, core->opts.rewindBufferCapacity, true);
threadContext->impl->rewind.stateFlags = core->opts.rewindSave ? SAVESTATE_SAVEDATA : 0;
} else {
mCoreRewindContextDeinit(&threadContext->impl->rewind);
}

View File

@ -33,7 +33,7 @@ void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t
unsigned priority = event->priority;
while (next) {
int32_t nextWhen = next->when - timing->masterCycles;
if (nextWhen > when || (nextWhen == when && next->priority > priority)) {
if (nextWhen > nextEvent || (nextWhen == nextEvent && next->priority > priority)) {
break;
}
previous = &next->next;
@ -58,6 +58,9 @@ void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent* event) {
bool mTimingIsScheduled(const struct mTiming* timing, const struct mTimingEvent* event) {
const struct mTimingEvent* next = timing->root;
if (!next) {
next = timing->reroot;
}
while (next) {
if (next == event) {
return true;

View File

@ -5,7 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba/internal/debugger/symbols.h>
#include <mgba-util/string.h>
#include <mgba-util/table.h>
#include <mgba-util/vfs.h>
struct mDebuggerSymbol {
int32_t value;
@ -47,3 +49,40 @@ void mDebuggerSymbolAdd(struct mDebuggerSymbols* st, const char* name, int32_t v
void mDebuggerSymbolRemove(struct mDebuggerSymbols* st, const char* name) {
HashTableRemove(&st->names, name);
}
void mDebuggerLoadARMIPSSymbols(struct mDebuggerSymbols* st, struct VFile* vf) {
char line[512];
while (true) {
ssize_t bytesRead = vf->readline(vf, line, sizeof(line));
if (bytesRead <= 0) {
break;
}
if (line[bytesRead - 1] == '\n') {
line[bytesRead - 1] = '\0';
}
uint32_t address = 0;
const char* buf = line;
buf = hex32(buf, &address);
if (!buf) {
continue;
}
bytesRead -= 8;
while (isspace((int) buf[0]) && bytesRead > 0) {
--bytesRead;
++buf;
}
if (!bytesRead) {
continue;
}
if (buf[0] == '.') {
// Directives are not handled yet
continue;
}
mDebuggerSymbolAdd(st, buf, address, -1);
}
}

View File

@ -15,11 +15,25 @@
#endif
#include <mgba-util/gui/file-select.h>
#include <mgba-util/gui/menu.h>
#include <mgba-util/vfs.h>
#ifndef GUI_MAX_INPUTS
#define GUI_MAX_INPUTS 7
#endif
static bool _biosNamed(const char* name) {
char ext[PATH_MAX + 1] = {};
separatePath(name, NULL, NULL, ext);
if (strstr(name, "bios")) {
return true;
}
if (!strncmp(ext, "bin", PATH_MAX)) {
return true;
}
return false;
}
void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t nExtra) {
struct GUIMenu menu = {
.title = "Configure",
@ -183,7 +197,7 @@ void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t
}
if (!strcmp(item->data, "gba.bios")) {
// TODO: show box if failed
if (!GUISelectFile(&runner->params, gbaBiosPath, sizeof(gbaBiosPath), GBAIsBIOS)) {
if (!GUISelectFile(&runner->params, gbaBiosPath, sizeof(gbaBiosPath), _biosNamed, GBAIsBIOS)) {
gbaBiosPath[0] = '\0';
}
continue;
@ -191,21 +205,21 @@ void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t
#ifdef M_CORE_GB
if (!strcmp(item->data, "gb.bios")) {
// TODO: show box if failed
if (!GUISelectFile(&runner->params, gbBiosPath, sizeof(gbBiosPath), GBIsBIOS)) {
if (!GUISelectFile(&runner->params, gbBiosPath, sizeof(gbBiosPath), _biosNamed, GBIsBIOS)) {
gbBiosPath[0] = '\0';
}
continue;
}
if (!strcmp(item->data, "gbc.bios")) {
// TODO: show box if failed
if (!GUISelectFile(&runner->params, gbcBiosPath, sizeof(gbcBiosPath), GBIsBIOS)) {
if (!GUISelectFile(&runner->params, gbcBiosPath, sizeof(gbcBiosPath), _biosNamed, GBIsBIOS)) {
gbcBiosPath[0] = '\0';
}
continue;
}
if (!strcmp(item->data, "sgb.bios")) {
// TODO: show box if failed
if (!GUISelectFile(&runner->params, sgbBiosPath, sizeof(sgbBiosPath), GBIsBIOS)) {
if (!GUISelectFile(&runner->params, sgbBiosPath, sizeof(sgbBiosPath), _biosNamed, GBIsBIOS)) {
sgbBiosPath[0] = '\0';
}
continue;

View File

@ -73,6 +73,26 @@ static struct mGUILogger {
.logLevel = 0
};
static bool _testExtensions(const char* name) {
char ext[PATH_MAX] = {};
separatePath(name, NULL, NULL, ext);
if (!strncmp(ext, "sav", PATH_MAX)) {
return false;
}
if (!strncmp(ext, "png", PATH_MAX)) {
return false;
}
if (!strncmp(ext, "ini", PATH_MAX)) {
return false;
}
if (!strncmp(ext, "ss", 2)) {
return false;
}
return true;
}
static void _drawBackground(struct GUIBackground* background, void* context) {
UNUSED(context);
struct mGUIBackground* gbaBackground = (struct mGUIBackground*) background;
@ -421,10 +441,12 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
if (guiKeys & (1 << mGUI_INPUT_SCREENSHOT)) {
mCoreTakeScreenshot(runner->core);
}
if (heldKeys & (1 << mGUI_INPUT_FAST_FORWARD)) {
runner->setFrameLimiter(runner, false);
} else {
runner->setFrameLimiter(runner, true);
if (runner->setFrameLimiter) {
if (heldKeys & (1 << mGUI_INPUT_FAST_FORWARD)) {
runner->setFrameLimiter(runner, false);
} else {
runner->setFrameLimiter(runner, true);
}
}
uint16_t keys = runner->pollGameInput(runner);
if (runner->prepareForFrame) {
@ -481,6 +503,10 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) {
if (runner->paused) {
runner->paused(runner);
}
if (runner->setFrameLimiter) {
runner->setFrameLimiter(runner, true);
}
GUIInvalidateKeys(&runner->params);
uint32_t keys = 0xFFFFFFFF; // Huge hack to avoid an extra variable!
struct GUIMenuItem* item;
@ -580,7 +606,7 @@ void mGUIRunloop(struct mGUIRunner* runner) {
}
while (true) {
char path[PATH_MAX];
if (!GUISelectFile(&runner->params, path, sizeof(path), 0)) {
if (!GUISelectFile(&runner->params, path, sizeof(path), _testExtensions, NULL)) {
break;
}
mCoreConfigSetValue(&runner->config, "lastDirectory", runner->params.currentPath);

View File

@ -7,7 +7,6 @@
#include <mgba/core/tile-cache.h>
#include <mgba/internal/gba/gba.h>
#include <mgba/internal/gba/io.h>
#ifndef DISABLE_THREADING

View File

@ -219,7 +219,12 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf
mCoreConfigCopyValue(&core->config, config, "gb.model");
mCoreConfigCopyValue(&core->config, config, "sgb.model");
mCoreConfigCopyValue(&core->config, config, "cgb.model");
mCoreConfigCopyValue(&core->config, config, "sgb.borders");
int fakeBool;
if (mCoreConfigGetIntValue(config, "sgb.borders", &fakeBool)) {
gb->video.sgbBorders = fakeBool;
gb->video.renderer->enableSGBBorder(gb->video.renderer, fakeBool);
}
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
struct GBCore* gbcore = (struct GBCore*) core;
@ -383,11 +388,6 @@ static void _GBCoreReset(struct mCore* core) {
}
}
int fakeBool;
if (mCoreConfigGetIntValue(&core->config, "sgb.borders", &fakeBool)) {
gb->video.sgbBorders = fakeBool;
}
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
if (!gb->biosVf && core->opts.useBios) {
struct VFile* bios = NULL;

View File

@ -25,13 +25,14 @@ void GBLoadSymbols(struct mDebuggerSymbols* st, struct VFile* vf) {
uint8_t byte;
const char* buf = line;
while (buf) {
while (buf && bytesRead >= 2) {
buf = hex8(buf, &byte);
if (!buf) {
break;
}
address <<= 8;
address += byte;
bytesRead -= 2;
if (buf[0] == ':') {
segment = address;
@ -42,14 +43,19 @@ void GBLoadSymbols(struct mDebuggerSymbols* st, struct VFile* vf) {
break;
}
}
if (!buf) {
if (!buf || bytesRead < 1) {
continue;
}
while (isspace((int) buf[0])) {
while (isspace((int) buf[0]) && bytesRead > 0) {
--bytesRead;
++buf;
}
if (!bytesRead) {
continue;
}
mDebuggerSymbolAdd(st, buf, address, segment);
}
}

View File

@ -22,6 +22,7 @@ static void GBVideoProxyRendererWritePalette(struct GBVideoRenderer* renderer, i
static void GBVideoProxyRendererDrawRange(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj* obj, size_t oamMax);
static void GBVideoProxyRendererFinishScanline(struct GBVideoRenderer* renderer, int y);
static void GBVideoProxyRendererFinishFrame(struct GBVideoRenderer* renderer);
static void GBVideoProxyRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable);
static void GBVideoProxyRendererGetPixels(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels);
static void GBVideoProxyRendererPutPixels(struct GBVideoRenderer* renderer, size_t stride, const void* pixels);
@ -39,6 +40,7 @@ void GBVideoProxyRendererCreate(struct GBVideoProxyRenderer* renderer, struct GB
renderer->d.drawRange = GBVideoProxyRendererDrawRange;
renderer->d.finishScanline = GBVideoProxyRendererFinishScanline;
renderer->d.finishFrame = GBVideoProxyRendererFinishFrame;
renderer->d.enableSGBBorder = GBVideoProxyRendererEnableSGBBorder;
renderer->d.getPixels = GBVideoProxyRendererGetPixels;
renderer->d.putPixels = GBVideoProxyRendererPutPixels;
@ -260,6 +262,20 @@ void GBVideoProxyRendererFinishFrame(struct GBVideoRenderer* renderer) {
}
}
static void GBVideoProxyRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable) {
struct GBVideoProxyRenderer* proxyRenderer = (struct GBVideoProxyRenderer*) renderer;
if (proxyRenderer->logger->block && proxyRenderer->logger->wait) {
proxyRenderer->logger->lock(proxyRenderer->logger);
// Insert an extra item into the queue to make sure it gets flushed
mVideoLoggerRendererFlush(proxyRenderer->logger);
proxyRenderer->logger->wait(proxyRenderer->logger);
}
proxyRenderer->backend->enableSGBBorder(proxyRenderer->backend, enable);
if (proxyRenderer->logger->block && proxyRenderer->logger->wait) {
proxyRenderer->logger->unlock(proxyRenderer->logger);
}
}
static void GBVideoProxyRendererGetPixels(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels) {
struct GBVideoProxyRenderer* proxyRenderer = (struct GBVideoProxyRenderer*) renderer;
if (proxyRenderer->logger->block && proxyRenderer->logger->wait) {

View File

@ -157,6 +157,7 @@ bool GBLoadSave(struct GB* gb, struct VFile* vf) {
gb->sramRealVf = vf;
if (gb->sramSize) {
GBResizeSram(gb, gb->sramSize);
GBMBCSwitchSramBank(gb, gb->memory.sramCurrentBank);
}
return vf;
}
@ -256,7 +257,7 @@ void GBSavedataMask(struct GB* gb, struct VFile* vf, bool writeback) {
}
void GBSavedataUnmask(struct GB* gb) {
if (gb->sramVf == gb->sramRealVf) {
if (!gb->sramRealVf || gb->sramVf == gb->sramRealVf) {
return;
}
struct VFile* vf = gb->sramVf;
@ -268,6 +269,7 @@ void GBSavedataUnmask(struct GB* gb) {
vf->read(vf, gb->memory.sram, gb->sramSize);
gb->sramMaskWriteback = false;
}
GBMBCSwitchSramBank(gb, gb->memory.sramCurrentBank);
vf->close(vf);
}
@ -478,6 +480,7 @@ void GBSkipBIOS(struct GB* gb) {
switch (gb->model) {
case GB_MODEL_AUTODETECT: // Silence warnings
gb->model = GB_MODEL_DMG;
// Fall through
case GB_MODEL_DMG:
cpu->a = 1;
cpu->f.packed = 0xB0;

View File

@ -21,6 +21,7 @@ static void GBVideoSoftwareRendererWriteOAM(struct GBVideoRenderer* renderer, ui
static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj* obj, size_t oamMax);
static void GBVideoSoftwareRendererFinishScanline(struct GBVideoRenderer* renderer, int y);
static void GBVideoSoftwareRendererFinishFrame(struct GBVideoRenderer* renderer);
static void GBVideoSoftwareRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable);
static void GBVideoSoftwareRendererGetPixels(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels);
static void GBVideoSoftwareRendererPutPixels(struct GBVideoRenderer* renderer, size_t stride, const void* pixels);
@ -174,6 +175,7 @@ void GBVideoSoftwareRendererCreate(struct GBVideoSoftwareRenderer* renderer) {
renderer->d.drawRange = GBVideoSoftwareRendererDrawRange;
renderer->d.finishScanline = GBVideoSoftwareRendererFinishScanline;
renderer->d.finishFrame = GBVideoSoftwareRendererFinishFrame;
renderer->d.enableSGBBorder = GBVideoSoftwareRendererEnableSGBBorder;
renderer->d.getPixels = GBVideoSoftwareRendererGetPixels;
renderer->d.putPixels = GBVideoSoftwareRendererPutPixels;
@ -707,6 +709,16 @@ static void GBVideoSoftwareRendererFinishFrame(struct GBVideoRenderer* renderer)
softwareRenderer->hasWindow = false;
}
static void GBVideoSoftwareRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable) {
struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
if (softwareRenderer->model == GB_MODEL_SGB) {
softwareRenderer->sgbBorders = enable;
if (softwareRenderer->sgbBorders && !renderer->sgbRenderMode) {
_regenerateSGBBorder(softwareRenderer);
}
}
}
static void GBVideoSoftwareRendererDrawBackground(struct GBVideoSoftwareRenderer* renderer, uint8_t* maps, int startX, int endX, int sx, int sy) {
uint8_t* data = renderer->d.vram;
uint8_t* attr = &maps[GB_SIZE_VRAM_BANK0];

View File

@ -173,7 +173,6 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
mTimingSchedule(&gb->timing, &gb->eiPending, when);
}
enum GBModel oldModel = gb->model;
gb->model = state->model;
if (gb->model < GB_MODEL_CGB) {
@ -182,10 +181,6 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
gb->audio.style = GB_AUDIO_CGB;
}
if (gb->model != GB_MODEL_SGB || oldModel != GB_MODEL_SGB) {
gb->video.sgbBorders = false;
}
GBMemoryDeserialize(gb, state);
GBVideoDeserialize(&gb->video, state);
GBIODeserialize(gb, state);
@ -235,6 +230,7 @@ void GBSGBSerialize(struct GB* gb, struct GBSerializedState* state) {
if (gb->video.renderer->sgbAttributes) {
memcpy(state->sgb.attributes, gb->video.renderer->sgbAttributes, sizeof(state->sgb.attributes));
}
gb->video.renderer->enableSGBBorder(gb->video.renderer, gb->video.sgbBorders);
}
void GBSGBDeserialize(struct GB* gb, const struct GBSerializedState* state) {

View File

@ -26,6 +26,7 @@ static void GBVideoDummyRendererWriteOAM(struct GBVideoRenderer* renderer, uint1
static void GBVideoDummyRendererDrawRange(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj* obj, size_t oamMax);
static void GBVideoDummyRendererFinishScanline(struct GBVideoRenderer* renderer, int y);
static void GBVideoDummyRendererFinishFrame(struct GBVideoRenderer* renderer);
static void GBVideoDummyRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable);
static void GBVideoDummyRendererGetPixels(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels);
static void GBVideoDummyRendererPutPixels(struct GBVideoRenderer* renderer, size_t stride, const void* pixels);
@ -48,6 +49,7 @@ static struct GBVideoRenderer dummyRenderer = {
.drawRange = GBVideoDummyRendererDrawRange,
.finishScanline = GBVideoDummyRendererFinishScanline,
.finishFrame = GBVideoDummyRendererFinishFrame,
.enableSGBBorder = GBVideoDummyRendererEnableSGBBorder,
.getPixels = GBVideoDummyRendererGetPixels,
.putPixels = GBVideoDummyRendererPutPixels,
};
@ -784,6 +786,12 @@ static void GBVideoDummyRendererFinishFrame(struct GBVideoRenderer* renderer) {
// Nothing to do
}
static void GBVideoDummyRendererEnableSGBBorder(struct GBVideoRenderer* renderer, bool enable) {
UNUSED(renderer);
UNUSED(enable);
// Nothing to do
}
static void GBVideoDummyRendererGetPixels(struct GBVideoRenderer* renderer, size_t* stride, const void** pixels) {
UNUSED(renderer);
UNUSED(stride);

View File

@ -132,7 +132,6 @@ struct GBACore {
struct mCoreCallbacks logCallbacks;
#ifndef DISABLE_THREADING
struct mVideoThreadProxy threadProxy;
int threadedVideo;
#endif
int keys;
struct mCPUComponent* components[CPU_COMPONENT_MAX];
@ -172,7 +171,6 @@ static bool _GBACoreInit(struct mCore* core) {
gbacore->renderer.outputBuffer = NULL;
#ifndef DISABLE_THREADING
gbacore->threadedVideo = false;
mVideoThreadProxyCreate(&gbacore->threadProxy);
#endif
gbacore->proxyRenderer.logger = NULL;
@ -252,7 +250,7 @@ static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* con
mCoreConfigCopyValue(&core->config, config, "gba.bios");
#ifndef DISABLE_THREADING
mCoreConfigGetIntValue(config, "threadedVideo", &gbacore->threadedVideo);
mCoreConfigCopyValue(&core->config, config, "threadedVideo");
#endif
}
@ -397,7 +395,8 @@ static void _GBACoreReset(struct mCore* core) {
if (gbacore->renderer.outputBuffer) {
struct GBAVideoRenderer* renderer = &gbacore->renderer.d;
#ifndef DISABLE_THREADING
if (gbacore->threadedVideo) {
int fakeBool;
if (mCoreConfigGetIntValue(&core->config, "threadedVideo", &fakeBool) && fakeBool) {
gbacore->proxyRenderer.logger = &gbacore->threadProxy.d;
GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer);
renderer = &gbacore->proxyRenderer.d;
@ -724,29 +723,38 @@ static void _GBACoreDetachDebugger(struct mCore* core) {
}
static void _GBACoreLoadSymbols(struct mCore* core, struct VFile* vf) {
#ifdef USE_ELF
bool closeAfter = false;
core->symbolTable = mDebuggerSymbolTableCreate();
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
#ifdef USE_ELF
if (!vf) {
closeAfter = true;
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".elf", O_RDONLY);
}
#endif
if (!vf) {
closeAfter = true;
vf = mDirectorySetOpenSuffix(&core->dirs, core->dirs.base, ".sym", O_RDONLY);
}
#endif
if (!vf) {
return;
}
#ifdef USE_ELF
struct ELF* elf = ELFOpen(vf);
if (elf) {
#ifdef USE_DEBUGGERS
mCoreLoadELFSymbols(core->symbolTable, elf);
#endif
ELFClose(elf);
} else
#endif
{
mDebuggerLoadARMIPSSymbols(core->symbolTable, vf);
}
if (closeAfter) {
vf->close(vf);
}
#endif
}
static bool _GBACoreLookupIdentifier(struct mCore* core, const char* name, int32_t* value, int* segment) {
@ -859,6 +867,7 @@ static void _GBACoreEnableAudioChannel(struct mCore* core, size_t id, bool enabl
break;
case 4:
gba->audio.forceDisableChA = !enable;
break;
case 5:
gba->audio.forceDisableChB = !enable;
break;

View File

@ -202,13 +202,17 @@ void _dmaEvent(struct mTiming* timing, void* context, uint32_t cyclesLate) {
void GBADMAUpdate(struct GBA* gba) {
int i;
struct GBAMemory* memory = &gba->memory;
memory->activeDMA = -1;
uint32_t currentTime = mTimingCurrentTime(&gba->timing);
int32_t leastTime = INT_MAX;
memory->activeDMA = -1;
for (i = 0; i < 4; ++i) {
struct GBADMA* dma = &memory->dma[i];
if (GBADMARegisterIsEnable(dma->reg) && dma->nextCount) {
memory->activeDMA = i;
break;
int32_t time = dma->when - currentTime;
if (memory->activeDMA == -1 || (dma->count == dma->nextCount && time < leastTime)) {
leastTime = time;
memory->activeDMA = i;
}
}
}

View File

@ -45,9 +45,10 @@ static void GBAHitStub(struct ARMCore* cpu, uint32_t opcode);
static void GBAIllegal(struct ARMCore* cpu, uint32_t opcode);
static void GBABreakpoint(struct ARMCore* cpu, int immediate);
#ifdef USE_DEBUGGERS
static bool _setSoftwareBreakpoint(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
static bool _clearSoftwareBreakpoint(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
#endif
#ifdef FIXED_ROM_BUFFER
extern uint32_t* romBuffer;
@ -705,6 +706,7 @@ void GBAGetGameTitle(const struct GBA* gba, char* out) {
void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) {
struct GBA* gba = (struct GBA*) cpu->master;
UNUSED(gba);
#ifdef USE_DEBUGGERS
if (gba->debugger) {
struct mDebuggerEntryInfo info = {
@ -888,6 +890,7 @@ void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mo
}
}
#ifdef USE_DEBUGGERS
static bool _setSoftwareBreakpoint(struct ARMDebugger* debugger, uint32_t address, enum ExecutionMode mode, uint32_t* opcode) {
GBASetBreakpoint((struct GBA*) debugger->cpu->master, &debugger->d.p->d, address, mode, opcode);
return true;
@ -897,3 +900,4 @@ static bool _clearSoftwareBreakpoint(struct ARMDebugger* debugger, uint32_t addr
GBAClearBreakpoint((struct GBA*) debugger->cpu->master, address, mode, opcode);
return true;
}
#endif

View File

@ -121,6 +121,7 @@ void GBAMemoryReset(struct GBA* gba) {
}
memset(gba->memory.io, 0, sizeof(gba->memory.io));
GBAAdjustWaitstates(gba, 0);
gba->memory.agbPrint = 0;
memset(&gba->memory.agbPrintCtx, 0, sizeof(gba->memory.agbPrintCtx));
@ -364,6 +365,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
value <<= 16; \
value |= cpu->prefetch[0]; \
} \
break; \
default: \
value |= value << 16; \
} \

View File

@ -47,6 +47,7 @@ void GBASavedataInit(struct GBASavedata* savedata, struct VFile* vf) {
savedata->vf = vf;
savedata->realVf = vf;
savedata->mapMode = MAP_WRITE;
savedata->maskWriteback = false;
savedata->dirty = 0;
savedata->dirtAge = 0;
savedata->dust.name = "GBA Savedata Settling";
@ -95,7 +96,7 @@ void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf, bool writeb
}
void GBASavedataUnmask(struct GBASavedata* savedata) {
if (savedata->vf == savedata->realVf) {
if (!savedata->realVf || savedata->vf == savedata->realVf) {
return;
}
enum SavedataType type = savedata->type;
@ -194,10 +195,17 @@ bool GBASavedataLoad(struct GBASavedata* savedata, struct VFile* in) {
}
void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type) {
if (savedata->type == type) {
return;
}
if (savedata->type != SAVEDATA_AUTODETECT) {
struct VFile* vf = savedata->vf;
int mapMode = savedata->mapMode;
bool maskWriteback = savedata->maskWriteback;
GBASavedataDeinit(savedata);
GBASavedataInit(savedata, vf);
savedata->mapMode = mapMode;
savedata->maskWriteback = maskWriteback;
}
switch (type) {
case SAVEDATA_FLASH512:

View File

@ -61,6 +61,7 @@ void GBASerialize(struct GBA* gba, struct GBASerializedState* state) {
GBASerializedMiscFlags miscFlags = 0;
miscFlags = GBASerializedMiscFlagsSetHalted(miscFlags, gba->cpu->halted);
miscFlags = GBASerializedMiscFlagsSetPOSTFLG(miscFlags, gba->memory.io[REG_POSTFLG >> 1] & 1);
STORE_32(miscFlags, 0, &state->miscFlags);
GBAMemorySerialize(&gba->memory, state);
@ -177,6 +178,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
GBASerializedMiscFlags miscFlags = 0;
LOAD_32(miscFlags, 0, &state->miscFlags);
gba->cpu->halted = GBASerializedMiscFlagsGetHalted(miscFlags);
gba->memory.io[REG_POSTFLG >> 1] = GBASerializedMiscFlagsGetPOSTFLG(miscFlags);
GBAVideoDeserialize(&gba->video, state);
GBAMemoryDeserialize(&gba->memory, state);

View File

@ -246,10 +246,8 @@ void GBAVFameSramWrite(struct GBAVFameCart* cart, uint32_t address, uint8_t valu
// if mode has been set - the address and value of the SRAM write will be modified
address = _modifySramAddress(cart->cartType, address, cart->sramMode);
value = _modifySramValue(cart->cartType, value, cart->sramMode);
// these writes are mirrored
address &= 0x7FFF;
address &= (SIZE_CART_SRAM - 1);
sramData[address] = value;
sramData[address + 0x8000] = value;
}
static uint32_t _modifySramAddress(enum GBAVFameCartType type, uint32_t address, int mode) {

View File

@ -344,7 +344,7 @@ void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState
uint32_t when;
LOAD_32(when, 0, &state->video.nextEvent);
GBARegisterDISPSTAT dispstat = video->p->memory.io[REG_DISPSTAT >> 1];
GBARegisterDISPSTAT dispstat = state->io[REG_DISPSTAT >> 1];
if (GBARegisterDISPSTATIsInHblank(dispstat)) {
video->event.callback = _startHdraw;
} else {

View File

@ -45,7 +45,7 @@ set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM}/arm-none-eabi)
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM}/arm-none-eabi ${DEVKITPRO}/portlibs/3ds)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")

View File

@ -180,11 +180,6 @@ static void _map3DSKey(struct mInputMap* map, int ctrKey, enum GBAKey key) {
static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right);
static void _drawStart(void) {
C3D_FrameBufClear(&bottomScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0);
C3D_FrameBufClear(&topScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0);
}
static void _frameStart(void) {
if (frameStarted) {
return;
}
@ -193,12 +188,14 @@ static void _frameStart(void) {
if (!frameLimiter) {
if (tickCounter + 4481000 > svcGetSystemTick()) {
flags = C3D_FRAME_NONBLOCK;
} else {
tickCounter = svcGetSystemTick();
}
tickCounter = svcGetSystemTick();
}
C3D_FrameBegin(flags);
ctrStartFrame();
C3D_RenderTargetClear(bottomScreen[doubleBuffer], C3D_CLEAR_COLOR, 0, 0);
C3D_RenderTargetClear(topScreen[doubleBuffer], C3D_CLEAR_COLOR, 0, 0);
}
static void _drawEnd(void) {
@ -208,7 +205,7 @@ static void _drawEnd(void) {
ctrEndFrame();
C3D_RenderTargetSetOutput(topScreen[doubleBuffer], GFX_TOP, GFX_LEFT, GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
C3D_RenderTargetSetOutput(bottomScreen[doubleBuffer], GFX_BOTTOM, GFX_LEFT, GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
C3D_FrameEnd(GX_CMDLIST_FLUSH);
C3D_FrameEnd(0);
frameStarted = false;
doubleBuffer ^= 1;
@ -230,7 +227,6 @@ static int _batteryState(void) {
}
static void _guiPrepare(void) {
_frameStart();
C3D_FrameDrawOn(bottomScreen[doubleBuffer]);
ctrSetViewportSize(320, 240, true);
}
@ -254,8 +250,9 @@ static void _resetCamera(struct m3DSImageSource* imageSource) {
}
static void _setup(struct mGUIRunner* runner) {
uint8_t mask;
if (R_SUCCEEDED(svcGetProcessAffinityMask(&mask, CUR_PROCESS_HANDLE, 4)) && mask >= 4) {
bool n3ds = false;
APT_CheckNew3DS(&n3ds);
if (n3ds) {
mCoreConfigSetDefaultIntValue(&runner->config, "threadedVideo", 1);
mCoreLoadForeignConfig(runner->core, &runner->config);
}
@ -401,7 +398,6 @@ static void _gameUnloaded(struct mGUIRunner* runner) {
}
static void _drawTex(struct mCore* core, bool faded) {
_frameStart();
unsigned screen_w, screen_h;
switch (screenMode) {
case SM_PA_BOTTOM:
@ -545,7 +541,6 @@ static void _drawTex(struct mCore* core, bool faded) {
static void _drawFrame(struct mGUIRunner* runner, bool faded) {
UNUSED(runner);
C3D_Tex* tex = &outputTexture;
GSPGPU_FlushDataCache(outputBuffer, 256 * VIDEO_VERTICAL_PIXELS * 2);
@ -565,7 +560,6 @@ static void _drawFrame(struct mGUIRunner* runner, bool faded) {
}
static void _drawScreenshot(struct mGUIRunner* runner, const color_t* pixels, unsigned width, unsigned height, bool faded) {
C3D_Tex* tex = &outputTexture;
color_t* newPixels = linearMemAlign(256 * height * sizeof(color_t), 0x100);
@ -602,9 +596,6 @@ static void _incrementScreenMode(struct mGUIRunner* runner) {
UNUSED(runner);
screenMode = (screenMode + 1) % SM_MAX;
mCoreConfigSetUIntValue(&runner->config, "screenMode", screenMode);
C3D_FrameBufClear(&bottomScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0);
C3D_FrameBufClear(&topScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0);
}
static void _setFrameLimiter(struct mGUIRunner* runner, bool limit) {

View File

@ -11,10 +11,12 @@
#include <mgba/core/cheats.h>
#include <mgba/core/core.h>
#include <mgba/core/log.h>
#include <mgba/core/serialize.h>
#include <mgba/core/version.h>
#ifdef M_CORE_GB
#include <mgba/gb/core.h>
#include <mgba/internal/gb/gb.h>
#include <mgba/internal/gb/mbc.h>
#endif
#ifdef M_CORE_GBA
#include <mgba/gba/core.h>
@ -42,6 +44,10 @@ static void _postAudioBuffer(struct mAVStream*, blip_t* left, blip_t* right);
static void _setRumble(struct mRumble* rumble, int enable);
static uint8_t _readLux(struct GBALuminanceSource* lux);
static void _updateLux(struct GBALuminanceSource* lux);
static void _updateCamera(const uint32_t* buffer, unsigned width, unsigned height, size_t pitch);
static void _startImage(struct mImageSource*, unsigned w, unsigned h, int colorFormats);
static void _stopImage(struct mImageSource*);
static void _requestImage(struct mImageSource*, const void** buffer, size_t* stride, enum mColorFormat* colorFormat);
static struct mCore* core;
static void* outputBuffer;
@ -55,6 +61,12 @@ static struct mRumble rumble;
static struct GBALuminanceSource lux;
static int luxLevel;
static struct mLogger logger;
static struct retro_camera_callback cam;
static struct mImageSource imageSource;
static uint32_t* camData = NULL;
static unsigned camWidth;
static unsigned camHeight;
static size_t camStride;
static void _reloadSettings(void) {
struct mCoreOptions opts = {
@ -187,8 +199,17 @@ void retro_get_system_av_info(struct retro_system_av_info* info) {
core->desiredVideoDimensions(core, &width, &height);
info->geometry.base_width = width;
info->geometry.base_height = height;
info->geometry.max_width = width;
info->geometry.max_height = height;
#ifdef M_CORE_GB
if (core->platform(core) == PLATFORM_GB) {
info->geometry.max_width = 256;
info->geometry.max_height = 224;
} else
#endif
{
info->geometry.max_width = width;
info->geometry.max_height = height;
}
info->geometry.aspect_ratio = width / (double) height;
info->timing.fps = core->frequency(core) / (float) core->frameCycles(core);
info->timing.sample_rate = 32768;
@ -256,6 +277,10 @@ void retro_init(void) {
stream.postAudioBuffer = _postAudioBuffer;
stream.postVideoFrame = 0;
stream.videoFrameRateChanged = 0;
imageSource.startRequestImage = _startImage;
imageSource.stopRequestImage = _stopImage;
imageSource.requestImage = _requestImage;
}
void retro_deinit(void) {
@ -475,6 +500,14 @@ bool retro_load_game(const struct retro_game_info* game) {
#ifdef M_CORE_GB
if (core->platform(core) == PLATFORM_GB) {
memset(&cam, 0, sizeof(cam));
cam.height = GBCAM_HEIGHT;
cam.width = GBCAM_WIDTH;
cam.caps = 1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER;
cam.frame_raw_framebuffer = _updateCamera;
core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource);
environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam);
const char* modelName = mCoreConfigGetValue(&core->config, "gb.model");
struct GB* gb = core->board;
@ -496,7 +529,7 @@ bool retro_load_game(const struct retro_game_info* game) {
default:
biosName = "gb_bios.bin";
break;
};
}
}
#endif
@ -527,23 +560,33 @@ void retro_unload_game(void) {
}
size_t retro_serialize_size(void) {
return core->stateSize(core);
struct VFile* vfm = VFileMemChunk(NULL, 0);
mCoreSaveStateNamed(core, vfm, SAVESTATE_SAVEDATA | SAVESTATE_RTC);
size_t size = vfm->size(vfm);
vfm->close(vfm);
return size;
}
bool retro_serialize(void* data, size_t size) {
if (size != retro_serialize_size()) {
struct VFile* vfm = VFileMemChunk(NULL, 0);
mCoreSaveStateNamed(core, vfm, SAVESTATE_SAVEDATA | SAVESTATE_RTC);
if ((ssize_t) size > vfm->size(vfm)) {
size = vfm->size(vfm);
} else if ((ssize_t) size < vfm->size(vfm)) {
vfm->close(vfm);
return false;
}
core->saveState(core, data);
vfm->seek(vfm, 0, SEEK_SET);
vfm->read(vfm, data, size);
vfm->close(vfm);
return true;
}
bool retro_unserialize(const void* data, size_t size) {
if (size != retro_serialize_size()) {
return false;
}
core->loadState(core, data);
return true;
struct VFile* vfm = VFileFromConstMemory(data, size);
bool success = mCoreLoadStateNamed(core, vfm, SAVESTATE_RTC);
vfm->close(vfm);
return success;
}
void retro_cheat_reset(void) {
@ -732,3 +775,36 @@ static uint8_t _readLux(struct GBALuminanceSource* lux) {
}
return 0xFF - value;
}
static void _updateCamera(const uint32_t* buffer, unsigned width, unsigned height, size_t pitch) {
if (!camData || width != camWidth || height != camHeight) {
camData = malloc(sizeof(*buffer) * height * pitch);
camWidth = width;
camHeight = height;
camStride = pitch / sizeof(*buffer);
}
memcpy(camData, buffer, sizeof(*buffer) * height * pitch);
}
static void _startImage(struct mImageSource* image, unsigned w, unsigned h, int colorFormats) {
UNUSED(image);
UNUSED(colorFormats);
camData = NULL;
cam.start();
}
static void _stopImage(struct mImageSource* image) {
UNUSED(image);
cam.stop();
}
static void _requestImage(struct mImageSource* image, const void** buffer, size_t* stride, enum mColorFormat* colorFormat) {
UNUSED(image);
if (!camData) {
cam.start();
}
*buffer = camData;
*stride = camStride;
*colorFormat = mCOLOR_XRGB8;
}

View File

@ -234,8 +234,7 @@ static void _requestImage(struct mImageSource* source, const void** buffer, size
static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right) {
UNUSED(stream);
MutexLock(&audioContext.mutex);
struct GBAStereoSample* samples = &audioContext.buffer[audioContext.writeOffset];
while (audioContext.samples == PSP2_AUDIO_BUFFER_SIZE) {
while (audioContext.samples + PSP2_SAMPLES >= PSP2_AUDIO_BUFFER_SIZE) {
if (!frameLimiter) {
blip_clear(left);
blip_clear(right);
@ -244,6 +243,7 @@ static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* rig
}
ConditionWait(&audioContext.cond, &audioContext.mutex);
}
struct GBAStereoSample* samples = &audioContext.buffer[audioContext.writeOffset];
blip_read_samples(left, &samples[0].left, PSP2_SAMPLES, true);
blip_read_samples(right, &samples[0].right, PSP2_SAMPLES, true);
audioContext.samples += PSP2_SAMPLES;
@ -403,6 +403,8 @@ void mPSP2UnloadROM(struct mGUIRunner* runner) {
default:
break;
}
audioContext.running = false;
ThreadJoin(audioThread);
}
void mPSP2Paused(struct mGUIRunner* runner) {

View File

@ -236,6 +236,21 @@ class Core(object):
def step(self):
self._core.step(self._core)
@needs_reset
@protected
def load_raw_state(self, state):
if len(state) < self._core.stateSize(self._core):
return False
return self._core.loadState(self._core, state)
@needs_reset
@protected
def save_raw_state(self):
state = ffi.new('unsigned char[%i]' % self._core.stateSize(self._core))
if self._core.saveState(self._core, state):
return state
return None
@staticmethod
def _keys_to_int(*args, **kwargs):
keys = 0

View File

@ -13,6 +13,10 @@ def install_default(logger):
Logger.install_default(logger)
def silence():
Logger.install_default(NullLogger())
class Logger(object):
FATAL = lib.mLOG_FATAL
DEBUG = lib.mLOG_DEBUG

View File

@ -302,7 +302,7 @@ install(TARGETS ${BINARY_NAME}-qt
if(UNIX AND NOT APPLE)
find_program(DESKTOP_FILE_INSTALL desktop-file-install)
if(DESKTOP_FILE_INSTALL)
install(CODE "execute_process(COMMAND ${DESKTOP_FILE_INSTALL} \"${CMAKE_SOURCE_DIR}/res/${BINARY_NAME}-qt.desktop\" --dir \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications/\")")
install(CODE "execute_process(COMMAND ${DESKTOP_FILE_INSTALL} \"${CMAKE_SOURCE_DIR}/res/${BINARY_NAME}-qt.desktop\" --dir \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications/\")" COMPONENT ${BINARY_NAME}-qt)
endif()
endif()
if(UNIX)

View File

@ -107,7 +107,6 @@ ConfigController::ConfigController(QObject* parent)
m_opts.logLevel = mLOG_WARN | mLOG_ERROR | mLOG_FATAL;
m_opts.rewindEnable = false;
m_opts.rewindBufferCapacity = 300;
m_opts.rewindSave = true;
m_opts.useBios = true;
m_opts.suspendScreensaver = true;
m_opts.lockAspectRatio = true;

View File

@ -90,14 +90,8 @@ CoreController::CoreController(mCore* core, QObject* parent)
controller->m_resetActions.clear();
QSize size = controller->screenDimensions();
controller->m_buffers[0].resize(size.width() * size.height() * sizeof(color_t));
controller->m_buffers[1].resize(size.width() * size.height() * sizeof(color_t));
controller->m_buffers[0].fill(0xFF);
controller->m_buffers[1].fill(0xFF);
controller->m_activeBuffer = &controller->m_buffers[0];
context->core->setVideoBuffer(context->core, reinterpret_cast<color_t*>(controller->m_activeBuffer->data()), size.width());
context->core->setVideoBuffer(context->core, reinterpret_cast<color_t*>(controller->m_activeBuffer->data()), controller->screenDimensions().width());
controller->finishFrame();
};
@ -582,8 +576,8 @@ void CoreController::loadPatch(const QString& patchPath) {
if (patch) {
m_threadContext.core->loadPatch(m_threadContext.core, patch);
m_patched = true;
patch->close(patch);
}
patch->close(patch);
if (mCoreThreadHasStarted(&m_threadContext)) {
reset();
}
@ -776,7 +770,7 @@ void CoreController::finishFrame() {
m_activeBuffer = &m_buffers[1];
}
// Copy contents to avoid issues when doing frameskip
*m_activeBuffer = *m_completeBuffer;
memcpy(m_activeBuffer->data(), m_completeBuffer->data(), m_activeBuffer->size());
m_threadContext.core->setVideoBuffer(m_threadContext.core, reinterpret_cast<color_t*>(m_activeBuffer->data()), screenDimensions().width());
for (auto& action : m_frameActions) {

View File

@ -65,6 +65,7 @@ public slots:
virtual void framePosted() = 0;
virtual void setShaders(struct VDir*) = 0;
virtual void clearShaders() = 0;
virtual void resizeContext() = 0;
void showMessage(const QString& message);

View File

@ -163,6 +163,15 @@ void DisplayGL::clearShaders() {
QMetaObject::invokeMethod(m_painter, "clearShaders");
}
void DisplayGL::resizeContext() {
if (m_drawThread) {
m_isDrawing = false;
CoreController::Interrupter interrupter(m_context);
QMetaObject::invokeMethod(m_painter, "resizeContext", Qt::BlockingQueuedConnection);
}
}
void DisplayGL::resizeEvent(QResizeEvent* event) {
Display::resizeEvent(event);
resizePainter();
@ -254,8 +263,11 @@ PainterGL::~PainterGL() {
void PainterGL::setContext(std::shared_ptr<CoreController> context) {
m_context = context;
resizeContext();
}
if (!context) {
void PainterGL::resizeContext() {
if (!m_context) {
return;
}

View File

@ -61,6 +61,7 @@ public slots:
void framePosted() override;
void setShaders(struct VDir*) override;
void clearShaders() override;
void resizeContext() override;
protected:
virtual void paintEvent(QPaintEvent*) override {}
@ -100,6 +101,7 @@ public slots:
void lockAspectRatio(bool lock);
void lockIntegerScaling(bool lock);
void filter(bool filter);
void resizeContext();
void setShaders(struct VDir*);
void clearShaders();

View File

@ -68,6 +68,18 @@ void DisplayQt::framePosted() {
#endif
}
void DisplayQt::resizeContext() {
if (!m_context) {
return;
}
QSize size = m_context->screenDimensions();
if (m_width != size.width() || m_height != size.height()) {
m_width = size.width();
m_height = size.height();
m_backing = std::move(QImage());
}
}
void DisplayQt::paintEvent(QPaintEvent*) {
QPainter painter(this);
painter.fillRect(QRect(QPoint(), size()), Qt::black);

View File

@ -34,6 +34,7 @@ public slots:
void framePosted() override;
void setShaders(struct VDir*) override {}
void clearShaders() override {}
void resizeContext() override;
protected:
virtual void paintEvent(QPaintEvent*) override;

View File

@ -64,10 +64,20 @@ GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config)
if (!m_configController->getQtOption("audioDriver").isNull()) {
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController->getQtOption("audioDriver").toInt()));
}
connect(this, &GBAApp::aboutToQuit, this, &GBAApp::cleanup);
}
GBAApp::~GBAApp() {
void GBAApp::cleanup() {
m_workerThreads.waitForDone();
while (!m_workerJobs.isEmpty()) {
finishJob(m_workerJobs.firstKey());
}
if (m_db) {
NoIntroDBDestroy(m_db);
}
}
bool GBAApp::event(QEvent* event) {
@ -177,7 +187,7 @@ bool GBAApp::reloadGameDB() {
NoIntroDBDestroy(m_db);
}
if (db) {
GameDBParser* parser = new GameDBParser(db);
std::shared_ptr<GameDBParser> parser = std::make_shared<GameDBParser>(db);
submitWorkerJob(std::bind(&GameDBParser::parseNoIntroDB, parser));
m_db = db;
return true;

View File

@ -52,7 +52,6 @@ Q_OBJECT
public:
GBAApp(int& argc, char* argv[], ConfigController*);
~GBAApp();
static GBAApp* app();
static QString dataDir();
@ -79,6 +78,7 @@ protected:
private slots:
void finishJob(qint64 jobId);
void cleanup();
private:
class WorkerJob : public QRunnable {

View File

@ -149,12 +149,6 @@ void MemoryModel::jumpToAddress(const QString& hex) {
}
void MemoryModel::jumpToAddress(uint32_t address) {
if (address >= 0x10000000) {
return;
}
if (address < m_base || address >= m_base + m_size) {
setRegion(0, 0x10000000, tr("All"));
}
m_top = (address - m_base) / 16;
boundsCheck();
verticalScrollBar()->setValue(m_top);

View File

@ -42,7 +42,7 @@ MemoryView::MemoryView(std::shared_ptr<CoreController> controller, QWidget* pare
connect(m_ui.width16, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(2); });
connect(m_ui.width32, &QAbstractButton::clicked, [this]() { m_ui.hexfield->setAlignment(4); });
connect(m_ui.setAddress, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
m_ui.hexfield, static_cast<void (MemoryModel::*)(uint32_t)>(&MemoryModel::jumpToAddress));
this, static_cast<void (MemoryView::*)(uint32_t)>(&MemoryView::jumpToAddress));
connect(m_ui.hexfield, &MemoryModel::selectionChanged, this, &MemoryView::updateSelection);
connect(controller.get(), &CoreController::stopping, this, &QWidget::close);
@ -66,6 +66,7 @@ void MemoryView::setIndex(int index) {
size_t nBlocks = core->listMemoryBlocks(core, &blocks);
const mCoreMemoryBlock& info = blocks[index];
m_region = qMakePair(info.start, info.end);
m_ui.segments->setValue(-1);
m_ui.segments->setVisible(info.maxSegment > 0);
m_ui.segments->setMaximum(info.maxSegment);
@ -86,6 +87,17 @@ void MemoryView::update() {
updateStatus();
}
void MemoryView::jumpToAddress(uint32_t address) {
if (address < m_region.first || address >= m_region.second) {
m_ui.regions->setCurrentIndex(0);
setIndex(0);
}
if (address < m_region.first || address >= m_region.second) {
return;
}
m_ui.hexfield->jumpToAddress(address);
}
void MemoryView::updateSelection(uint32_t start, uint32_t end) {
m_selection.first = start;
m_selection.second = end;

View File

@ -21,7 +21,7 @@ public:
public slots:
void update();
void jumpToAddress(uint32_t address) { m_ui.hexfield->jumpToAddress(address); }
void jumpToAddress(uint32_t address);
private slots:
void setIndex(int);
@ -33,6 +33,7 @@ private:
Ui::MemoryView m_ui;
std::shared_ptr<CoreController> m_controller;
QPair<uint32_t, uint32_t> m_region;
QPair<uint32_t, uint32_t> m_selection;
};

View File

@ -346,7 +346,6 @@ void SettingsView::updateConfig() {
saveSetting("mute", m_ui.mute);
saveSetting("rewindEnable", m_ui.rewind);
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
saveSetting("rewindSave", m_ui.rewindSave);
saveSetting("resampleVideo", m_ui.resampleVideo);
saveSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
@ -477,7 +476,6 @@ void SettingsView::reloadConfig() {
loadSetting("mute", m_ui.mute);
loadSetting("rewindEnable", m_ui.rewind);
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
loadSetting("rewindSave", m_ui.rewindSave);
loadSetting("resampleVideo", m_ui.resampleVideo);
loadSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
loadSetting("suspendScreensaver", m_ui.suspendScreensaver);

View File

@ -326,6 +326,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QDoubleSpinBox" name="fpsTarget">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
@ -609,6 +612,23 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Autofire interval:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="autofireThreshold">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
@ -648,21 +668,21 @@
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Idle loops:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="idleOptimization">
<item>
<property name="text">
@ -681,21 +701,28 @@
</item>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="7" column="1">
<widget class="QCheckBox" name="preload">
<property name="text">
<string>Preload entire ROM into memory</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Savestate extra data:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="saveStateScreenshot">
<property name="text">
<string>Screenshot</string>
@ -705,7 +732,7 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="saveStateSave">
<property name="text">
<string>Save data</string>
@ -715,7 +742,7 @@
</property>
</widget>
</item>
<item row="12" column="1">
<item row="11" column="1">
<widget class="QCheckBox" name="saveStateCheats">
<property name="text">
<string>Cheat codes</string>
@ -725,14 +752,21 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="12" column="0" colspan="2">
<widget class="Line" name="line_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Load extra data:</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="13" column="1">
<widget class="QCheckBox" name="loadStateScreenshot">
<property name="text">
<string>Screenshot</string>
@ -742,61 +776,20 @@
</property>
</widget>
</item>
<item row="15" column="1">
<item row="14" column="1">
<widget class="QCheckBox" name="loadStateSave">
<property name="text">
<string>Save data</string>
</property>
</widget>
</item>
<item row="16" column="1">
<item row="15" column="1">
<widget class="QCheckBox" name="loadStateCheats">
<property name="text">
<string>Cheat codes</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2">
<widget class="Line" name="line_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="rewindSave">
<property name="text">
<string>Rewind affects save data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="preload">
<property name="text">
<string>Preload entire ROM into memory</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Autofire interval:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="autofireThreshold">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="bios">

View File

@ -268,6 +268,7 @@ void Window::reloadConfig() {
m_audioProcessor->setBufferSamples(opts->audioBuffers);
m_audioProcessor->requestSampleRate(opts->sampleRate);
}
m_display->resizeContext();
}
m_display->lockAspectRatio(opts->lockAspectRatio);
m_display->filter(opts->resampleVideo);
@ -904,6 +905,7 @@ void Window::reloadDisplayDriver() {
if (m_controller) {
m_display->setMinimumSize(m_controller->screenDimensions());
connect(m_controller.get(), &CoreController::stopping, m_display.get(), &Display::stopDrawing);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::paused, m_display.get(), &Display::pauseDrawing);
@ -1468,17 +1470,22 @@ void Window::setupMenu(QMenuBar* menubar) {
QMenu* target = avMenu->addMenu(tr("FPS target"));
ConfigOption* fpsTargetOption = m_config->addOption("fpsTarget");
fpsTargetOption->connect([this](const QVariant& value) {
QMap<double, QAction*> fpsTargets;
for (int fps : {15, 30, 45, 60, 90, 120, 240}) {
fpsTargets[fps] = fpsTargetOption->addValue(QString::number(fps), fps, target);
}
target->addSeparator();
double nativeGB = double(GBA_ARM7TDMI_FREQUENCY) / double(VIDEO_TOTAL_LENGTH);
fpsTargets[nativeGB] = fpsTargetOption->addValue(tr("Native (59.7275)"), nativeGB, target);
fpsTargetOption->connect([this, fpsTargets](const QVariant& value) {
reloadConfig();
for (auto iter = fpsTargets.begin(); iter != fpsTargets.end(); ++iter) {
bool enableSignals = iter.value()->blockSignals(true);
iter.value()->setChecked(abs(iter.key() - value.toDouble()) < 0.001);
iter.value()->blockSignals(enableSignals);
}
}, this);
fpsTargetOption->addValue(tr("15"), 15, target);
fpsTargetOption->addValue(tr("30"), 30, target);
fpsTargetOption->addValue(tr("45"), 45, target);
fpsTargetOption->addValue(tr("Native (59.7)"), float(GBA_ARM7TDMI_FREQUENCY) / float(VIDEO_TOTAL_LENGTH), target);
fpsTargetOption->addValue(tr("60"), 60, target);
fpsTargetOption->addValue(tr("90"), 90, target);
fpsTargetOption->addValue(tr("120"), 120, target);
fpsTargetOption->addValue(tr("240"), 240, target);
m_config->updateOption("fpsTarget");
avMenu->addSeparator();
@ -1674,11 +1681,6 @@ void Window::setupMenu(QMenuBar* menubar) {
reloadConfig();
}, this);
ConfigOption* rewindSave = m_config->addOption("rewindSave");
rewindBufferCapacity->connect([this](const QVariant& value) {
reloadConfig();
}, this);
ConfigOption* allowOpposingDirections = m_config->addOption("allowOpposingDirections");
allowOpposingDirections->connect([this](const QVariant& value) {
reloadConfig();
@ -1808,7 +1810,7 @@ void Window::focusCheck() {
void Window::updateFrame() {
QSize size = m_controller->screenDimensions();
QImage currentImage(reinterpret_cast<const uchar*>(m_controller->drawContext()), size.width(), size.height(),
size.width() * BYTES_PER_PIXEL, QImage::Format_RGBX8888);
256 * BYTES_PER_PIXEL, QImage::Format_RGBX8888);
QPixmap pixmap;
pixmap.convertFromImage(currentImage);
m_screenWidget->setPixmap(pixmap);
@ -1870,6 +1872,7 @@ void Window::setController(CoreController* controller, const QString& fname) {
});
connect(m_controller.get(), &CoreController::stopping, m_display.get(), &Display::stopDrawing);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::paused, m_display.get(), &Display::pauseDrawing);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ if (SDL_VERSION EQUAL "2")
set(SDL_LIBRARY ${SDL2_LIBRARIES})
link_directories(${SDL2_LIBDIR})
set(SDL_VERSION_DEBIAN "2-2.0-0")
set(SDL_FOUND ON PARENT_SCOPE)
endif()
endif()

View File

@ -61,6 +61,7 @@ void mSDLGLRunloop(struct mSDLRenderer* renderer, void* user) {
}
#endif
}
renderer->core->desiredVideoDimensions(renderer->core, &renderer->width, &renderer->height);
if (renderer->width != v->width || renderer->height != v->height) {
renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width);
v->setDimensions(v, renderer->width, renderer->height);

View File

@ -0,0 +1,53 @@
find_program(ELF2NRO elf2nro)
find_program(NACPTOOL nacptool)
find_program(BUILD_ROMFS build_romfs)
find_library(GLAPI_LIBRARY glapi REQUIRED)
find_library(EGL_LIBRARY EGL REQUIRED)
set(OS_DEFINES USE_VFS_FILE IOAPI_NO_64)
list(APPEND CORE_VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
include_directories(AFTER ${OPENGLES2_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIR})
file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/wii/wii-*.c)
if(${CMAKE_BUILD_TYPE} STREQUAL Debug OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
find_library(NOUVEAU_LIBRARY drm_nouveaud REQUIRED)
list(APPEND OS_LIB nxd)
else()
find_library(NOUVEAU_LIBRARY drm_nouveau REQUIRED)
list(APPEND OS_LIB nx)
endif()
set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
set(OS_SRC ${OS_SRC} PARENT_SCOPE)
set(OS_LIB ${OS_LIB} PARENT_SCOPE)
if(BUILD_PERF)
add_custom_target(${BINARY_NAME}-perf.nro ALL
${ELF2NRO} ../${BINARY_NAME}-perf ${BINARY_NAME}-perf.nro
DEPENDS ${BINARY_NAME}-perf)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.nro
DESTINATION . COMPONENT ${BINARY_NAME}-perf)
endif()
add_executable(${BINARY_NAME}.elf ${GUI_SRC} ${PLATFORM_SRC} main.c)
set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${M_LIBRARY} ${EGL_LIBRARY} ${OPENGLES2_LIBRARY} ${GLAPI_LIBRARY} ${NOUVEAU_LIBRARY} stdc++ ${OS_LIB})
add_custom_command(OUTPUT control.nacp
COMMAND ${NACPTOOL} --create "${PROJECT_NAME}" "endrift" "${VERSION_STRING}" control.nacp)
add_custom_command(OUTPUT romfs.bin
COMMAND ${CMAKE_COMMAND} -E make_directory romfs
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/res/font-new.png" romfs/
COMMAND ${BUILD_ROMFS} romfs romfs.bin
COMMAND ${CMAKE_COMMAND} -E remove_directory romfs
DEPENDS "${CMAKE_SOURCE_DIR}/res/font-new.png")
add_custom_target(${BINARY_NAME}.nro ALL
${ELF2NRO} ${BINARY_NAME}.elf ${BINARY_NAME}.nro --romfs=romfs.bin --nacp=control.nacp --icon="${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg"
DEPENDS ${BINARY_NAME}.elf control.nacp ${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg romfs.bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.nro DESTINATION . COMPONENT ${BINARY_NAME}-switch)

View File

@ -0,0 +1,56 @@
if(DEFINED ENV{DEVKITPRO})
set(DEVKITPRO $ENV{DEVKITPRO})
else()
message(FATAL_ERROR "Could not find DEVKITPRO in environment")
endif()
if(DEFINED ENV{DEVKITA64})
set(DEVKITA64 $ENV{DEVKITA64})
else()
set(DEVKITA64 ${DEVKITPRO}/devkitA64)
endif()
if(DEFINED ENV{LIBNX})
set(LIBNX $ENV{LIBNX})
else()
set(LIBNX ${DEVKITPRO}/libnx)
endif()
set(extension)
if (CMAKE_HOST_WIN32)
set(extension .exe)
endif()
set(CMAKE_PROGRAM_PATH ${DEVKITA64}/bin)
set(cross_prefix aarch64-none-elf-)
set(arch_flags "-mtune=cortex-a57 -ffunction-sections -march=armv8-a -mtp=soft -fPIC -ftls-model=local-exec")
set(inc_flags "-I${LIBNX}/include ${arch_flags}")
set(link_flags "-L${LIBNX}/lib -lnx -specs=${LIBNX}/switch.specs ${arch_flags}")
set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name")
set(CMAKE_SYSTEM_PROCESSOR aarch64 CACHE INTERNAL "processor")
set(CMAKE_LIBRARY_ARCHITECTURE aarch64-none-elf CACHE INTERNAL "abi")
find_program(CMAKE_AR ${cross_prefix}gcc-ar${extension})
find_program(CMAKE_RANLIB ${cross_prefix}gcc-ranlib${extension})
find_program(CMAKE_C_COMPILER ${cross_prefix}gcc${extension})
find_program(CMAKE_CXX_COMPILER ${cross_prefix}g++${extension})
find_program(CMAKE_ASM_COMPILER ${cross_prefix}gcc${extension})
find_program(CMAKE_LINKER ${cross_prefix}ld${extension})
set(CMAKE_C_FLAGS ${inc_flags} CACHE INTERNAL "c compiler flags")
set(CMAKE_ASM_FLAGS ${inc_flags} CACHE INTERNAL "assembler flags")
set(CMAKE_CXX_FLAGS ${inc_flags} CACHE INTERNAL "cxx compiler flags")
SET(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
set(CMAKE_FIND_ROOT_PATH ${DEVKITARM}/aarch64-none-elf ${DEVKITPRO}/portlibs/switch)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")
set(PKG_CONFIG_EXECUTABLE "/dev/null" CACHE INTERNAL "" FORCE)
set(SWITCH ON)
add_definitions(-D__SWITCH__)

View File

@ -0,0 +1,364 @@
/* Copyright (c) 2013-2018 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba-util/gui/font.h>
#include <mgba-util/gui/font-metrics.h>
#include <mgba-util/png-io.h>
#include <mgba-util/string.h>
#include <mgba-util/vfs.h>
#include <GLES2/gl2.h>
#define GLYPH_HEIGHT 24
#define CELL_HEIGHT 32
#define CELL_WIDTH 32
static const GLfloat _offsets[] = {
0.f, 0.f,
1.f, 0.f,
1.f, 1.f,
0.f, 1.f,
};
static const GLchar* const _gles2Header =
"#version 100\n"
"precision mediump float;\n";
static const char* const _vertexShader =
"attribute vec2 offset;\n"
"uniform vec3 origin;\n"
"uniform vec2 glyph;\n"
"uniform vec2 dims;\n"
"uniform mat2 transform;\n"
"varying vec2 texCoord;\n"
"void main() {\n"
" texCoord = (glyph + offset * dims) / 512.0;\n"
" vec2 scaledOffset = (transform * (offset * 2.0 - vec2(1.0)) + vec2(1.0)) / 2.0 * dims;\n"
" gl_Position = vec4((origin.x + scaledOffset.x) / 640.0 - 1.0, -(origin.y + scaledOffset.y) / 360.0 + 1.0, origin.z, 1.0);\n"
"}";
static const char* const _fragmentShader =
"varying vec2 texCoord;\n"
"uniform sampler2D tex;\n"
"uniform vec4 color;\n"
"uniform float cutoff;\n"
"void main() {\n"
" vec4 texColor = texture2D(tex, texCoord);\n"
" texColor.a = clamp((texColor.a - cutoff) / (1.0 - cutoff), 0.0, 1.0);\n"
" texColor.rgb = color.rgb;\n"
" texColor.a *= color.a;\n"
" gl_FragColor = texColor;\n"
"}";
struct GUIFont {
GLuint font;
GLuint program;
GLuint vbo;
GLuint offsetLocation;
GLuint texLocation;
GLuint dimsLocation;
GLuint transformLocation;
GLuint colorLocation;
GLuint originLocation;
GLuint glyphLocation;
GLuint cutoffLocation;
};
static bool _loadTexture(const char* path) {
struct VFile* vf = VFileOpen(path, O_RDONLY);
if (!vf) {
return false;
}
png_structp png = PNGReadOpen(vf, 0);
png_infop info = png_create_info_struct(png);
png_infop end = png_create_info_struct(png);
bool success = false;
if (png && info && end) {
success = PNGReadHeader(png, info);
}
void* pixels = NULL;
if (success) {
unsigned height = png_get_image_height(png, info);
unsigned width = png_get_image_width(png, info);
pixels = malloc(width * height);
if (pixels) {
success = PNGReadPixels8(png, info, pixels, width, height, width);
success = success && PNGReadFooter(png, end);
} else {
success = false;
}
if (success) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
}
}
PNGReadClose(png, info, end);
if (pixels) {
free(pixels);
}
vf->close(vf);
return success;
}
struct GUIFont* GUIFontCreate(void) {
struct GUIFont* font = malloc(sizeof(struct GUIFont));
if (!font) {
return NULL;
}
glGenTextures(1, &font->font);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, font->font);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (!_loadTexture("romfs:/font-new.png")) {
GUIFontDestroy(font);
return NULL;
}
font->program = glCreateProgram();
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
const GLchar* shaderBuffer[2];
shaderBuffer[0] = _gles2Header;
shaderBuffer[1] = _vertexShader;
glShaderSource(vertexShader, 2, shaderBuffer, NULL);
shaderBuffer[1] = _fragmentShader;
glShaderSource(fragmentShader, 2, shaderBuffer, NULL);
glAttachShader(font->program, vertexShader);
glAttachShader(font->program, fragmentShader);
glCompileShader(fragmentShader);
GLint success;
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar msg[512];
glGetShaderInfoLog(fragmentShader, sizeof(msg), NULL, msg);
puts(msg);
}
glCompileShader(vertexShader);
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar msg[512];
glGetShaderInfoLog(vertexShader, sizeof(msg), NULL, msg);
puts(msg);
}
glLinkProgram(font->program);
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
font->texLocation = glGetUniformLocation(font->program, "tex");
font->colorLocation = glGetUniformLocation(font->program, "color");
font->dimsLocation = glGetUniformLocation(font->program, "dims");
font->transformLocation = glGetUniformLocation(font->program, "transform");
font->originLocation = glGetUniformLocation(font->program, "origin");
font->glyphLocation = glGetUniformLocation(font->program, "glyph");
font->cutoffLocation = glGetUniformLocation(font->program, "cutoff");
font->offsetLocation = glGetAttribLocation(font->program, "offset");
glGenBuffers(1, &font->vbo);
glBindBuffer(GL_ARRAY_BUFFER, font->vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(_offsets), _offsets, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return font;
}
void GUIFontDestroy(struct GUIFont* font) {
glDeleteBuffers(1, &font->vbo);
glDeleteProgram(font->program);
glDeleteTextures(1, &font->font);
free(font);
}
unsigned GUIFontHeight(const struct GUIFont* font) {
UNUSED(font);
return GLYPH_HEIGHT;
}
unsigned GUIFontGlyphWidth(const struct GUIFont* font, uint32_t glyph) {
UNUSED(font);
if (glyph > 0x7F) {
glyph = '?';
}
return defaultFontMetrics[glyph].width * 2;
}
void GUIFontIconMetrics(const struct GUIFont* font, enum GUIIcon icon, unsigned* w, unsigned* h) {
UNUSED(font);
if (icon >= GUI_ICON_MAX) {
if (w) {
*w = 0;
}
if (h) {
*h = 0;
}
} else {
if (w) {
*w = defaultIconMetrics[icon].width * 2;
}
if (h) {
*h = defaultIconMetrics[icon].height * 2;
}
}
}
void GUIFontDrawGlyph(const struct GUIFont* font, int x, int y, uint32_t color, uint32_t glyph) {
if (glyph > 0x7F) {
glyph = '?';
}
struct GUIFontGlyphMetric metric = defaultFontMetrics[glyph];
glUseProgram(font->program);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, font->font);
glBindBuffer(GL_ARRAY_BUFFER, font->vbo);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUniform1i(font->texLocation, 0);
glUniform2f(font->glyphLocation, (glyph & 15) * CELL_WIDTH + metric.padding.left * 2, (glyph >> 4) * CELL_HEIGHT + metric.padding.top * 2);
glUniform2f(font->dimsLocation, CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2, CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2);
glUniform3f(font->originLocation, x, y - GLYPH_HEIGHT + metric.padding.top * 2, 0);
glUniformMatrix2fv(font->transformLocation, 1, GL_FALSE, (float[4]) {1.0, 0.0, 0.0, 1.0});
glVertexAttribPointer(font->offsetLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(font->offsetLocation);
glUniform1f(font->cutoffLocation, 0.1f);
glUniform4f(font->colorLocation, 0.0, 0.0, 0.0, ((color >> 24) & 0xFF) / 128.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glUniform1f(font->cutoffLocation, 0.7f);
glUniform4f(font->colorLocation, ((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color & 0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(font->offsetLocation);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
}
void GUIFontDrawIcon(const struct GUIFont* font, int x, int y, enum GUIAlignment align, enum GUIOrientation orient, uint32_t color, enum GUIIcon icon) {
if (icon >= GUI_ICON_MAX) {
return;
}
struct GUIIconMetric metric = defaultIconMetrics[icon];
float hFlip = 1.0f;
float vFlip = 1.0f;
switch (align & GUI_ALIGN_HCENTER) {
case GUI_ALIGN_HCENTER:
x -= metric.width;
break;
case GUI_ALIGN_RIGHT:
x -= metric.width * 2;
break;
}
switch (align & GUI_ALIGN_VCENTER) {
case GUI_ALIGN_VCENTER:
y -= metric.height;
break;
case GUI_ALIGN_BOTTOM:
y -= metric.height * 2;
break;
}
glUseProgram(font->program);
switch (orient) {
case GUI_ORIENT_HMIRROR:
hFlip = -1.0;
break;
case GUI_ORIENT_VMIRROR:
vFlip = -1.0;
break;
case GUI_ORIENT_0:
default:
// TODO: Rotate
break;
}
glUseProgram(font->program);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, font->font);
glBindBuffer(GL_ARRAY_BUFFER, font->vbo);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUniform1i(font->texLocation, 0);
glUniform2f(font->glyphLocation, metric.x * 2, metric.y * 2 + 256);
glUniform2f(font->dimsLocation, metric.width * 2, metric.height * 2);
glUniform3f(font->originLocation, x, y, 0);
glUniformMatrix2fv(font->transformLocation, 1, GL_FALSE, (float[4]) {hFlip, 0.0, 0.0, vFlip});
glVertexAttribPointer(font->offsetLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(font->offsetLocation);
glUniform1f(font->cutoffLocation, 0.1f);
glUniform4f(font->colorLocation, 0.0, 0.0, 0.0, ((color >> 24) & 0xFF) / 128.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glUniform1f(font->cutoffLocation, 0.7f);
glUniform4f(font->colorLocation, ((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color & 0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(font->offsetLocation);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
}
void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon) {
if (icon >= GUI_ICON_MAX) {
return;
}
struct GUIIconMetric metric = defaultIconMetrics[icon];
if (!w) {
w = metric.width * 2;
}
if (!h) {
h = metric.height * 2;
}
glUseProgram(font->program);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, font->font);
glBindBuffer(GL_ARRAY_BUFFER, font->vbo);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUniform1i(font->texLocation, 0);
glUniform2f(font->glyphLocation, metric.x * 2, metric.y * 2 + 256);
glUniform2f(font->dimsLocation, metric.width * 2, metric.height * 2);
glUniform3f(font->originLocation, x + w / 2 - metric.width, y + h / 2 - metric.height, 0);
glUniformMatrix2fv(font->transformLocation, 1, GL_FALSE, (float[4]) {w * 0.5f / metric.width, 0.0, 0.0, h * 0.5f / metric.height});
glVertexAttribPointer(font->offsetLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(font->offsetLocation);
glUniform1f(font->cutoffLocation, 0.1f);
glUniform4f(font->colorLocation, 0.0, 0.0, 0.0, ((color >> 24) & 0xFF) / 128.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glUniform1f(font->cutoffLocation, 0.7f);
glUniform4f(font->colorLocation, ((color >> 16) & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, (color & 0xFF) / 255.0f, ((color >> 24) & 0xFF) / 255.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(font->offsetLocation);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

487
src/platform/switch/main.c Normal file
View File

@ -0,0 +1,487 @@
/* Copyright (c) 2013-2018 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "feature/gui/gui-runner.h"
#include <mgba/core/blip_buf.h>
#include <mgba/core/core.h>
#include <mgba/internal/gba/audio.h>
#include <mgba/internal/gba/input.h>
#include <mgba-util/gui.h>
#include <mgba-util/gui/font.h>
#include <switch.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#define AUTO_INPUT 0x4E585031
#define SAMPLES 0x400
#define BUFFER_SIZE 0x1000
#define N_BUFFERS 4
TimeType __nx_time_type = TimeType_UserSystemClock;
static EGLDisplay s_display;
static EGLContext s_context;
static EGLSurface s_surface;
static const GLfloat _offsets[] = {
0.f, 0.f,
1.f, 0.f,
1.f, 1.f,
0.f, 1.f,
};
static const GLchar* const _gles2Header =
"#version 100\n"
"precision mediump float;\n";
static const char* const _vertexShader =
"attribute vec2 offset;\n"
"uniform vec2 dims;\n"
"uniform vec2 insize;\n"
"varying vec2 texCoord;\n"
"void main() {\n"
" vec2 ratio = insize / 256.0;\n"
" vec2 scaledOffset = offset * dims;\n"
" gl_Position = vec4(scaledOffset.x * 2.0 - dims.x, scaledOffset.y * -2.0 + dims.y, 0.0, 1.0);\n"
" texCoord = offset * ratio;\n"
"}";
static const char* const _fragmentShader =
"varying vec2 texCoord;\n"
"uniform sampler2D tex;\n"
"uniform vec4 color;\n"
"void main() {\n"
" vec4 texColor = vec4(texture2D(tex, texCoord).rgb, 1.0);\n"
" texColor *= color;\n"
" gl_FragColor = texColor;\n"
"}";
static GLuint program;
static GLuint vbo;
static GLuint offsetLocation;
static GLuint texLocation;
static GLuint dimsLocation;
static GLuint insizeLocation;
static GLuint colorLocation;
static GLuint tex;
static color_t frameBuffer[256 * 256];
static struct mAVStream stream;
static int audioBufferActive;
static struct GBAStereoSample audioBuffer[N_BUFFERS][SAMPLES] __attribute__((__aligned__(0x1000)));
static AudioOutBuffer audoutBuffer[N_BUFFERS];
static int enqueuedBuffers;
static bool frameLimiter = true;
static int framecount = 0;
static bool initEgl() {
s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!s_display) {
goto _fail0;
}
eglInitialize(s_display, NULL, NULL);
EGLConfig config;
EGLint numConfigs;
static const EGLint attributeList[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_NONE
};
eglChooseConfig(s_display, attributeList, &config, 1, &numConfigs);
if (!numConfigs) {
goto _fail1;
}
s_surface = eglCreateWindowSurface(s_display, config, "", NULL);
if (!s_surface) {
goto _fail1;
}
//EGLint contextAttributeList[] = {
// EGL_CONTEXT_CLIENT_VERSION, 2,
// EGL_NONE
//};
s_context = eglCreateContext(s_display, config, EGL_NO_CONTEXT, NULL);
if (!s_context) {
goto _fail2;
}
eglMakeCurrent(s_display, s_surface, s_surface, s_context);
return true;
_fail2:
eglDestroySurface(s_display, s_surface);
s_surface = NULL;
_fail1:
eglTerminate(s_display);
s_display = NULL;
_fail0:
return false;
}
static void deinitEgl() {
if (s_display) {
if (s_context) {
eglDestroyContext(s_display, s_context);
}
if (s_surface) {
eglDestroySurface(s_display, s_surface);
}
eglTerminate(s_display);
}
}
static void _mapKey(struct mInputMap* map, uint32_t binding, int nativeKey, enum GBAKey key) {
mInputBindKey(map, binding, __builtin_ctz(nativeKey), key);
}
static void _drawStart(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static void _drawEnd(void) {
if (frameLimiter || (framecount & 3) == 0) {
eglSwapBuffers(s_display, s_surface);
}
}
static uint32_t _pollInput(const struct mInputMap* map) {
int keys = 0;
hidScanInput();
u32 padkeys = hidKeysHeld(CONTROLLER_P1_AUTO);
keys |= mInputMapKeyBits(map, AUTO_INPUT, padkeys, 0);
return keys;
}
static enum GUICursorState _pollCursor(unsigned* x, unsigned* y) {
hidScanInput();
if (hidTouchCount() < 1) {
return GUI_CURSOR_NOT_PRESENT;
}
touchPosition touch;
hidTouchRead(&touch, 0);
*x = touch.px;
*y = touch.py;
return GUI_CURSOR_DOWN;
}
static void _setup(struct mGUIRunner* runner) {
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_A, GBA_KEY_A);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_B, GBA_KEY_B);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_PLUS, GBA_KEY_START);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_MINUS, GBA_KEY_SELECT);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_DUP, GBA_KEY_UP);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_DDOWN, GBA_KEY_DOWN);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_DLEFT, GBA_KEY_LEFT);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_DRIGHT, GBA_KEY_RIGHT);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_L, GBA_KEY_L);
_mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_R, GBA_KEY_R);
runner->core->setVideoBuffer(runner->core, frameBuffer, 256);
runner->core->setAVStream(runner->core, &stream);
}
static void _gameLoaded(struct mGUIRunner* runner) {
u32 samplerate = audoutGetSampleRate();
double ratio = GBAAudioCalculateRatio(1, 60.0, 1);
blip_set_rates(runner->core->getAudioChannel(runner->core, 0), runner->core->frequency(runner->core), samplerate * ratio);
blip_set_rates(runner->core->getAudioChannel(runner->core, 1), runner->core->frequency(runner->core), samplerate * ratio);
}
static void _drawTex(struct mGUIRunner* runner, unsigned width, unsigned height, bool faded) {
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(program);
float aspectX = width / (float) runner->params.width;
float aspectY = height / (float) runner->params.height;
float max;
if (aspectX > aspectY) {
max = floor(1.0 / aspectX);
} else {
max = floor(1.0 / aspectY);
}
aspectX *= max;
aspectY *= max;
glUniform1i(texLocation, 0);
glUniform2f(dimsLocation, aspectX, aspectY);
glUniform2f(insizeLocation, width, height);
if (!faded) {
glUniform4f(colorLocation, 1.0f, 1.0f, 1.0f, 1.0f);
} else {
glUniform4f(colorLocation, 0.8f, 0.8f, 0.8f, 0.8f);
}
glVertexAttribPointer(offsetLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(offsetLocation);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(offsetLocation);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
}
static void _drawFrame(struct mGUIRunner* runner, bool faded) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer);
unsigned width, height;
runner->core->desiredVideoDimensions(runner->core, &width, &height);
_drawTex(runner, width, height, faded);
++framecount;
}
static void _drawScreenshot(struct mGUIRunner* runner, const color_t* pixels, unsigned width, unsigned height, bool faded) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
_drawTex(runner, width, height, faded);
}
static uint16_t _pollGameInput(struct mGUIRunner* runner) {
int keys = 0;
hidScanInput();
u32 padkeys = hidKeysHeld(CONTROLLER_P1_AUTO);
keys |= mInputMapKeyBits(&runner->core->inputMap, AUTO_INPUT, padkeys, 0);
return keys;
}
static void _setFrameLimiter(struct mGUIRunner* runner, bool limit) {
UNUSED(runner);
if (!frameLimiter && limit) {
while (enqueuedBuffers > 1) {
AudioOutBuffer* releasedBuffers;
u32 audoutNReleasedBuffers;
audoutWaitPlayFinish(&releasedBuffers, &audoutNReleasedBuffers, 100000000);
enqueuedBuffers -= audoutNReleasedBuffers;
}
}
frameLimiter = limit;
}
static bool _running(struct mGUIRunner* runner) {
UNUSED(runner);
return appletMainLoop();
}
static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right) {
UNUSED(stream);
AudioOutBuffer* releasedBuffers;
u32 audoutNReleasedBuffers;
audoutGetReleasedAudioOutBuffer(&releasedBuffers, &audoutNReleasedBuffers);
enqueuedBuffers -= audoutNReleasedBuffers;
if (!frameLimiter && enqueuedBuffers >= N_BUFFERS) {
blip_clear(left);
blip_clear(right);
return;
}
if (enqueuedBuffers >= N_BUFFERS - 1 && R_SUCCEEDED(audoutWaitPlayFinish(&releasedBuffers, &audoutNReleasedBuffers, 10000000))) {
enqueuedBuffers -= audoutNReleasedBuffers;
}
struct GBAStereoSample* samples = audioBuffer[audioBufferActive];
blip_read_samples(left, &samples[0].left, SAMPLES, true);
blip_read_samples(right, &samples[0].right, SAMPLES, true);
audoutAppendAudioOutBuffer(&audoutBuffer[audioBufferActive]);
audioBufferActive += 1;
audioBufferActive %= N_BUFFERS;
++enqueuedBuffers;
}
static int _batteryState(void) {
u32 charge;
int state = 0;
if (R_SUCCEEDED(psmGetBatteryChargePercentage(&charge))) {
state = charge / 25;
}
return state;
}
int main(int argc, char* argv[]) {
socketInitializeDefault();
nxlinkStdio();
initEgl();
romfsInit();
audoutInitialize();
psmInitialize();
struct GUIFont* font = GUIFontCreate();
u32 width = 1280;
u32 height = 720;
glViewport(0, 0, width, height);
glClearColor(0.f, 0.f, 0.f, 1.f);
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
program = glCreateProgram();
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
const GLchar* shaderBuffer[2];
shaderBuffer[0] = _gles2Header;
shaderBuffer[1] = _vertexShader;
glShaderSource(vertexShader, 2, shaderBuffer, NULL);
shaderBuffer[1] = _fragmentShader;
glShaderSource(fragmentShader, 2, shaderBuffer, NULL);
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glCompileShader(fragmentShader);
GLint success;
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar msg[512];
glGetShaderInfoLog(fragmentShader, sizeof(msg), NULL, msg);
puts(msg);
}
glCompileShader(vertexShader);
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar msg[512];
glGetShaderInfoLog(vertexShader, sizeof(msg), NULL, msg);
puts(msg);
}
glLinkProgram(program);
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
texLocation = glGetUniformLocation(program, "tex");
colorLocation = glGetUniformLocation(program, "color");
dimsLocation = glGetUniformLocation(program, "dims");
insizeLocation = glGetUniformLocation(program, "insize");
offsetLocation = glGetAttribLocation(program, "offset");
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(_offsets), _offsets, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
stream.videoDimensionsChanged = NULL;
stream.postVideoFrame = NULL;
stream.postAudioFrame = NULL;
stream.postAudioBuffer = _postAudioBuffer;
memset(audioBuffer, 0, sizeof(audioBuffer));
audioBufferActive = 0;
enqueuedBuffers = 0;
size_t i;
for (i = 0; i < N_BUFFERS; ++i) {
audoutBuffer[i].next = NULL;
audoutBuffer[i].buffer = audioBuffer[i];
audoutBuffer[i].buffer_size = BUFFER_SIZE;
audoutBuffer[i].data_size = BUFFER_SIZE;
audoutBuffer[i].data_offset = 0;
}
struct mGUIRunner runner = {
.params = {
width, height,
font, "/",
_drawStart, _drawEnd,
_pollInput, _pollCursor,
_batteryState,
NULL, NULL,
},
.keySources = (struct GUIInputKeys[]) {
{
.name = "Controller Input",
.id = AUTO_INPUT,
.keyNames = (const char*[]) {
"A",
"B",
"X",
"Y",
"L Stick",
"R Stick",
"L",
"R",
"ZL",
"ZR",
"+",
"-",
"Left",
"Up",
"Right",
"Down",
"L Left",
"L Up",
"L Right",
"L Down",
"R Left",
"R Up",
"R Right",
"R Down",
"SL",
"SR"
},
.nKeys = 26
},
{ .id = 0 }
},
.nConfigExtra = 0,
.setup = _setup,
.teardown = NULL,
.gameLoaded = _gameLoaded,
.gameUnloaded = NULL,
.prepareForFrame = NULL,
.drawFrame = _drawFrame,
.drawScreenshot = _drawScreenshot,
.paused = NULL,
.unpaused = _gameLoaded,
.incrementScreenMode = NULL,
.setFrameLimiter = _setFrameLimiter,
.pollGameInput = _pollGameInput,
.running = _running
};
mGUIInit(&runner, "switch");
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_A, GUI_INPUT_SELECT);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_B, GUI_INPUT_BACK);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_X, GUI_INPUT_CANCEL);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_DUP, GUI_INPUT_UP);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_DDOWN, GUI_INPUT_DOWN);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_DLEFT, GUI_INPUT_LEFT);
_mapKey(&runner.params.keyMap, AUTO_INPUT, KEY_DRIGHT, GUI_INPUT_RIGHT);
audoutStartAudioOut();
mGUIRunloop(&runner);
psmExit();
audoutExit();
deinitEgl();
socketExit();
return 0;
}

View File

@ -0,0 +1,15 @@
/* Copyright (c) 2013-2018 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba-util/memory.h>
void* anonymousMemoryMap(size_t size) {
return malloc(size);
}
void mappedMemoryFree(void* memory, size_t size) {
UNUSED(size);
free(memory);
}

View File

@ -19,6 +19,9 @@
#ifdef _3DS
#include <3ds.h>
#endif
#ifdef __SWITCH__
#include <switch.h>
#endif
#include <errno.h>
#include <fcntl.h>
@ -49,6 +52,9 @@ struct PerfOpts {
extern bool allocateRomBuffer(void);
FS_Archive sdmcArchive;
#endif
#ifdef __SWITCH__
TimeType __nx_time_type = TimeType_LocalSystemClock;
#endif
static void _mPerfRunloop(struct mCore* context, int* frames, bool quiet);
static void _mPerfShutdown(int signal);
@ -71,6 +77,10 @@ int main(int argc, char** argv) {
if (!allocateRomBuffer()) {
return 1;
}
#elif defined(__SWITCH__)
UNUSED(_mPerfShutdown);
gfxInitDefault();
consoleInit(NULL);
#else
signal(SIGINT, _mPerfShutdown);
#endif
@ -128,6 +138,8 @@ int main(int argc, char** argv) {
#ifdef _3DS
gfxExit();
acExit();
#elif defined(__SWITCH__)
gfxExit();
#endif
return didFail;
@ -254,7 +266,10 @@ static bool _mPerfRunServer(const char* listen, const struct mArguments* args, c
SocketSend(_socket, header, strlen(header));
}
char path[PATH_MAX];
while (SocketRecv(_socket, path, sizeof(path)) > 0) {
memset(path, 0, sizeof(path));
ssize_t i;
while ((i = SocketRecv(_socket, path, sizeof(path) - 1)) > 0) {
path[i] = '\0';
char* nl = strchr(path, '\n');
if (nl == path) {
break;
@ -265,6 +280,7 @@ static bool _mPerfRunServer(const char* listen, const struct mArguments* args, c
if (!_mPerfRunCore(path, args, perfOpts)) {
break;
}
memset(path, 0, sizeof(path));
}
SocketClose(_socket);
SocketClose(server);

View File

@ -39,7 +39,7 @@ set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
set(CMAKE_FIND_ROOT_PATH ${DEVKITPPC}/powerpc-eabi)
set(CMAKE_FIND_ROOT_PATH ${DEVKITPPC}/powerpc-eabi ${DEVKITPRO}/portlibs/ppc)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")

View File

@ -1,4 +1,4 @@
Libpng 1.6.17 - March 26, 2015
Libpng 1.6.34 - September 29, 2017
This is a public release of libpng, intended for use in production codes.
@ -7,61 +7,24 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.6.17.tar.xz (LZMA-compressed, recommended)
libpng-1.6.17.tar.gz
libpng-1.6.34.tar.xz (LZMA-compressed, recommended)
libpng-1.6.34.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1617.7z (LZMA-compressed, recommended)
lpng1617.zip
lpng1634.7z (LZMA-compressed, recommended)
lpng1634.zip
Other information:
libpng-1.6.17-README.txt
libpng-1.6.17-LICENSE.txt
libpng-1.6.17-*.asc (armored detached GPG signatures)
libpng-1.6.34-README.txt
libpng-1.6.34-LICENSE.txt
libpng-1.6.34-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.16):
Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
Corrected the width limit calculation in png_check_IHDR().
Removed user limits from pngfix. Also pass NULL pointers to
png_read_row to skip the unnecessary row de-interlace stuff.
Added testing of png_set_packing() to pngvalid.c
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
Implement previously untested cases of libpng transforms in pngvalid.c
Fixed byte order in 2-byte filler, in png_do_read_filler().
Made the check for out-of-range values in png_set_tRNS() detect
values that are exactly 2^bit_depth, and work on 16-bit platforms.
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
Do not build png_product2() when it is unused.
Display user limits in the output from pngtest.
Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
and 1-million-row default limits in pnglibconf.dfa, that can be reset
by the user at build time or run time. This provides a more robust
defense against DOS and as-yet undiscovered overflows.
Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
of png.h.
Avoid runtime checks when converting integer to png_byte with
Visual Studio (Sergey Kosarevsky)
Removed some comments that the configure script did not handle
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
Free the unknown_chunks structure even when it contains no data.
Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
for consistency, and remove some useless tests (Alexey Petruchik).
Remove pnglibconf.h, pnglibconf.c, pnglibconf.pre, pnglibconf.dfn,
and pnglibconf.out instead of pnglibconf.* in "make clean" (Cosmin).
Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha
value was wrong. It's not clear if this affected the final stored
value; in the obvious code path the upper and lower 8-bits of the
alpha value were identical and the alpha was truncated to 8-bits
rather than dividing by 257 (John Bowler).
Changes since the last public release (1.6.33):
Removed contrib/pngsuite/i*.png; some of these were incorrect and caused
test failures.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,57 @@
# CMakeLists.txt
# Copyright (C) 2007-2015 Glenn Randers-Pehrson
# Copyright (C) 2007,2009-2017 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012
# Revised by Roger Leigh, 2016
# Revised by Andreas Franek, 2016
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
cmake_minimum_required(VERSION 3.0.2)
cmake_policy(VERSION 3.0.2)
# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
# Use new variable expansion policy.
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
project(libpng C)
project(libpng ASM C)
enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 17)
set(PNGLIB_RELEASE 34)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
include(GNUInstallDirs)
# needed packages
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
#Allow users to specify location of Zlib,
# Useful if zlib is being built alongside this as a sub-project
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
IF(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
ENDIF(NOT PNG_BUILD_ZLIB)
if(NOT WIN32)
find_library(M_LIBRARY
@ -47,32 +76,391 @@ option(PNG_FRAMEWORK "Build OS X framework" OFF)
option(PNG_DEBUG "Build with debug output" OFF)
option(PNGARG "Disable ANSI-C prototypes" OFF)
option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
if(PNG_HARDWARE_OPTIMIZATIONS)
# set definitions and sources for arm
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code;
off: disable the optimizations;
on: turn on unconditionally.")
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
${PNG_ARM_NEON_POSSIBLE_VALUES})
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
set(libpng_arm_sources
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c)
if(${PNG_ARM_NEON} STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(${PNG_ARM_NEON} STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
endif()
# set definitions and sources for powerpc
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
off: disable the optimizations.")
set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS
${PNG_POWERPC_VSX_POSSIBLE_VALUES})
list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off")
set(libpng_powerpc_sources
powerpc/powerpc_init.c
powerpc/filter_vsx_intrinsics.c)
if(${PNG_POWERPC_VSX} STREQUAL "on")
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
endif()
else()
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
endif()
# set definitions and sources for intel
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
off: disable the optimizations")
set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS
${PNG_INTEL_SSE_POSSIBLE_VALUES})
list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off")
set(libpng_intel_sources
intel/intel_init.c
intel/filter_sse2_intrinsics.c)
if(${PNG_INTEL_SSE} STREQUAL "on")
add_definitions(-DPNG_INTEL_SSE_OPT=1)
endif()
else()
add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
endif()
# set definitions and sources for MIPS
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
off: disable the optimizations")
set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS
${PNG_MIPS_MSA_POSSIBLE_VALUES})
list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
set(libpng_mips_sources
mips/mips_init.c
mips/filter_msa_intrinsics.c)
if(${PNG_MIPS_MSA} STREQUAL "on")
add_definitions(-DPNG_MIPS_MSA_OPT=2)
endif()
else()
add_definitions(-DPNG_MIPS_MSA_OPT=0)
endif()
endif()
endif(PNG_HARDWARE_OPTIMIZATIONS)
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
# Use the prebuilt pnglibconf.h file from the scripts folder
# TODO: fix this by building with awk; without this no cmake build can be
# configured directly (to do so indirectly use your local awk to build a
# pnglibconf.h in the build directory.)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
if(ld-version-script AND NOT APPLE)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
local: *;
};
VERS_2 {
global: sym2;
main;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
endif()
# Find symbol prefix. Likely obsolete and unnecessary with recent
# toolchains (it's not done in many other projects).
function(symbol_prefix)
set(SYMBOL_PREFIX)
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
INPUT_FILE /dev/null
OUTPUT_VARIABLE OUT
RESULT_VARIABLE STATUS)
if(CPP_FAIL)
message(WARNING "Failed to run the C preprocessor")
endif()
string(REPLACE "\n" ";" OUT "${OUT}")
foreach(line ${OUT})
string(REGEX MATCH "^PREFIX=" found_match "${line}")
if(found_match)
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
if(found_match)
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
endif()
set(SYMBOL_PREFIX "${prefix}")
endif()
endforeach()
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
endfunction()
if(UNIX)
symbol_prefix()
endif()
find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT AWK OR ANDROID)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
add_custom_target(genfiles) # Dummy
else()
include(CMakeParseArguments)
# Generate .chk from .out with awk
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_chk)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GC_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GC_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate .out from .c with awk
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_out)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GO_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate specific source file with awk
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_source)
set(options)
set(oneValueArgs OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GSO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
endif()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Copy file
function(generate_copy source destination)
add_custom_command(OUTPUT "${destination}"
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
"${destination}"
DEPENDS "${source}")
endfunction()
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
# Generate pnglibconf.c
generate_source(OUTPUT "pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
set(PNGPREFIX_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
endif()
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
generate_source(OUTPUT "pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
${PNGLIBCONF_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
generate_source(OUTPUT "pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
add_custom_target(symbol-check DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
add_custom_target("genprebuilt"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# A single target handles generation of all generated files. If
# they are dependend upon separately by multiple targets, this
# confuses parallel make (it would require a separate top-level
# target for each file to track the dependencies properly).
add_custom_target(genfiles DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
endif(NOT AWK OR ANDROID)
# OUR SOURCES
set(libpng_public_hdrs
png.h
pngconf.h
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
)
set(libpng_sources
${libpng_public_hdrs}
set(libpng_private_hdrs
pngpriv.h
pngdebug.h
pnginfo.h
pngpriv.h
pngstruct.h
)
if(AWK AND NOT ANDROID)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
${libpng_public_hdrs}
${libpng_private_hdrs}
png.c
pngerror.c
pngget.c
@ -88,6 +476,10 @@ set(libpng_sources
pngwrite.c
pngwtran.c
pngwutil.c
${libpng_arm_sources}
${libpng_intel_sources}
${libpng_mips_sources}
${libpng_powerpc_sources}
)
set(pngtest_sources
pngtest.c
@ -98,7 +490,18 @@ set(pngvalid_sources
set(pngstest_sources
contrib/libtests/pngstest.c
)
# SOME NEEDED DEFINITIONS
set(pngunknown_sources
contrib/libtests/pngunknown.c
)
set(pngimage_sources
contrib/libtests/pngimage.c
)
set(pngfix_sources
contrib/tools/pngfix.c
)
set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
@ -114,33 +517,59 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
unset(PNG_LIB_TARGETS)
if(PNG_SHARED)
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
add_library(png SHARED ${libpng_sources})
set(PNG_LIB_TARGETS png)
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
add_dependencies(png genfiles)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
set_target_properties(png PROPERTIES PREFIX "lib")
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
if(UNIX AND AWK)
if(HAVE_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
endif()
endif()
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_STATIC)
# does not work without changing name
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
add_dependencies(png_static genfiles)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}"
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}_static"
CLEAN_DIRECT_OUTPUT 1)
endif()
list(APPEND PNG_LIB_TARGETS png_static)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
set_target_properties(png_static PROPERTIES PREFIX "lib")
endif()
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_FRAMEWORK)
set(PNG_LIB_NAME_FRAMEWORK ${PNG_LIB_NAME}_framework)
add_library(${PNG_LIB_NAME_FRAMEWORK} SHARED ${libpng_sources})
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_FRAMEWORK})
set_target_properties(${PNG_LIB_NAME_FRAMEWORK} PROPERTIES
set(PNG_LIB_NAME_FRAMEWORK png_framework)
add_library(png_framework SHARED ${libpng_sources})
add_dependencies(png_framework genfiles)
list(APPEND PNG_LIB_TARGETS png_framework)
set_target_properties(png_framework PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${PNGLIB_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
@ -149,7 +578,7 @@ if(PNG_FRAMEWORK)
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER "${libpng_public_hdrs}"
OUTPUT_NAME png)
target_link_libraries(${PNG_LIB_NAME_FRAMEWORK} ${ZLIB_LIBRARY} ${M_LIBRARY})
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(NOT PNG_LIB_TARGETS)
@ -160,79 +589,233 @@ if(NOT PNG_LIB_TARGETS)
endif()
if(PNG_SHARED AND WIN32)
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
endif()
function(png_add_test)
set(options)
set(oneValueArgs NAME COMMAND)
set(multiValueArgs OPTIONS FILES)
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _PAT_NAME)
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
endif()
if (NOT _PAT_COMMAND)
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
endif()
set(TEST_OPTIONS "${_PAT_OPTIONS}")
set(TEST_FILES "${_PAT_FILES}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
add_test(NAME "${_PAT_NAME}"
COMMAND "${CMAKE_COMMAND}"
"-DLIBPNG=$<TARGET_FILE:png>"
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
else() # old 2.x add_test; limited and won't work well on Windows
# Note LIBPNG is a dummy value as there are no generator expressions
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
"-DTEST_COMMAND=./${_PAT_COMMAND}"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
endif()
endfunction()
if(PNG_TESTS AND PNG_SHARED)
# does not work with msvc due to png_lib_ver issue
# Find test PNG files by globbing, but sort lists to ensure
# consistency between different filesystems.
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
list(SORT PNGSUITE_PNGS)
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
list(SORT TEST_PNGS)
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
add_executable(pngtest ${pngtest_sources})
target_link_libraries(pngtest ${PNG_LIB_NAME})
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
#
target_link_libraries(pngtest png)
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
add_executable(pngvalid ${pngvalid_sources})
target_link_libraries(pngvalid ${PNG_LIB_NAME})
add_test(pngvalid ./pngvalid)
target_link_libraries(pngvalid png)
png_add_test(NAME pngvalid-gamma-16-to-8
COMMAND pngvalid OPTIONS --gamma-16-to-8)
png_add_test(NAME pngvalid-gamma-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
png_add_test(NAME pngvalid-gamma-background
COMMAND pngvalid OPTIONS --gamma-background)
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
png_add_test(NAME pngvalid-gamma-expand16-background
COMMAND pngvalid OPTIONS --gamma-background --expand16)
png_add_test(NAME pngvalid-gamma-expand16-transform
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
png_add_test(NAME pngvalid-gamma-sbit
COMMAND pngvalid OPTIONS --gamma-sbit)
png_add_test(NAME pngvalid-gamma-threshold
COMMAND pngvalid OPTIONS --gamma-threshold)
png_add_test(NAME pngvalid-gamma-transform
COMMAND pngvalid OPTIONS --gamma-transform)
png_add_test(NAME pngvalid-progressive-interlace-standard
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
png_add_test(NAME pngvalid-progressive-size
COMMAND pngvalid OPTIONS --size --progressive-read)
png_add_test(NAME pngvalid-progressive-standard
COMMAND pngvalid OPTIONS --standard --progressive-read)
png_add_test(NAME pngvalid-standard
COMMAND pngvalid OPTIONS --standard)
png_add_test(NAME pngvalid-transform
COMMAND pngvalid OPTIONS --transform)
add_executable(pngstest ${pngstest_sources})
target_link_libraries(pngstest ${PNG_LIB_NAME})
add_test(pngstest ./pngstest
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
)
target_link_libraries(pngstest png)
foreach(gamma_type 1.8 linear none sRGB)
foreach(alpha_type none alpha)
set(PNGSTEST_FILES)
foreach(test_png ${TEST_PNGS})
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
set(TEST_PNG_VALID TRUE)
if(TEST_PNG_ALPHA)
if (NOT "${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
else()
if ("${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_LINEAR)
if(NOT "${gamma_type}" STREQUAL "linear")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_SRGB)
if(NOT "${gamma_type}" STREQUAL "sRGB")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_G18)
if(NOT "${gamma_type}" STREQUAL "1.8")
set(TEST_PNG_VALID FALSE)
endif()
else()
if(NOT "${gamma_type}" STREQUAL "none")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_VALID)
list(APPEND PNGSTEST_FILES "${test_png}")
endif()
endforeach()
# Should already be sorted, but sort anyway to be certain.
list(SORT PNGSTEST_FILES)
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
COMMAND pngstest
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
FILES ${PNGSTEST_FILES})
endforeach()
endforeach()
add_executable(pngunknown ${pngunknown_sources})
target_link_libraries(pngunknown png)
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
add_executable(pngimage ${pngimage_sources})
target_link_libraries(pngimage png)
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
endif()
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
if(PNG_SHARED)
add_executable(pngfix ${pngfix_sources})
target_link_libraries(pngfix png)
set(PNG_BIN_TARGETS pngfix)
add_executable(png-fix-itxt ${png_fix_itxt_sources})
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
# Set a variable with CMake code which:
# Creates a symlink from src to dest (if possible) or alternatively
# copies if different.
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
DEPENDS ${PNG_LIB_TARGETS}
)
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
endmacro()
include(CMakeParseArguments)
function(CREATE_SYMLINK DEST_FILE)
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
if(NOT S_TARGET AND NOT S_FILE)
message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.")
endif(NOT S_TARGET AND NOT S_FILE)
if(S_TARGET AND S_FILE)
message(FATAL_ERROR "CREATE_SYMLINK called with both source file ${S_FILE} and build target ${S_TARGET} arguments - can only handle 1 type per call.")
endif(S_TARGET AND S_FILE)
if(S_FILE)
# If we don't need to symlink something that's coming from a build target,
# we can go ahead and symlink/copy at configure time.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
endif(S_FILE)
if(S_TARGET)
# We need to use generator expressions, which can be a bit tricky, so for
# simplicity make the symlink a POST_BUILD step and use the TARGET
# signature of add_custom_command.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
)
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
)
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
endif(S_TARGET)
endfunction()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
# libpng is a library so default to 'lib'
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
@ -251,31 +834,21 @@ if(NOT WIN32 OR CYGWIN OR MINGW)
set(LIBS "-lz -lm")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config)
endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.17
set_target_properties(png PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.34
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)
endif()
if(PNG_STATIC)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
OUTPUT_NAME ${PNG_LIB_NAME}
CLEAN_DIRECT_OUTPUT 1)
endif()
endif()
# If CMake > 2.4.x, we set a variable used below to export
# targets to an export file.
@ -298,26 +871,20 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(CYGWIN OR MINGW)
if(NOT WIN32)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32)
endif(PNG_SHARED)
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif()
endif()
@ -334,6 +901,11 @@ if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
install(TARGETS ${PNG_BIN_TARGETS}
RUNTIME DESTINATION bin)
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
# Install man pages
if(NOT PNG_MAN_DIR)
@ -342,7 +914,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
# Install pkg-config files
if(NOT WIN32 OR CYGWIN OR MINGW)
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
@ -351,7 +923,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
DESTINATION bin)
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
endif()
# On versions of CMake that support it, create an export file CMake
@ -371,4 +943,3 @@ endif()
# to create msvc import lib for mingw compiled shared lib
# pexports libpng.dll > libpng.def
# lib /def:libpng.def /machine:x86

View File

@ -1,24 +1,26 @@
Installing libpng
Installing libpng
Contents
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Setjmp/longjmp issues
XVI. Other sources of information about libpng
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Enabling or disabling hardware optimizations
XV. Changes to the build and configuration of libpng in libpng-1.5.x
XVI. Setjmp/longjmp issues
XVII. Common linking failures
XVIII. Other sources of information about libpng
I. Simple installation
@ -47,7 +49,9 @@ If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
up-to-date set of tools, running ./autogen.sh in a git clone before
running ./configure may fix the problem. To be really sure that you
aren't using any of the included pre-built scripts, you can do this:
aren't using any of the included pre-built scripts, especially if you
are building from a tar distribution instead of a git distribution,
do this:
./configure --enable-maintainer-mode
make maintainer-clean
@ -75,8 +79,8 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng; otherwise go to http://zlib.net. You can place
zlib in in the same directory as libpng or in another directory.
wherever you got libpng; otherwise go to https://zlib.net/. You can
place zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
@ -87,22 +91,24 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
and LD_LIBRARY_PATH in your environment before running "make test"
or "make distcheck":
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
in your environment and type
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
IV. Using cmake
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
As when using the simple configure method described above, "/path" points to
the installation directory where you want to put the libpng "lib", "include",
@ -116,8 +122,8 @@ or "zlib128") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
.. (the parent directory)
libpng (this directory)
.. (the parent directory)
libpng (this directory)
INSTALL (this file)
README
*.h, *.c => libpng source files
@ -160,10 +166,15 @@ VII. Building with makefiles
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example: cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example:
cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
target directories to match your preferences.
@ -239,7 +250,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
PNG_NO_.
"PNG_NO_".
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
@ -271,7 +282,57 @@ library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections that are actually used will be loaded into memory.
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XIV. Enabling or disabling hardware optimizations
Certain hardware capabilites, such as the Intel SSE instructions,
are normally detected at run time. Enable them with configure options
such as one of
--enable-arm-neon=yes
--enable-mips-msa=yes
--enable-intel-sse=yes
--enable-powerpc-vsx=yes
or enable them all at once with
--enable-hardware-optimizations=yes
or, if you are not using "configure", you can use one
or more of
CPPFLAGS += "-DPNG_ARM_NEON"
CPPFLAGS += "-DPNG_MIPS_MSA"
CPPFLAGS += "-DPNG_INTEL_SSE"
CPPFLAGS += "-DPNG_POWERPC_VSX"
See for example scripts/makefile.linux-opt
If you wish to avoid using them,
you can disable them via the configure option
--disable-hardware-optimizations
to disable them all, or
--enable-intel-sse=no
to disable a particular one,
or via compiler-command options such as
CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,
-DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"
If you are using cmake, hardware optimizations are "on"
by default. To disable them, use
cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \
-DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no
or disable them all at once with
cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
XV. Changes to the build and configuration of libpng in libpng-1.5.x
Details of internal changes to the library code can be found in the CHANGES
file and in the GIT repository logs. These will be of no concern to the vast
@ -307,7 +368,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new
approach is documented in pngconf.h
Despite these changes, libpng 1.5.0 only supports the native C function
calling standard on those platforms tested so far (__cdecl on Microsoft
calling standard on those platforms tested so far ("__cdecl" on Microsoft
Windows). This is because the support requirements for alternative
calling conventions seem to no longer exist. Developers who find it
necessary to set PNG_API_RULE to 1 should advise the mailing list
@ -362,7 +423,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built
libpng, because than the settings would not accurately reflect the settings
that were used to build libpng.
XV. Setjmp/longjmp issues
XVI. Setjmp/longjmp issues
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
is known to be not thread-safe on some platforms and we don't know of
@ -371,7 +432,7 @@ your application is going to be using multiple threads, you should
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
-DPNG_NO_SETJMP on your compile line, or with
#undef PNG_SETJMP_SUPPORTED
#undef PNG_SETJMP_SUPPORTED
in your pnglibconf.h or pngusr.h.
@ -380,28 +441,25 @@ This requires setjmp/longjmp, so you must either build the library
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
XVI. Other sources of information about libpng:
XVII. Common linking failures
If your application fails to find libpng or zlib entries while linking:
Be sure "-lz" appears after "-lpng" on your linking command.
Be sure you have built libpng, zlib, and your application for the
same platform (e.g., 32-bit or 64-bit).
If you are using the vstudio project, observe the WARNING in
project/vstudio/README.txt.
XVIII. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Using the ./configure script -- 16 December 2002.
=================================================
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you might need to add to configure
explicitly, which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/libpng16, or whatever.
If you find that the configure script is out-of-date or is not supporting
your platform properly, try running autogen.sh to regenerate "configure",
"Makefile.in", and the other configuration files. Then try configure again.
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h.

View File

@ -10,21 +10,21 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.17, March 26, 2015, are
Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
Simon-Pierre Cadieux
Eric S. Raymond
Mans Rullgard
Cosmin Truta
Gilles Vollant
James Yu
Mandar Sahastrabuddhe
Google Inc.
Vadim Barkov
and with the following additions to the disclaimer:
@ -35,19 +35,25 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
license as libpng-0.96, with the following individuals added to the list
of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
and are distributed according to the same disclaimer and license as
libpng-0.88, with the following individuals added to the list of
Contributing Authors:
John Bowler
Kevin Bracey
@ -56,8 +62,11 @@ with the following individuals added to the list of Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
@ -80,13 +89,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
@ -94,18 +103,31 @@ supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
TRADEMARK:
printf("%s",png_get_copyright(NULL));
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
March 26, 2015
September 29, 2017

View File

@ -1,13 +1,21 @@
# Makefile.am:
# Source file for Makefile.in (and hence Makefile)
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
#
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.6.25 [September 1, 2016]
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
ACLOCAL_AMFLAGS = -I scripts
# test programs - run on make check, make distcheck
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
if HAVE_CLOCK_GETTIME
check_PROGRAMS += timepng
endif
# Utilities - installed
bin_PROGRAMS= pngfix png-fix-itxt
@ -37,37 +45,38 @@ pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngimage_SOURCES = contrib/libtests/pngimage.c
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
timepng_SOURCES = contrib/libtests/timepng.c
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngfix_SOURCES = contrib/tools/pngfix.c
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
pngcp_SOURCES = contrib/tools/pngcp.c
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
# Generally these are single line shell scripts to run a test with a particular
# set of parameters:
TESTS =\
tests/pngtest\
tests/pngtest-badpngs\
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
tests/pngvalid-gamma-expand16-background\
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
tests/pngvalid-progressive-interlace-size\
tests/pngvalid-progressive-size\
tests/pngvalid-progressive-interlace-standard\
tests/pngvalid-progressive-interlace-transform\
tests/pngvalid-transform\
tests/pngvalid-progressive-standard tests/pngvalid-standard\
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
tests/pngstest-error tests/pngunknown-IDAT\
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
tests/pngimage-quick tests/pngimage-full
# These tests are expected, and required, to fail:
XFAIL_TESTS = tests/pngstest-error
# man pages
dist_man_MANS= libpng.3 libpngpf.3 png.5
@ -89,6 +98,21 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
arm/filter_neon.S arm/filter_neon_intrinsics.c
endif
if PNG_MIPS_MSA
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\
mips/filter_msa_intrinsics.c
endif
if PNG_INTEL_SSE
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
intel/filter_sse2_intrinsics.c
endif
if PNG_POWERPC_VSX
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
powerpc/filter_vsx_intrinsics.c
endif
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
@ -225,6 +249,7 @@ contrib/libtests/timepng.o: pnglibconf.h
contrib/tools/makesRGB.o: pnglibconf.h
contrib/tools/pngfix.o: pnglibconf.h
contrib/tools/pngcp.o: pnglibconf.h
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
# be built with PNG_USE_READ_MACROS; this prevents the read macros from

View File

@ -14,9 +14,14 @@
@SET_MAKE@
# Makefile.am:
# Source file for Makefile.in (and hence Makefile)
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
#
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.6.25 [September 1, 2016]
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
@ -96,18 +101,29 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = pngtest$(EXEEXT) pngunknown$(EXEEXT) \
pngstest$(EXEEXT) pngvalid$(EXEEXT) pngimage$(EXEEXT)
pngstest$(EXEEXT) pngvalid$(EXEEXT) pngimage$(EXEEXT) \
pngcp$(EXEEXT) $(am__EXEEXT_1)
@HAVE_CLOCK_GETTIME_TRUE@am__append_1 = timepng
bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT)
@PNG_ARM_NEON_TRUE@am__append_1 = arm/arm_init.c\
@PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\
@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c
@PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\
@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.c
@PNG_INTEL_SSE_TRUE@am__append_4 = intel/intel_init.c\
@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.c
@PNG_POWERPC_VSX_TRUE@am__append_5 = powerpc/powerpc_init.c\
@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.c
# Versioned symbols and restricted exports
@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@am__append_2 = -Wl,-M -Wl,libpng.vers
@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@am__append_3 = -Wl,--version-script=libpng.vers
@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@am__append_6 = -Wl,-M -Wl,libpng.vers
@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@am__append_7 = -Wl,--version-script=libpng.vers
# Only restricted exports when possible
@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_4 = -export-symbols libpng.sym
@DO_PNG_PREFIX_TRUE@am__append_5 = -DPNG_PREFIX='@PNG_PREFIX@'
@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_8 = -export-symbols libpng.sym
@DO_PNG_PREFIX_TRUE@am__append_9 = -DPNG_PREFIX='@PNG_PREFIX@'
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/scripts/libtool.m4 \
@ -164,14 +180,24 @@ am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \
pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c \
pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \
pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \
arm/filter_neon.S arm/filter_neon_intrinsics.c
arm/filter_neon.S arm/filter_neon_intrinsics.c \
mips/mips_init.c mips/filter_msa_intrinsics.c \
intel/intel_init.c intel/filter_sse2_intrinsics.c \
powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c
am__dirstamp = $(am__leading_dot)dirstamp
@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \
@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo
@PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \
@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.lo
@PNG_INTEL_SSE_TRUE@am__objects_3 = intel/intel_init.lo \
@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.lo
@PNG_POWERPC_VSX_TRUE@am__objects_4 = powerpc/powerpc_init.lo \
@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.lo
am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = png.lo pngerror.lo \
pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo \
pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo \
pngwrite.lo pngwtran.lo pngwutil.lo $(am__objects_1)
pngwrite.lo pngwtran.lo pngwutil.lo $(am__objects_1) \
$(am__objects_2) $(am__objects_3) $(am__objects_4)
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS =
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = \
$(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) \
@ -185,10 +211,14 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK = $(LIBTOOL) $(AM_V_lt) \
$(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS) $(LDFLAGS) -o \
$@
@HAVE_CLOCK_GETTIME_TRUE@am__EXEEXT_1 = timepng$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS)
am_png_fix_itxt_OBJECTS = contrib/tools/png-fix-itxt.$(OBJEXT)
png_fix_itxt_OBJECTS = $(am_png_fix_itxt_OBJECTS)
png_fix_itxt_LDADD = $(LDADD)
am_pngcp_OBJECTS = contrib/tools/pngcp.$(OBJEXT)
pngcp_OBJECTS = $(am_pngcp_OBJECTS)
pngcp_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
am_pngfix_OBJECTS = contrib/tools/pngfix.$(OBJEXT)
pngfix_OBJECTS = $(am_pngfix_OBJECTS)
pngfix_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
@ -207,6 +237,9 @@ pngunknown_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
am_pngvalid_OBJECTS = contrib/libtests/pngvalid.$(OBJEXT)
pngvalid_OBJECTS = $(am_pngvalid_OBJECTS)
pngvalid_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
am_timepng_OBJECTS = contrib/libtests/timepng.$(OBJEXT)
timepng_OBJECTS = $(am_timepng_OBJECTS)
timepng_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
SCRIPTS = $(bin_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -254,14 +287,14 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \
$(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \
$(png_fix_itxt_SOURCES) $(pngfix_SOURCES) $(pngimage_SOURCES) \
$(pngstest_SOURCES) $(pngtest_SOURCES) $(pngunknown_SOURCES) \
$(pngvalid_SOURCES)
$(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \
$(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \
$(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES)
DIST_SOURCES = \
$(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST) \
$(png_fix_itxt_SOURCES) $(pngfix_SOURCES) $(pngimage_SOURCES) \
$(pngstest_SOURCES) $(pngtest_SOURCES) $(pngunknown_SOURCES) \
$(pngvalid_SOURCES)
$(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \
$(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \
$(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -664,37 +697,36 @@ pngunknown_SOURCES = contrib/libtests/pngunknown.c
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngimage_SOURCES = contrib/libtests/pngimage.c
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
timepng_SOURCES = contrib/libtests/timepng.c
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngfix_SOURCES = contrib/tools/pngfix.c
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
pngcp_SOURCES = contrib/tools/pngcp.c
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
# Generally these are single line shell scripts to run a test with a particular
# set of parameters:
TESTS = \
tests/pngtest\
tests/pngtest-badpngs\
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
tests/pngvalid-gamma-expand16-background\
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
tests/pngvalid-progressive-interlace-size\
tests/pngvalid-progressive-size\
tests/pngvalid-progressive-interlace-standard\
tests/pngvalid-progressive-interlace-transform\
tests/pngvalid-transform\
tests/pngvalid-progressive-standard tests/pngvalid-standard\
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
tests/pngstest-error tests/pngunknown-IDAT\
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
tests/pngimage-quick tests/pngimage-full
# These tests are expected, and required, to fail:
XFAIL_TESTS = tests/pngstest-error
# man pages
dist_man_MANS = libpng.3 libpngpf.3 png.5
EXTRA_SCRIPTS = libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
@ -707,12 +739,13 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c \
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c \
pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c \
pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h \
pngstruct.h pngusr.dfa $(am__append_1)
pngstruct.h pngusr.dfa $(am__append_2) $(am__append_3) \
$(am__append_4) $(am__append_5)
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined \
-export-dynamic -version-number \
@PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 \
$(am__append_2) $(am__append_3) $(am__append_4)
$(am__append_6) $(am__append_7) $(am__append_8)
@HAVE_LD_VERSION_SCRIPT_FALSE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
@HAVE_LD_VERSION_SCRIPT_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
pkginclude_HEADERS = png.h pngconf.h
@ -748,7 +781,7 @@ SUFFIXES = .chk .out
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0' \
-DPNGLIB_VERSION='@PNGLIB_VERSION@' \
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' -DPNG_NO_USE_READ_MACROS \
-DPNG_BUILDING_SYMBOL_TABLE $(am__append_5)
-DPNG_BUILDING_SYMBOL_TABLE $(am__append_9)
# EXT_LIST is a list of the possibly library directory extensions, this exists
# because we can't find a good way of discovering the file extensions that are
@ -857,6 +890,35 @@ arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp)
arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp)
arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \
arm/$(DEPDIR)/$(am__dirstamp)
mips/$(am__dirstamp):
@$(MKDIR_P) mips
@: > mips/$(am__dirstamp)
mips/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) mips/$(DEPDIR)
@: > mips/$(DEPDIR)/$(am__dirstamp)
mips/mips_init.lo: mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp)
mips/filter_msa_intrinsics.lo: mips/$(am__dirstamp) \
mips/$(DEPDIR)/$(am__dirstamp)
intel/$(am__dirstamp):
@$(MKDIR_P) intel
@: > intel/$(am__dirstamp)
intel/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) intel/$(DEPDIR)
@: > intel/$(DEPDIR)/$(am__dirstamp)
intel/intel_init.lo: intel/$(am__dirstamp) \
intel/$(DEPDIR)/$(am__dirstamp)
intel/filter_sse2_intrinsics.lo: intel/$(am__dirstamp) \
intel/$(DEPDIR)/$(am__dirstamp)
powerpc/$(am__dirstamp):
@$(MKDIR_P) powerpc
@: > powerpc/$(am__dirstamp)
powerpc/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) powerpc/$(DEPDIR)
@: > powerpc/$(DEPDIR)/$(am__dirstamp)
powerpc/powerpc_init.lo: powerpc/$(am__dirstamp) \
powerpc/$(DEPDIR)/$(am__dirstamp)
powerpc/filter_vsx_intrinsics.lo: powerpc/$(am__dirstamp) \
powerpc/$(DEPDIR)/$(am__dirstamp)
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES) $(EXTRA_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES)
$(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK) -rpath $(libdir) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD) $(LIBS)
@ -930,6 +992,12 @@ contrib/tools/png-fix-itxt.$(OBJEXT): contrib/tools/$(am__dirstamp) \
png-fix-itxt$(EXEEXT): $(png_fix_itxt_OBJECTS) $(png_fix_itxt_DEPENDENCIES) $(EXTRA_png_fix_itxt_DEPENDENCIES)
@rm -f png-fix-itxt$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(png_fix_itxt_OBJECTS) $(png_fix_itxt_LDADD) $(LIBS)
contrib/tools/pngcp.$(OBJEXT): contrib/tools/$(am__dirstamp) \
contrib/tools/$(DEPDIR)/$(am__dirstamp)
pngcp$(EXEEXT): $(pngcp_OBJECTS) $(pngcp_DEPENDENCIES) $(EXTRA_pngcp_DEPENDENCIES)
@rm -f pngcp$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(pngcp_OBJECTS) $(pngcp_LDADD) $(LIBS)
contrib/tools/pngfix.$(OBJEXT): contrib/tools/$(am__dirstamp) \
contrib/tools/$(DEPDIR)/$(am__dirstamp)
@ -971,6 +1039,12 @@ contrib/libtests/pngvalid.$(OBJEXT): contrib/libtests/$(am__dirstamp) \
pngvalid$(EXEEXT): $(pngvalid_OBJECTS) $(pngvalid_DEPENDENCIES) $(EXTRA_pngvalid_DEPENDENCIES)
@rm -f pngvalid$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(pngvalid_OBJECTS) $(pngvalid_LDADD) $(LIBS)
contrib/libtests/timepng.$(OBJEXT): contrib/libtests/$(am__dirstamp) \
contrib/libtests/$(DEPDIR)/$(am__dirstamp)
timepng$(EXEEXT): $(timepng_OBJECTS) $(timepng_DEPENDENCIES) $(EXTRA_timepng_DEPENDENCIES)
@rm -f timepng$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(timepng_OBJECTS) $(timepng_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
@ -1013,6 +1087,12 @@ mostlyclean-compile:
-rm -f arm/*.lo
-rm -f contrib/libtests/*.$(OBJEXT)
-rm -f contrib/tools/*.$(OBJEXT)
-rm -f intel/*.$(OBJEXT)
-rm -f intel/*.lo
-rm -f mips/*.$(OBJEXT)
-rm -f mips/*.lo
-rm -f powerpc/*.$(OBJEXT)
-rm -f powerpc/*.lo
distclean-compile:
-rm -f *.tab.c
@ -1040,8 +1120,16 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngstest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngunknown.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngvalid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/timepng.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/png-fix-itxt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngcp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngfix.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/filter_sse2_intrinsics.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/intel_init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/filter_msa_intrinsics.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/mips_init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/powerpc_init.Plo@am__quote@
.S.o:
@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@ -1097,6 +1185,9 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
-rm -rf arm/.libs arm/_libs
-rm -rf intel/.libs intel/_libs
-rm -rf mips/.libs mips/_libs
-rm -rf powerpc/.libs powerpc/_libs
distclean-libtool:
-rm -f libtool config.lt
@ -1457,6 +1548,13 @@ tests/pngtest.log: tests/pngtest
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngtest-badpngs.log: tests/pngtest-badpngs
@p='tests/pngtest-badpngs'; \
b='tests/pngtest-badpngs'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngvalid-gamma-16-to-8.log: tests/pngvalid-gamma-16-to-8
@p='tests/pngvalid-gamma-16-to-8'; \
b='tests/pngvalid-gamma-16-to-8'; \
@ -1520,9 +1618,9 @@ tests/pngvalid-gamma-transform.log: tests/pngvalid-gamma-transform
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngvalid-progressive-interlace-size.log: tests/pngvalid-progressive-interlace-size
@p='tests/pngvalid-progressive-interlace-size'; \
b='tests/pngvalid-progressive-interlace-size'; \
tests/pngvalid-progressive-size.log: tests/pngvalid-progressive-size
@p='tests/pngvalid-progressive-size'; \
b='tests/pngvalid-progressive-size'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
@ -1534,9 +1632,9 @@ tests/pngvalid-progressive-interlace-standard.log: tests/pngvalid-progressive-in
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngvalid-progressive-interlace-transform.log: tests/pngvalid-progressive-interlace-transform
@p='tests/pngvalid-progressive-interlace-transform'; \
b='tests/pngvalid-progressive-interlace-transform'; \
tests/pngvalid-transform.log: tests/pngvalid-transform
@p='tests/pngvalid-transform'; \
b='tests/pngvalid-transform'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
@ -1555,114 +1653,58 @@ tests/pngvalid-standard.log: tests/pngvalid-standard
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-0g01.log: tests/pngstest-0g01
@p='tests/pngstest-0g01'; \
b='tests/pngstest-0g01'; \
tests/pngstest-1.8.log: tests/pngstest-1.8
@p='tests/pngstest-1.8'; \
b='tests/pngstest-1.8'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-0g02.log: tests/pngstest-0g02
@p='tests/pngstest-0g02'; \
b='tests/pngstest-0g02'; \
tests/pngstest-1.8-alpha.log: tests/pngstest-1.8-alpha
@p='tests/pngstest-1.8-alpha'; \
b='tests/pngstest-1.8-alpha'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-0g04.log: tests/pngstest-0g04
@p='tests/pngstest-0g04'; \
b='tests/pngstest-0g04'; \
tests/pngstest-linear.log: tests/pngstest-linear
@p='tests/pngstest-linear'; \
b='tests/pngstest-linear'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-0g08.log: tests/pngstest-0g08
@p='tests/pngstest-0g08'; \
b='tests/pngstest-0g08'; \
tests/pngstest-linear-alpha.log: tests/pngstest-linear-alpha
@p='tests/pngstest-linear-alpha'; \
b='tests/pngstest-linear-alpha'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-0g16.log: tests/pngstest-0g16
@p='tests/pngstest-0g16'; \
b='tests/pngstest-0g16'; \
tests/pngstest-none.log: tests/pngstest-none
@p='tests/pngstest-none'; \
b='tests/pngstest-none'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-2c08.log: tests/pngstest-2c08
@p='tests/pngstest-2c08'; \
b='tests/pngstest-2c08'; \
tests/pngstest-none-alpha.log: tests/pngstest-none-alpha
@p='tests/pngstest-none-alpha'; \
b='tests/pngstest-none-alpha'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-2c16.log: tests/pngstest-2c16
@p='tests/pngstest-2c16'; \
b='tests/pngstest-2c16'; \
tests/pngstest-sRGB.log: tests/pngstest-sRGB
@p='tests/pngstest-sRGB'; \
b='tests/pngstest-sRGB'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-3p01.log: tests/pngstest-3p01
@p='tests/pngstest-3p01'; \
b='tests/pngstest-3p01'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-3p02.log: tests/pngstest-3p02
@p='tests/pngstest-3p02'; \
b='tests/pngstest-3p02'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-3p04.log: tests/pngstest-3p04
@p='tests/pngstest-3p04'; \
b='tests/pngstest-3p04'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-3p08.log: tests/pngstest-3p08
@p='tests/pngstest-3p08'; \
b='tests/pngstest-3p08'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-4a08.log: tests/pngstest-4a08
@p='tests/pngstest-4a08'; \
b='tests/pngstest-4a08'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-4a16.log: tests/pngstest-4a16
@p='tests/pngstest-4a16'; \
b='tests/pngstest-4a16'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-6a08.log: tests/pngstest-6a08
@p='tests/pngstest-6a08'; \
b='tests/pngstest-6a08'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-6a16.log: tests/pngstest-6a16
@p='tests/pngstest-6a16'; \
b='tests/pngstest-6a16'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
tests/pngstest-error.log: tests/pngstest-error
@p='tests/pngstest-error'; \
b='tests/pngstest-error'; \
tests/pngstest-sRGB-alpha.log: tests/pngstest-sRGB-alpha
@p='tests/pngstest-sRGB-alpha'; \
b='tests/pngstest-sRGB-alpha'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
@ -1960,6 +2002,12 @@ distclean-generic:
-rm -f contrib/libtests/$(am__dirstamp)
-rm -f contrib/tools/$(DEPDIR)/$(am__dirstamp)
-rm -f contrib/tools/$(am__dirstamp)
-rm -f intel/$(DEPDIR)/$(am__dirstamp)
-rm -f intel/$(am__dirstamp)
-rm -f mips/$(DEPDIR)/$(am__dirstamp)
-rm -f mips/$(am__dirstamp)
-rm -f powerpc/$(DEPDIR)/$(am__dirstamp)
-rm -f powerpc/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -1976,7 +2024,7 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR) arm/$(DEPDIR) contrib/libtests/$(DEPDIR) contrib/tools/$(DEPDIR)
-rm -rf ./$(DEPDIR) arm/$(DEPDIR) contrib/libtests/$(DEPDIR) contrib/tools/$(DEPDIR) intel/$(DEPDIR) mips/$(DEPDIR) powerpc/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
@ -2028,7 +2076,7 @@ installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR) arm/$(DEPDIR) contrib/libtests/$(DEPDIR) contrib/tools/$(DEPDIR)
-rm -rf ./$(DEPDIR) arm/$(DEPDIR) contrib/libtests/$(DEPDIR) contrib/tools/$(DEPDIR) intel/$(DEPDIR) mips/$(DEPDIR) powerpc/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@ -2152,6 +2200,7 @@ contrib/libtests/timepng.o: pnglibconf.h
contrib/tools/makesRGB.o: pnglibconf.h
contrib/tools/pngfix.o: pnglibconf.h
contrib/tools/pngcp.o: pnglibconf.h
.c.out:
rm -f $@ $*.tf[12]

View File

@ -1,4 +1,4 @@
README for libpng version 1.6.17 - March 26, 2015 (shared library 16.0)
README for libpng version 1.6.34 - September 29, 2017 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -23,7 +23,7 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use
this function.
To avoid problems with changes to the internals of png info_struct,
To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
@ -88,11 +88,11 @@ zlib should be available at the same place that libpng is, or at zlib.net.
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
in any of those places, e-mail me, and I'll help you find it.
This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at http://libpng.download/src . If you
can't find it in any of those places, e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
@ -134,7 +134,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for nineteen years now, and it is official and
been discussing PNG for twenty years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.
@ -179,18 +179,25 @@ Files in this distribution:
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform
powerpc => Contains optimized code for the PowerPC platform
contrib => Contributions
arm-neon => Optimized code for ARM-NEON platform
powerpc-vsx => Optimized code for POWERPC-VSX platform
examples => Example programs
gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999
libtests => Test programs
mips-msa => Optimized code for MIPS-MSA platform
pngminim => Minimal decoder, encoder, and progressive decoder
programs demonstrating use of pngusr.dfa
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
testpngs
tools => Various tools
visupng => Contains a MSVC workspace for VisualPng
intel => Optimized code for INTEL-SSE2 platform
mips => Optimized code for MIPS platform
projects => Contains project files and workspaces for
building a DLL
owatcom => Contains a WATCOM project for building libpng

View File

@ -5,13 +5,14 @@ Final bug fixes.
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
this, minimize the use of png_error(), replacing them with
png_warning(); return(0); or similar.
Palette creation.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Make profile checking optional via a png_set_something() call.
Man pages for function calls.
Better documentation.
Better filter selection
@ -23,7 +24,7 @@ Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
Refactor preprocessor conditionals to compile entire statements
*/

View File

@ -1,9 +1,9 @@
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.22 [May 26, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -66,6 +66,7 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
png_debug(1, "in png_init_filter_functions_neon");
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{

View File

@ -1,9 +1,9 @@
/* filter_neon.S - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.31 [July 27, 2017]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -16,7 +16,7 @@
#define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h"
#if defined(__linux__) && defined(__ELF__)
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif

View File

@ -1,11 +1,11 @@
/* filter_neon_intrinsics.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by James Yu <james.yu at linaro.org>, October 2013.
* Based on filter_neon.S, written by Mans Rullgard, 2011.
*
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.22 [May 26, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -47,6 +47,8 @@ png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
png_bytep rp_stop = row + row_info->rowbytes;
png_const_bytep pp = prev_row;
png_debug(1, "in png_read_filter_row_up_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint8x16_t qrp, qpp;
@ -72,6 +74,8 @@ png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_sub3_neon");
for (; rp < rp_stop;)
{
uint8x8_t vtmp1, vtmp2;
@ -113,6 +117,8 @@ png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_sub4_neon");
for (; rp < rp_stop; rp += 16)
{
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
@ -148,6 +154,8 @@ png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
png_debug(1, "in png_read_filter_row_avg3_neon");
for (; rp < rp_stop; pp += 12)
{
uint8x8_t vtmp1, vtmp2, vtmp3;
@ -207,6 +215,8 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_avg4_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;
@ -280,6 +290,8 @@ png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
png_debug(1, "in png_read_filter_row_paeth3_neon");
for (; rp < rp_stop; pp += 12)
{
uint8x8x2_t *vppt;
@ -339,6 +351,8 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
png_debug(1, "in png_read_filter_row_paeth4_neon");
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;

View File

@ -73,12 +73,13 @@ done
# present bad things are happening.
#
# The autotools generated files:
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
config.sub configure depcomp install-sh ltmain.sh missing test-driver"
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
config.sub configure depcomp install-sh ltmain.sh missing\
test-driver"
#
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
# versions than those required by configure.ac):
libpng_autotools_extra="compile"
libpng_autotools_extra="compile config.h.in~"
#
# These are separate because 'maintainer-clean' does not remove them.
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\

View File

@ -78,6 +78,27 @@
/* Enable ARM Neon optimizations */
#undef PNG_ARM_NEON_OPT
/* Enable Intel SSE optimizations */
#undef PNG_INTEL_SSE_OPT
/* Turn on MIPS MSA optimizations at run-time */
#undef PNG_MIPS_MSA_API_SUPPORTED
/* Check for MIPS MSA support at run-time */
#undef PNG_MIPS_MSA_CHECK_SUPPORTED
/* Enable MIPS MSA optimizations */
#undef PNG_MIPS_MSA_OPT
/* Turn on POWERPC VSX optimizations at run-time */
#undef PNG_POWERPC_VSX_API_SUPPORTED
/* Check for POWERPC VSX support at run-time */
#undef PNG_POWERPC_VSX_CHECK_SUPPORTED
/* Enable POWERPC VSX optimizations */
#undef PNG_POWERPC_VSX_OPT
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libpng 1.6.17.
# Generated by GNU Autoconf 2.69 for libpng 1.6.34.
#
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
#
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libpng'
PACKAGE_TARNAME='libpng'
PACKAGE_VERSION='1.6.17'
PACKAGE_STRING='libpng 1.6.17'
PACKAGE_VERSION='1.6.34'
PACKAGE_STRING='libpng 1.6.34'
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
PACKAGE_URL=''
@ -635,6 +635,12 @@ ac_includes_default="\
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
PNG_POWERPC_VSX_FALSE
PNG_POWERPC_VSX_TRUE
PNG_INTEL_SSE_FALSE
PNG_INTEL_SSE_TRUE
PNG_MIPS_MSA_FALSE
PNG_MIPS_MSA_TRUE
PNG_ARM_NEON_FALSE
PNG_ARM_NEON_TRUE
DO_INSTALL_LIBPNG_CONFIG_FALSE
@ -657,6 +663,8 @@ HAVE_LD_VERSION_SCRIPT_FALSE
HAVE_LD_VERSION_SCRIPT_TRUE
HAVE_SOLARIS_LD_FALSE
HAVE_SOLARIS_LD_TRUE
HAVE_CLOCK_GETTIME_FALSE
HAVE_CLOCK_GETTIME_TRUE
LIBOBJS
POW_LIB
PNG_COPTS
@ -805,7 +813,11 @@ with_libpng_prefix
enable_unversioned_links
enable_unversioned_libpng_pc
enable_unversioned_libpng_config
enable_hardware_optimizations
enable_arm_neon
enable_mips_msa
enable_intel_sse
enable_powerpc_vsx
'
ac_precious_vars='build_alias
host_alias
@ -1360,7 +1372,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libpng 1.6.17 to adapt to many kinds of systems.
\`configure' configures libpng 1.6.34 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1430,7 +1442,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libpng 1.6.17:";;
short | recursive ) echo "Configuration of libpng 1.6.34:";;
esac
cat <<\_ACEOF
@ -1482,6 +1494,8 @@ Optional Features:
link to the versioned version. This is done by
default - use --disable-unversioned-libpng-config to
change this.
--enable-hardware-optimizations
Enable hardware optimizations: =no/off, yes/on:
--enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api,
yes/on: no/off: disable the optimizations; check:
use internal checking code (deprecated and poorly
@ -1489,6 +1503,23 @@ Optional Features:
call to png_set_option; yes/on: turn on
unconditionally. If not specified: determined by the
compiler.
--enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api,
yes/on: no/off: disable the optimizations; check:
use internal checking code (deprecated and poorly
supported); api: disable by default, enable by a
call to png_set_option; yes/on: turn on
unconditionally. If not specified: determined by the
compiler.
--enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on:
no/off: disable the optimizations; yes/on: enable
the optimizations. If not specified: determined by
the compiler.
--enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check,
api, yes/on: no/off: disable the optimizations;
check: use internal checking code api: disable by
default, enable by a call to png_set_option yes/on:
turn on unconditionally. If not specified:
determined by the compiler.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -1591,7 +1622,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libpng configure 1.6.17
libpng configure 1.6.34
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -1923,7 +1954,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libpng $as_me 1.6.17, which was
It was created by libpng $as_me 1.6.34, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2794,7 +2825,7 @@ fi
# Define the identity of the package.
PACKAGE='libpng'
VERSION='1.6.17'
VERSION='1.6.34'
cat >>confdefs.h <<_ACEOF
@ -2888,7 +2919,7 @@ END
fi
# The following line causes --disable-maintainer-mode to be the default to
# configure, this is necessary because libpng distributions cannot rely on the
# configure. This is necessary because libpng distributions cannot rely on the
# time stamps of the autotools generated files being correct
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
@ -2915,10 +2946,10 @@ fi
PNGLIB_VERSION=1.6.17
PNGLIB_VERSION=1.6.34
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
PNGLIB_RELEASE=17
PNGLIB_RELEASE=34
@ -12597,6 +12628,41 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1
# This is incompatible with the new default mode, so we test for that and force the
# "-std=c89" compiler option:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to force back C standard to C89" >&5
$as_echo_n "checking if we need to force back C standard to C89... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _POSIX_SOURCE 1
#include <stdio.h>
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
if test "x$GCC" != "xyes"; then
as_fn_error $? "Forcing back to C89 is required but the flags are only known for GCC" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
CFLAGS="$CFLAGS -std=c89"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Checks for header files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
@ -13073,6 +13139,26 @@ fi
done
# Some later POSIX 1003.1 functions are required for test programs, failure here
# is soft (the corresponding test program is not built).
ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
if test "x$ac_cv_func_clock_gettime" = xyes; then :
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: not building timepng" >&5
$as_echo "$as_me: WARNING: not building timepng" >&2;}
fi
if test "$ac_cv_func_clock_gettime" = "yes"; then
HAVE_CLOCK_GETTIME_TRUE=
HAVE_CLOCK_GETTIME_FALSE='#'
else
HAVE_CLOCK_GETTIME_TRUE='#'
HAVE_CLOCK_GETTIME_FALSE=
fi
# Check whether --with-zlib-prefix was given.
if test "${with_zlib_prefix+set}" = set; then :
withval=$with_zlib_prefix; ZPREFIX=${withval}
@ -13420,6 +13506,64 @@ fi
# HOST SPECIFIC OPTIONS
# =====================
#
# DEFAULT
# =======
#
# Check whether --enable-hardware-optimizations was given.
if test "${enable_hardware_optimizations+set}" = set; then :
enableval=$enable_hardware_optimizations; case "$enableval" in
no|off)
# disable hardware optimization on all systems:
enable_arm_neon=no
$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h
enable_mips_msa=no
$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h
enable_powerpc_vsx=no
$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h
enable_intel_sse=no
$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h
;;
*)
# allow enabling hardware optimization on any system:
case "$host_cpu" in
arm*|aarch64*)
enable_arm_neon=yes
$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h
;;
mipsel*|mips64el*)
enable_mips_msa=yes
$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h
;;
i?86|x86_64)
enable_intel_sse=yes
$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h
;;
powerpc*|ppc64*)
enable_powerpc_vsx=yes
$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h
;;
esac
;;
esac
fi
# ARM
# ===
#
@ -13476,6 +13620,162 @@ else
fi
# MIPS
# ===
#
# MIPS MSA (SIMD) support.
# Check whether --enable-mips-msa was given.
if test "${enable_mips_msa+set}" = set; then :
enableval=$enable_mips_msa; case "$enableval" in
no|off)
# disable the default enabling on __mips_msa systems:
$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h
# Prevent inclusion of the assembler files below:
enable_mips_msa=no;;
check)
$as_echo "#define PNG_MIPS_MSA_CHECK_SUPPORTED /**/" >>confdefs.h
;;
api)
$as_echo "#define PNG_MIPS_MSA_API_SUPPORTED /**/" >>confdefs.h
;;
yes|on)
$as_echo "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api', if
you want the optimizations unconditionally pass '-mmsa -mfp64'
to the compiler." >&5
$as_echo "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api', if
you want the optimizations unconditionally pass '-mmsa -mfp64'
to the compiler." >&2;};;
*)
as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: invalid value" "$LINENO" 5
esac
fi
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'mips*')
if test "$enable_mips_msa" != 'no' &&
case "$host_cpu" in
mipsel*|mips64el*) :;;
esac; then
PNG_MIPS_MSA_TRUE=
PNG_MIPS_MSA_FALSE='#'
else
PNG_MIPS_MSA_TRUE='#'
PNG_MIPS_MSA_FALSE=
fi
# INTEL
# =====
#
# INTEL SSE (SIMD) support.
# Check whether --enable-intel-sse was given.
if test "${enable_intel_sse+set}" = set; then :
enableval=$enable_intel_sse; case "$enableval" in
no|off)
# disable the default enabling:
$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h
# Prevent inclusion of the assembler files below:
enable_intel_sse=no;;
yes|on)
$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h
;;
*)
as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: invalid value" "$LINENO" 5
esac
fi
# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
# or where Intel optimizations were explicitly requested (this allows a
# fallback if a future host CPU does not match 'x86*')
if test "$enable_intel_sse" != 'no' &&
case "$host_cpu" in
i?86|x86_64) :;;
*) test "$enable_intel_sse" != '';;
esac; then
PNG_INTEL_SSE_TRUE=
PNG_INTEL_SSE_FALSE='#'
else
PNG_INTEL_SSE_TRUE='#'
PNG_INTEL_SSE_FALSE=
fi
# PowerPC
# ===
#
# PowerPC VSX (SIMD) support.
# Check whether --enable-powerpc-vsx was given.
if test "${enable_powerpc_vsx+set}" = set; then :
enableval=$enable_powerpc_vsx; case "$enableval" in
no|off)
# disable the default enabling on __ppc64__ systems:
$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h
# Prevent inclusion of the platform specific files below:
enable_powerpc_vsx=no;;
check)
$as_echo "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file
for the list of supported OSes." >&5
$as_echo "$as_me: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file
for the list of supported OSes." >&2;};;
api)
$as_echo "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h
;;
yes|on)
$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if
you want the optimizations unconditionally pass '-maltivec -mvsx'
or '-mcpu=power8'to the compiler." >&5
$as_echo "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if
you want the optimizations unconditionally pass '-maltivec -mvsx'
or '-mcpu=power8'to the compiler." >&2;};;
*)
as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value" "$LINENO" 5
esac
fi
# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or
# where POWERPC optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'powerpc*')
if test "$enable_powerpc_vsx" != 'no' &&
case "$host_cpu" in
powerpc*|ppc64*) :;;
esac; then
PNG_POWERPC_VSX_TRUE=
PNG_POWERPC_VSX_FALSE='#'
else
PNG_POWERPC_VSX_TRUE='#'
PNG_POWERPC_VSX_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5
$as_echo "$as_me: Extra options for compiler: $PNG_COPTS" >&6;}
@ -13626,6 +13926,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_CLOCK_GETTIME_TRUE}" && test -z "${HAVE_CLOCK_GETTIME_FALSE}"; then
as_fn_error $? "conditional \"HAVE_CLOCK_GETTIME\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_SOLARIS_LD_TRUE}" && test -z "${HAVE_SOLARIS_LD_FALSE}"; then
as_fn_error $? "conditional \"HAVE_SOLARIS_LD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@ -13654,6 +13958,18 @@ if test -z "${PNG_ARM_NEON_TRUE}" && test -z "${PNG_ARM_NEON_FALSE}"; then
as_fn_error $? "conditional \"PNG_ARM_NEON\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${PNG_MIPS_MSA_TRUE}" && test -z "${PNG_MIPS_MSA_FALSE}"; then
as_fn_error $? "conditional \"PNG_MIPS_MSA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${PNG_INTEL_SSE_TRUE}" && test -z "${PNG_INTEL_SSE_FALSE}"; then
as_fn_error $? "conditional \"PNG_INTEL_SSE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${PNG_POWERPC_VSX_TRUE}" && test -z "${PNG_POWERPC_VSX_FALSE}"; then
as_fn_error $? "conditional \"PNG_POWERPC_VSX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
@ -14051,7 +14367,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libpng $as_me 1.6.17, which was
This file was extended by libpng $as_me 1.6.34, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -14117,7 +14433,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libpng config.status 1.6.17
libpng config.status 1.6.34
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -1,5 +1,12 @@
# configure.ac
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.6.25 [September 1, 2016]
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
@ -18,7 +25,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.6.17],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.6.34],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@ -29,7 +36,7 @@ AC_CONFIG_MACRO_DIR([scripts])
# 1.13 is required for parallel tests
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
# The following line causes --disable-maintainer-mode to be the default to
# configure, this is necessary because libpng distributions cannot rely on the
# configure. This is necessary because libpng distributions cannot rely on the
# time stamps of the autotools generated files being correct
AM_MAINTAINER_MODE
@ -39,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.17
PNGLIB_VERSION=1.6.34
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
PNGLIB_RELEASE=17
PNGLIB_RELEASE=34
dnl End of version number stuff
@ -60,7 +67,7 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
dnl compatible later version may be used
LT_INIT([win32-dll])
LT_PREREQ([2.4.2])
@ -107,6 +114,25 @@ AC_ARG_ENABLE(werror,
CFLAGS="$sav_CFLAGS"
fi],)
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1
# This is incompatible with the new default mode, so we test for that and force the
# "-std=c89" compiler option:
AC_MSG_CHECKING([if we need to force back C standard to C89])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([
[#define _POSIX_SOURCE 1]
[#include <stdio.h>]
])],
AC_MSG_RESULT(no),[
if test "x$GCC" != "xyes"; then
AC_MSG_ERROR(
[Forcing back to C89 is required but the flags are only known for GCC])
fi
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -std=c89"
])
# Checks for header files.
AC_HEADER_STDC
@ -120,6 +146,12 @@ AC_C_RESTRICT
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
# Some later POSIX 1003.1 functions are required for test programs, failure here
# is soft (the corresponding test program is not built).
AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])])
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
AC_ARG_WITH(zlib-prefix,
AS_HELP_STRING([[[--with-zlib-prefix]]],
[prefix that may have been used in installed zlib]),
@ -268,6 +300,55 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
# HOST SPECIFIC OPTIONS
# =====================
#
# DEFAULT
# =======
#
AC_ARG_ENABLE([hardware-optimizations],
AS_HELP_STRING([[[--enable-hardware-optimizations]]],
[Enable hardware optimizations: =no/off, yes/on:]),
[case "$enableval" in
no|off)
# disable hardware optimization on all systems:
enable_arm_neon=no
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
[Disable ARM_NEON optimizations])
enable_mips_msa=no
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
[Disable MIPS_MSA optimizations])
enable_powerpc_vsx=no
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
[Disable POWERPC VSX optimizations])
enable_intel_sse=no
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
[Disable INTEL_SSE optimizations])
;;
*)
# allow enabling hardware optimization on any system:
case "$host_cpu" in
arm*|aarch64*)
enable_arm_neon=yes
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
[Enable ARM_NEON optimizations])
;;
mipsel*|mips64el*)
enable_mips_msa=yes
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
[Enable MIPS_MSA optimizations])
;;
i?86|x86_64)
enable_intel_sse=yes
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
[Enable Intel SSE optimizations])
;;
powerpc*|ppc64*)
enable_powerpc_vsx=yes
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
[Enable POWERPC VSX optimizations])
;;
esac
;;
esac])
# ARM
# ===
#
@ -314,6 +395,134 @@ AM_CONDITIONAL([PNG_ARM_NEON],
*) test "$enable_arm_neon" != '';;
esac])
# MIPS
# ===
#
# MIPS MSA (SIMD) support.
AC_ARG_ENABLE([mips-msa],
AS_HELP_STRING([[[--enable-mips-msa]]],
[Enable MIPS MSA optimizations: =no/off, check, api, yes/on:]
[no/off: disable the optimizations; check: use internal checking code]
[(deprecated and poorly supported); api: disable by default, enable by]
[a call to png_set_option; yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]),
[case "$enableval" in
no|off)
# disable the default enabling on __mips_msa systems:
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
[Disable MIPS MSA optimizations])
# Prevent inclusion of the assembler files below:
enable_mips_msa=no;;
check)
AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
[Check for MIPS MSA support at run-time]);;
api)
AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
[Turn on MIPS MSA optimizations at run-time]);;
yes|on)
AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
[Enable MIPS MSA optimizations])
AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
[you want the optimizations unconditionally pass '-mmsa -mfp64']
[to the compiler.]);;
*)
AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
esac])
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'mips*')
AM_CONDITIONAL([PNG_MIPS_MSA],
[test "$enable_mips_msa" != 'no' &&
case "$host_cpu" in
mipsel*|mips64el*) :;;
esac])
# INTEL
# =====
#
# INTEL SSE (SIMD) support.
AC_ARG_ENABLE([intel-sse],
AS_HELP_STRING([[[--enable-intel-sse]]],
[Enable Intel SSE optimizations: =no/off, yes/on:]
[no/off: disable the optimizations;]
[yes/on: enable the optimizations.]
[If not specified: determined by the compiler.]),
[case "$enableval" in
no|off)
# disable the default enabling:
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
[Disable Intel SSE optimizations])
# Prevent inclusion of the assembler files below:
enable_intel_sse=no;;
yes|on)
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
[Enable Intel SSE optimizations]);;
*)
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
esac])
# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
# or where Intel optimizations were explicitly requested (this allows a
# fallback if a future host CPU does not match 'x86*')
AM_CONDITIONAL([PNG_INTEL_SSE],
[test "$enable_intel_sse" != 'no' &&
case "$host_cpu" in
i?86|x86_64) :;;
*) test "$enable_intel_sse" != '';;
esac])
# PowerPC
# ===
#
# PowerPC VSX (SIMD) support.
AC_ARG_ENABLE([powerpc-vsx],
AS_HELP_STRING([[[--enable-powerpc-vsx]]],
[Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:]
[no/off: disable the optimizations; check: use internal checking code]
[api: disable by default, enable by a call to png_set_option]
[yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]),
[case "$enableval" in
no|off)
# disable the default enabling on __ppc64__ systems:
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
[Disable POWERPC VSX optimizations])
# Prevent inclusion of the platform specific files below:
enable_powerpc_vsx=no;;
check)
AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
[Check for POWERPC VSX support at run-time])
AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file]
[for the list of supported OSes.]);;
api)
AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
[Turn on POWERPC VSX optimizations at run-time]);;
yes|on)
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
[Enable POWERPC VSX optimizations])
AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if]
[you want the optimizations unconditionally pass '-maltivec -mvsx']
[or '-mcpu=power8'to the compiler.]);;
*)
AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value])
esac])
# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or
# where POWERPC optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'powerpc*')
AM_CONDITIONAL([PNG_POWERPC_VSX],
[test "$enable_powerpc_vsx" != 'no' &&
case "$host_cpu" in
powerpc*|ppc64*) :;;
esac])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above

View File

@ -1,4 +1,5 @@
This "contrib" directory contains contributions which are not necessarily under
the libpng license, although all are open source. They are not part of
libpng proper and are not used for building the library.
libpng proper and are not used for building the library, although some are used
for testing the library via "make check".

View File

@ -1,7 +1,7 @@
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
--------------------------------------------
Detection of the ability to exexcute ARM NEON on an ARM processor requires
Detection of the ability to execute ARM NEON on an ARM processor requires
operating system support. (The information is not available in user mode.)
HOW TO USE THIS

View File

@ -17,7 +17,7 @@
*
* Documentation:
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
* http://code.google.com/p/android/issues/detail?id=49065
* https://code.google.com/p/android/issues/detail?id=49065
*
* NOTE: this requires that libpng is built against the Android NDK and linked
* with an implementation of the Android ARM 'cpu-features' library. The code

View File

@ -7,7 +7,7 @@
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
*
* SEE contrib/arm-neon/README before reporting bugs
*
* STATUS: COMPILED, TESTED

View File

@ -1,8 +1,8 @@
/* contrib/arm-neon/linux.c
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by John Bowler, 2014.
* Last changed in libpng 1.6.16 [December 22, 2014]
* Last changed in libpng 1.6.31 [July 27, 2017]
* Copyright (c) 2014, 2017 Glenn Randers-Pehrson
* Written by John Bowler, 2014, 2017.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -62,7 +62,7 @@ png_have_neon(png_structp png_ptr)
counter=0;
state = Feature;
/* FALL THROUGH */
/* FALLTHROUGH */
case Feature:
/* Match 'FEATURE', ASCII case insensitive. */
@ -72,10 +72,10 @@ png_have_neon(png_structp png_ptr)
state = Colon;
break;
}
/* did not match 'feature' */
state = SkipLine;
/* FALL THROUGH */
/* FALLTHROUGH */
case SkipLine:
skipLine:
@ -110,7 +110,7 @@ png_have_neon(png_structp png_ptr)
state = Neon;
counter = 0;
/* FALL THROUGH */
/* FALLTHROUGH */
case Neon:
/* Look for 'neon' tag */
@ -122,7 +122,7 @@ png_have_neon(png_structp png_ptr)
}
state = SkipTag;
/* FALL THROUGH */
/* FALLTHROUGH */
case SkipTag:
/* Skip non-space characters */

View File

@ -0,0 +1,57 @@
# pngcp.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2016
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with support for pngcp. This means just png_read_png,
# png_write_png and small number of configuration settings.
#
everything = off
# This option is specific to this configuration; it adds a #define to the
# generated pnglibconf.h which turns on the (not portable) timing option for
# pngcp. Note that any option is automatically preceded by PNG_; there is no
# way round this and this is deliberate.
option PNGCP_TIMING
# Because of the everything off above the option must also be turned on. This
# may not be done in one step because it is safer and avoids mis-spelled options
# in user .dfa files to error out if an unrecognized option is turned on.
option PNGCP_TIMING on
# Options to turn on png_read_png and png_write_png:
option INFO_IMAGE on
option SEQUENTIAL_READ on
option EASY_ACCESS on
option WRITE on
option WRITE_16BIT on
option WRITE_FILTER on
# pngcp needs this to preserve unknown chunks, switching all these on means that
# pngcp can work without explicit known chunk reading suppport
option UNKNOWN_CHUNKS on
option SET_UNKNOWN_CHUNKS on
option HANDLE_AS_UNKNOWN on
option SAVE_UNKNOWN_CHUNKS on
option WRITE_UNKNOWN_CHUNKS on
# pngcp needs this to handle palette files with invalid indices:
option CHECK_FOR_INVALID_INDEX on
option GET_PALETTE_MAX on
# Pre-libpng 1.7 pngcp has to stash text chunks manually, post 1.7 without this
# text chunks should be handled as unknown ok.
option TEXT on
# this is used to turn off limits:
option USER_LIMITS on
option SET_USER_LIMITS on
# these are are just required for specific customizations
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
option WRITE_CUSTOMIZE_COMPRESSION on

View File

@ -21,4 +21,4 @@ ORIGINAL AUTHORS
of the people below claim any rights with regard to the contents of this
directory.
John Bowler <jbowler@acm.org>
John Bowler <jbowler at acm.org>

View File

@ -26,6 +26,10 @@
#include <png.h>
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
defined (PNG_iCCP_SUPPORTED)
static int verbose = 1;
static png_byte no_profile[] = "no profile";
@ -178,3 +182,4 @@ main(int argc, char **argv)
/* Exit code is true if any extract succeeds */
return extracted == 0;
}
#endif /* READ && STDIO && iCCP */

Some files were not shown because too many files have changed in this diff Show More