mirror of
https://github.com/wiiu-env/libgui.git
synced 2025-01-12 08:19:07 +01:00
- Move lib from $(DESTDIR)$(DEVKITPRO)/wut/ to $(DESTDIR)$(DEVKITPRO)/wut/usr
- Remove fs dependencies - Replace CMutex with std::recursive_mutex - Remove the AsyncDeleter (dependency) - memoryInitialize was renamed to libgui_memoryInialized and added to this lib (same for memoryRelease)
This commit is contained in:
parent
886ae7e19b
commit
40d4391788
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ libgui.cbp
|
|||||||
lib/
|
lib/
|
||||||
*.bz2
|
*.bz2
|
||||||
libgui.layout
|
libgui.layout
|
||||||
|
obj/
|
||||||
|
8
Makefile
8
Makefile
@ -12,7 +12,7 @@ include $(DEVKITPRO)/wut/share/wut_rules
|
|||||||
|
|
||||||
export VER_MAJOR := 1
|
export VER_MAJOR := 1
|
||||||
export VER_MINOR := 0
|
export VER_MINOR := 0
|
||||||
export VER_PATCH := 0
|
export VER_PATCH := 1
|
||||||
|
|
||||||
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
||||||
|
|
||||||
@ -26,8 +26,10 @@ VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
|||||||
TARGET := $(notdir $(CURDIR))
|
TARGET := $(notdir $(CURDIR))
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := source \
|
SOURCES := source \
|
||||||
|
source/fs \
|
||||||
source/gui \
|
source/gui \
|
||||||
source/sounds \
|
source/sounds \
|
||||||
|
source/system \
|
||||||
source/video \
|
source/video \
|
||||||
source/video/shaders \
|
source/video/shaders \
|
||||||
|
|
||||||
@ -115,8 +117,8 @@ dist-src:
|
|||||||
dist: dist-src dist-bin
|
dist: dist-src dist-bin
|
||||||
|
|
||||||
install: dist-bin
|
install: dist-bin
|
||||||
mkdir -p $(DESTDIR)$(DEVKITPRO)/wut
|
mkdir -p $(DESTDIR)$(DEVKITPRO)/wut/usr
|
||||||
bzip2 -cd libgui-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut
|
bzip2 -cd libgui-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut/usr
|
||||||
|
|
||||||
lib:
|
lib:
|
||||||
@[ -d $@ ] || mkdir -p $@
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <gui/sigslot.h>
|
#include <gui/sigslot.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <gui/system/AsyncDeleter.h>
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -68,7 +67,7 @@ class GuiController;
|
|||||||
class CVideo;
|
class CVideo;
|
||||||
|
|
||||||
//!Primary GUI class. Most other classes inherit from this class.
|
//!Primary GUI class. Most other classes inherit from this class.
|
||||||
class GuiElement : public AsyncDeleter::Element {
|
class GuiElement {
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
GuiElement();
|
GuiElement();
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#ifndef _GUIIMAGEASYNC_H_
|
#ifndef _GUIIMAGEASYNC_H_
|
||||||
#define _GUIIMAGEASYNC_H_
|
#define _GUIIMAGEASYNC_H_
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
#include <gui/system/CThread.h>
|
#include <gui/system/CThread.h>
|
||||||
#include <gui/system/CMutex.h>
|
|
||||||
|
|
||||||
class GuiImageAsync : public GuiImage {
|
class GuiImageAsync : public GuiImage {
|
||||||
public:
|
public:
|
||||||
@ -51,7 +51,7 @@ private:
|
|||||||
|
|
||||||
static std::vector<GuiImageAsync *> imageQueue;
|
static std::vector<GuiImageAsync *> imageQueue;
|
||||||
static CThread *pThread;
|
static CThread *pThread;
|
||||||
static CMutex * pMutex;
|
static std::recursive_mutex * pMutex;
|
||||||
static uint32_t threadRefCounter;
|
static uint32_t threadRefCounter;
|
||||||
static GuiImageAsync * pInUse;
|
static GuiImageAsync * pInUse;
|
||||||
static bool bExitRequested;
|
static bool bExitRequested;
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
#define GUI_IMAGEDATA_H_
|
#define GUI_IMAGEDATA_H_
|
||||||
|
|
||||||
#include <gd.h>
|
#include <gd.h>
|
||||||
#include <gui/system/AsyncDeleter.h>
|
#include <gui/GuiElement.h>
|
||||||
#include <gui/gx2_ext.h>
|
#include <gui/gx2_ext.h>
|
||||||
#include <gx2/texture.h>
|
#include <gx2/texture.h>
|
||||||
|
|
||||||
class GuiImageData : public AsyncDeleter::Element {
|
class GuiImageData : public GuiElement {
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
GuiImageData();
|
GuiImageData();
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#ifndef GUI_SOUND_H_
|
#ifndef GUI_SOUND_H_
|
||||||
#define GUI_SOUND_H_
|
#define GUI_SOUND_H_
|
||||||
|
|
||||||
#include <gui/system/AsyncDeleter.h>
|
#include <gui/GuiElement.h>
|
||||||
|
|
||||||
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
||||||
class GuiSound : public AsyncDeleter::Element {
|
class GuiSound : public GuiElement {
|
||||||
public:
|
public:
|
||||||
//!Constructor
|
//!Constructor
|
||||||
//!\param sound Pointer to the sound data
|
//!\param sound Pointer to the sound data
|
||||||
|
@ -23,8 +23,8 @@ extern "C" {
|
|||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
void memoryInitialize(void);
|
void libgui_memoryInitialize(void);
|
||||||
void memoryRelease(void);
|
void libgui_memoryRelease(void);
|
||||||
|
|
||||||
void * MEM2_alloc(uint32_t size, uint32_t align);
|
void * MEM2_alloc(uint32_t size, uint32_t align);
|
||||||
void MEM2_free(void *ptr);
|
void MEM2_free(void *ptr);
|
@ -27,7 +27,7 @@
|
|||||||
#define SOUND_DECODER_HPP
|
#define SOUND_DECODER_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <gui/system/CMutex.h>
|
#include <mutex>
|
||||||
#include <gui/sounds/BufferCircle.hpp>
|
#include <gui/sounds/BufferCircle.hpp>
|
||||||
|
|
||||||
class CFile;
|
class CFile;
|
||||||
@ -131,7 +131,7 @@ protected:
|
|||||||
uint16_t SampleRate;
|
uint16_t SampleRate;
|
||||||
uint8_t *ResampleBuffer;
|
uint8_t *ResampleBuffer;
|
||||||
uint32_t ResampleRatio;
|
uint32_t ResampleRatio;
|
||||||
CMutex mutex;
|
std::recursive_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* Copyright (C) 2015 Dimok
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
****************************************************************************/
|
|
||||||
#ifndef _ASYNC_DELETER_H
|
|
||||||
#define _ASYNC_DELETER_H
|
|
||||||
|
|
||||||
#include <queue>
|
|
||||||
#include "CThread.h"
|
|
||||||
#include "CMutex.h"
|
|
||||||
|
|
||||||
class AsyncDeleter : public CThread {
|
|
||||||
public:
|
|
||||||
static void destroyInstance() {
|
|
||||||
if(deleterInstance != NULL) {
|
|
||||||
delete deleterInstance;
|
|
||||||
deleterInstance = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Element {
|
|
||||||
public:
|
|
||||||
Element() {}
|
|
||||||
virtual ~Element() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void pushForDelete(AsyncDeleter::Element *e) {
|
|
||||||
if(!deleterInstance) {
|
|
||||||
deleterInstance = new AsyncDeleter();
|
|
||||||
}
|
|
||||||
deleterInstance->deleteElements.push(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL deleteListEmpty() {
|
|
||||||
if(!deleterInstance) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return deleterInstance->deleteElements.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL realListEmpty() {
|
|
||||||
if(!deleterInstance) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return deleterInstance->realDeleteElements.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void triggerDeleteProcess(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
AsyncDeleter();
|
|
||||||
virtual ~AsyncDeleter();
|
|
||||||
|
|
||||||
static AsyncDeleter *deleterInstance;
|
|
||||||
|
|
||||||
void executeThread(void);
|
|
||||||
|
|
||||||
BOOL exitApplication;
|
|
||||||
std::queue<AsyncDeleter::Element *> deleteElements;
|
|
||||||
std::queue<AsyncDeleter::Element *> realDeleteElements;
|
|
||||||
CMutex deleteMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _ASYNC_DELETER_H
|
|
@ -1,69 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* Copyright (C) 2015 Dimok
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
****************************************************************************/
|
|
||||||
#ifndef _CMUTEX_H_
|
|
||||||
#define _CMUTEX_H_
|
|
||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <coreinit/mutex.h>
|
|
||||||
|
|
||||||
class CMutex
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMutex() {
|
|
||||||
pMutex = (OSMutex*) malloc(sizeof(OSMutex));
|
|
||||||
if(!pMutex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OSInitMutex(pMutex);
|
|
||||||
}
|
|
||||||
virtual ~CMutex() {
|
|
||||||
if(pMutex)
|
|
||||||
free(pMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lock(void) {
|
|
||||||
if(pMutex)
|
|
||||||
OSLockMutex(pMutex);
|
|
||||||
}
|
|
||||||
void unlock(void) {
|
|
||||||
if(pMutex)
|
|
||||||
OSUnlockMutex(pMutex);
|
|
||||||
}
|
|
||||||
BOOL tryLock(void) {
|
|
||||||
if(!pMutex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (OSTryLockMutex(pMutex) != 0);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
OSMutex *pMutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMutexLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMutexLock() {
|
|
||||||
mutex.lock();
|
|
||||||
}
|
|
||||||
virtual ~CMutexLock() {
|
|
||||||
mutex.unlock();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
CMutex mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _CMUTEX_H_
|
|
@ -17,10 +17,8 @@
|
|||||||
#ifndef CTHREAD_H_
|
#ifndef CTHREAD_H_
|
||||||
#define CTHREAD_H_
|
#define CTHREAD_H_
|
||||||
|
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <coreinit/systeminfo.h>
|
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
|
|
||||||
class CThread {
|
class CThread {
|
||||||
@ -64,30 +62,37 @@ public:
|
|||||||
}
|
}
|
||||||
//! Suspend thread
|
//! Suspend thread
|
||||||
virtual void suspendThread(void) {
|
virtual void suspendThread(void) {
|
||||||
if(isThreadSuspended()) return;
|
if(isThreadSuspended())
|
||||||
if(pThread) OSSuspendThread(pThread);
|
return;
|
||||||
|
if(pThread)
|
||||||
|
OSSuspendThread(pThread);
|
||||||
}
|
}
|
||||||
//! Resume thread
|
//! Resume thread
|
||||||
virtual void resumeThread(void) {
|
virtual void resumeThread(void) {
|
||||||
if(!isThreadSuspended()) return;
|
if(!isThreadSuspended())
|
||||||
if(pThread) OSResumeThread(pThread);
|
return;
|
||||||
|
if(pThread)
|
||||||
|
OSResumeThread(pThread);
|
||||||
}
|
}
|
||||||
//! Set thread priority
|
//! Set thread priority
|
||||||
virtual void setThreadPriority(int prio) {
|
virtual void setThreadPriority(int32_t prio) {
|
||||||
if(pThread) OSSetThreadPriority(pThread, prio);
|
if(pThread)
|
||||||
|
OSSetThreadPriority(pThread, prio);
|
||||||
}
|
}
|
||||||
//! Check if thread is suspended
|
//! Check if thread is suspended
|
||||||
virtual BOOL isThreadSuspended(void) const {
|
virtual bool isThreadSuspended(void) const {
|
||||||
if(pThread) return OSIsThreadSuspended(pThread);
|
if(pThread)
|
||||||
|
return OSIsThreadSuspended(pThread);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//! Check if thread is terminated
|
//! Check if thread is terminated
|
||||||
virtual BOOL isThreadTerminated(void) const {
|
virtual bool isThreadTerminated(void) const {
|
||||||
if(pThread) return OSIsThreadTerminated(pThread);
|
if(pThread)
|
||||||
|
return OSIsThreadTerminated(pThread);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//! Check if thread is running
|
//! Check if thread is running
|
||||||
virtual BOOL isThreadRunning(void) const {
|
virtual bool isThreadRunning(void) const {
|
||||||
return !isThreadSuspended() && !isThreadRunning();
|
return !isThreadSuspended() && !isThreadRunning();
|
||||||
}
|
}
|
||||||
//! Shutdown thread
|
//! Shutdown thread
|
||||||
@ -118,12 +123,12 @@ public:
|
|||||||
eAttributePinnedAff = 0x10
|
eAttributePinnedAff = 0x10
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
static int threadCallback(int argc, const char **argv) {
|
static int32_t threadCallback(int32_t argc, const char **argv) {
|
||||||
//! After call to start() continue with the internal function
|
//! After call to start() continue with the internal function
|
||||||
((CThread *) argv)->executeThread();
|
((CThread *) argv)->executeThread();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int iAttributes;
|
int32_t iAttributes;
|
||||||
OSThread *pThread;
|
OSThread *pThread;
|
||||||
uint8_t *pThreadStack;
|
uint8_t *pThreadStack;
|
||||||
Callback pCallback;
|
Callback pCallback;
|
||||||
|
169
libgui.layout
169
libgui.layout
@ -1,169 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_layout_file>
|
|
||||||
<ActiveTarget name="build" />
|
|
||||||
<File name="source\gui\GuiDragListener.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="23" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\ColorShader.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1984" topLine="19" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiFrame.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="4169" topLine="190" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GameBgImage.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1407" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiImage.cpp" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="3968" topLine="73" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiFrame.h" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="44" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GridBackground.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="37" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\PixelShader.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="5101" topLine="87" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiImageData.cpp" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="908" topLine="12" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiButton.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="60" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\FreeTypeGX.cpp" open="0" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="18556" topLine="535" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\resources\Resources.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="98" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiImageData.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="4" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiParticleImage.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="5191" topLine="69" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiScrollbar.cpp" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiSelectBox.cpp" open="0" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="10209" topLine="6" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiSelectBox.h" open="0" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1029" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiText.cpp" open="0" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="13325" topLine="552" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\Texture2DShader.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2033" topLine="16" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\ColorShader.cpp" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="4960" topLine="104" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\FXAAShader.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="161" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\Shader3D.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="10122" topLine="182" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\gui\GuiParticleImage.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1339" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\ShaderFractalColor.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="81" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\FXAAShader.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1894" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\Shader3D.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1445" topLine="26" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\CVideo.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="5104" topLine="227" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\Texture2DShader.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="10378" topLine="181" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\FetchShader.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1964" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\CursorDrawer.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2609" topLine="25" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\CVideo.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="4936" topLine="99" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\VertexShader.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="5756" topLine="115" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="source\video\shaders\Shader.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2281" topLine="11" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
</CodeBlocks_layout_file>
|
|
175
source/fs/CFile.cpp
Normal file
175
source/fs/CFile.cpp
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <fs/CFile.hpp>
|
||||||
|
|
||||||
|
CFile::CFile() {
|
||||||
|
iFd = -1;
|
||||||
|
mem_file = NULL;
|
||||||
|
filesize = 0;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFile::CFile(const std::string & filepath, eOpenTypes mode) {
|
||||||
|
iFd = -1;
|
||||||
|
this->open(filepath, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFile::CFile(const uint8_t * mem, int32_t size) {
|
||||||
|
iFd = -1;
|
||||||
|
this->open(mem, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFile::~CFile() {
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::open(const std::string & filepath, eOpenTypes mode) {
|
||||||
|
this->close();
|
||||||
|
int32_t openMode = 0;
|
||||||
|
|
||||||
|
// This depend on the devoptab implementation.
|
||||||
|
// see https://github.com/devkitPro/wut/blob/master/libraries/wutdevoptab/devoptab_fs_open.c#L21 fpr reference
|
||||||
|
|
||||||
|
switch(mode) {
|
||||||
|
default:
|
||||||
|
case ReadOnly: // file must exist
|
||||||
|
openMode = O_RDONLY;
|
||||||
|
break;
|
||||||
|
case WriteOnly: // file will be created / zerod
|
||||||
|
openMode = O_TRUNC | O_CREAT | O_WRONLY;
|
||||||
|
break;
|
||||||
|
case ReadWrite: // file must exist
|
||||||
|
openMode = O_RDWR;
|
||||||
|
break;
|
||||||
|
case Append: // append to file, file will be created if missing. write only
|
||||||
|
openMode = O_CREAT | O_APPEND | O_WRONLY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Using fopen works only on the first launch as expected
|
||||||
|
//! on the second launch it causes issues because we don't overwrite
|
||||||
|
//! the .data sections which is needed for a normal application to re-init
|
||||||
|
//! this will be added with launching as RPX
|
||||||
|
iFd = ::open(filepath.c_str(), openMode);
|
||||||
|
if(iFd < 0)
|
||||||
|
return iFd;
|
||||||
|
|
||||||
|
|
||||||
|
filesize = ::lseek(iFd, 0, SEEK_END);
|
||||||
|
::lseek(iFd, 0, SEEK_SET);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::open(const uint8_t * mem, int32_t size) {
|
||||||
|
this->close();
|
||||||
|
|
||||||
|
mem_file = mem;
|
||||||
|
filesize = size;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFile::close() {
|
||||||
|
if(iFd >= 0)
|
||||||
|
::close(iFd);
|
||||||
|
|
||||||
|
iFd = -1;
|
||||||
|
mem_file = NULL;
|
||||||
|
filesize = 0;
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::read(uint8_t * ptr, size_t size) {
|
||||||
|
if(iFd >= 0) {
|
||||||
|
int32_t ret = ::read(iFd, ptr,size);
|
||||||
|
if(ret > 0)
|
||||||
|
pos += ret;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t readsize = size;
|
||||||
|
|
||||||
|
if(readsize > (int64_t) (filesize-pos))
|
||||||
|
readsize = filesize-pos;
|
||||||
|
|
||||||
|
if(readsize <= 0)
|
||||||
|
return readsize;
|
||||||
|
|
||||||
|
if(mem_file != NULL) {
|
||||||
|
memcpy(ptr, mem_file+pos, readsize);
|
||||||
|
pos += readsize;
|
||||||
|
return readsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::write(const uint8_t * ptr, size_t size) {
|
||||||
|
if(iFd >= 0) {
|
||||||
|
size_t done = 0;
|
||||||
|
while(done < size) {
|
||||||
|
int32_t ret = ::write(iFd, ptr, size - done);
|
||||||
|
if(ret <= 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ptr += ret;
|
||||||
|
done += ret;
|
||||||
|
pos += ret;
|
||||||
|
}
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::seek(long int offset, int32_t origin) {
|
||||||
|
int32_t ret = 0;
|
||||||
|
int64_t newPos = pos;
|
||||||
|
|
||||||
|
if(origin == SEEK_SET) {
|
||||||
|
newPos = offset;
|
||||||
|
} else if(origin == SEEK_CUR) {
|
||||||
|
newPos += offset;
|
||||||
|
} else if(origin == SEEK_END) {
|
||||||
|
newPos = filesize+offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newPos < 0) {
|
||||||
|
pos = 0;
|
||||||
|
} else {
|
||||||
|
pos = newPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(iFd >= 0)
|
||||||
|
ret = ::lseek(iFd, pos, SEEK_SET);
|
||||||
|
|
||||||
|
if(mem_file != NULL) {
|
||||||
|
if(pos > filesize) {
|
||||||
|
pos = filesize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CFile::fwrite(const char *format, ...) {
|
||||||
|
char tmp[512];
|
||||||
|
tmp[0] = 0;
|
||||||
|
int32_t result = -1;
|
||||||
|
|
||||||
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
if((vsprintf(tmp, format, va) >= 0)) {
|
||||||
|
result = this->write((uint8_t *)tmp, strlen(tmp));
|
||||||
|
}
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* Copyright (C) 2010
|
|
||||||
* by Dimok
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any
|
|
||||||
* damages arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any
|
|
||||||
* purpose, including commercial applications, and to alter it and
|
|
||||||
* redistribute it freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you
|
|
||||||
* must not claim that you wrote the original software. If you use
|
|
||||||
* this software in a product, an acknowledgment in the product
|
|
||||||
* documentation would be appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and
|
|
||||||
* must not be misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* DirList Class
|
|
||||||
* for WiiXplorer 2010
|
|
||||||
***************************************************************************/
|
|
||||||
#ifndef ___DIRLIST_H_
|
|
||||||
#define ___DIRLIST_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <wut_types.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char * FilePath;
|
|
||||||
BOOL isDir;
|
|
||||||
} DirEntry;
|
|
||||||
|
|
||||||
class DirList {
|
|
||||||
public:
|
|
||||||
//!Constructor
|
|
||||||
DirList(void);
|
|
||||||
//!\param path Path from where to load the filelist of all files
|
|
||||||
//!\param filter A fileext that needs to be filtered
|
|
||||||
//!\param flags search/filter flags from the enum
|
|
||||||
DirList(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
|
||||||
//!Destructor
|
|
||||||
virtual ~DirList();
|
|
||||||
//! Load all the files from a directory
|
|
||||||
BOOL LoadPath(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
|
||||||
//! Get a filename of the list
|
|
||||||
//!\param list index
|
|
||||||
const char * GetFilename(int32_t index) const;
|
|
||||||
//! Get the a filepath of the list
|
|
||||||
//!\param list index
|
|
||||||
const char *GetFilepath(int32_t index) const {
|
|
||||||
if (!valid(index)) return "";
|
|
||||||
else return FileInfo[index].FilePath;
|
|
||||||
}
|
|
||||||
//! Get the a filesize of the list
|
|
||||||
//!\param list index
|
|
||||||
uint64_t GetFilesize(int32_t index) const;
|
|
||||||
//! Is index a dir or a file
|
|
||||||
//!\param list index
|
|
||||||
BOOL IsDir(int32_t index) const {
|
|
||||||
if(!valid(index)) return false;
|
|
||||||
return FileInfo[index].isDir;
|
|
||||||
};
|
|
||||||
//! Get the filecount of the whole list
|
|
||||||
int32_t GetFilecount() const {
|
|
||||||
return FileInfo.size();
|
|
||||||
};
|
|
||||||
//! Sort list by filepath
|
|
||||||
void SortList();
|
|
||||||
//! Custom sort command for custom sort functions definitions
|
|
||||||
void SortList(BOOL (*SortFunc)(const DirEntry &a, const DirEntry &b));
|
|
||||||
//! Get the index of the specified filename
|
|
||||||
int32_t GetFileIndex(const char *filename) const;
|
|
||||||
//! Enum for search/filter flags
|
|
||||||
enum {
|
|
||||||
Files = 0x01,
|
|
||||||
Dirs = 0x02,
|
|
||||||
CheckSubfolders = 0x08,
|
|
||||||
};
|
|
||||||
protected:
|
|
||||||
// Internal parser
|
|
||||||
BOOL InternalLoadPath(std::string &path);
|
|
||||||
//!Add a list entrie
|
|
||||||
void AddEntrie(const std::string &filepath, const char * filename, BOOL isDir);
|
|
||||||
//! Clear the list
|
|
||||||
void ClearList();
|
|
||||||
//! Check if valid pos is requested
|
|
||||||
inline BOOL valid(uint32_t pos) const {
|
|
||||||
return (pos < FileInfo.size());
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t Flags;
|
|
||||||
uint32_t Depth;
|
|
||||||
const char *Filter;
|
|
||||||
std::vector<DirEntry> FileInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef __FS_UTILS_H_
|
|
||||||
#define __FS_UTILS_H_
|
|
||||||
|
|
||||||
#include <wut_types.h>
|
|
||||||
|
|
||||||
class FSUtils {
|
|
||||||
public:
|
|
||||||
static int32_t LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size);
|
|
||||||
|
|
||||||
//! todo: C++ class
|
|
||||||
static int32_t CreateSubfolder(const char * fullpath);
|
|
||||||
static int32_t CheckFile(const char * filepath);
|
|
||||||
static BOOL saveBufferToFile(const char * path, void * buffer, uint32_t size);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __FS_UTILS_H_
|
|
@ -16,11 +16,11 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <gui/GuiImageAsync.h>
|
#include <gui/GuiImageAsync.h>
|
||||||
#include "fs/FSUtils.h"
|
#include "../fs/CFile.hpp"
|
||||||
|
|
||||||
std::vector<GuiImageAsync *> GuiImageAsync::imageQueue;
|
std::vector<GuiImageAsync *> GuiImageAsync::imageQueue;
|
||||||
CThread * GuiImageAsync::pThread = NULL;
|
CThread * GuiImageAsync::pThread = NULL;
|
||||||
CMutex * GuiImageAsync::pMutex = NULL;
|
std::recursive_mutex * GuiImageAsync::pMutex = NULL;
|
||||||
uint32_t GuiImageAsync::threadRefCounter = 0;
|
uint32_t GuiImageAsync::threadRefCounter = 0;
|
||||||
bool GuiImageAsync::bExitRequested = false;
|
bool GuiImageAsync::bExitRequested = false;
|
||||||
GuiImageAsync * GuiImageAsync::pInUse = NULL;
|
GuiImageAsync * GuiImageAsync::pInUse = NULL;
|
||||||
@ -98,10 +98,35 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
|
|||||||
pInUse->imgData = new GuiImageData(pInUse->imgBuffer, pInUse->imgBufferSize);
|
pInUse->imgData = new GuiImageData(pInUse->imgBuffer, pInUse->imgBufferSize);
|
||||||
} else {
|
} else {
|
||||||
uint8_t *buffer = NULL;
|
uint8_t *buffer = NULL;
|
||||||
uint32_t bufferSize = 0;
|
uint64_t bufferSize = 0;
|
||||||
|
|
||||||
int32_t iResult = FSUtils::LoadFileToMem(pInUse->filename.c_str(), &buffer, &bufferSize);
|
CFile file(pInUse->filename, CFile::ReadOnly);
|
||||||
if(iResult > 0) {
|
if(file.isOpen()) {
|
||||||
|
uint64_t filesize = file.size();
|
||||||
|
buffer = (uint8_t *) malloc(filesize);
|
||||||
|
if (buffer != NULL) {
|
||||||
|
uint32_t blocksize = 0x4000;
|
||||||
|
uint32_t done = 0;
|
||||||
|
int32_t readBytes = 0;
|
||||||
|
while(done < filesize) {
|
||||||
|
if(done + blocksize > filesize) {
|
||||||
|
blocksize = filesize - done;
|
||||||
|
}
|
||||||
|
readBytes = file.read(buffer + done, blocksize);
|
||||||
|
if(readBytes <= 0)
|
||||||
|
break;
|
||||||
|
done += readBytes;
|
||||||
|
}
|
||||||
|
if(done == filesize){
|
||||||
|
bufferSize = filesize;
|
||||||
|
}else{
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buffer != NULL && bufferSize > 0) {
|
||||||
pInUse->imgData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
pInUse->imgData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
||||||
|
|
||||||
//! free original image buffer which is converted to texture now and not needed anymore
|
//! free original image buffer which is converted to texture now and not needed anymore
|
||||||
@ -128,7 +153,7 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg) {
|
|||||||
void GuiImageAsync::threadInit() {
|
void GuiImageAsync::threadInit() {
|
||||||
if (pThread == NULL) {
|
if (pThread == NULL) {
|
||||||
bExitRequested = false;
|
bExitRequested = false;
|
||||||
pMutex = new CMutex();
|
pMutex = new std::recursive_mutex();
|
||||||
pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10);
|
pThread = CThread::create(GuiImageAsync::guiImageAsyncThread, NULL, CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 10);
|
||||||
pThread->resumeThread();
|
pThread->resumeThread();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gui/GuiImageData.h>
|
#include <gui/GuiImageData.h>
|
||||||
#include <system/memory.h>
|
#include <gui/memory.h>
|
||||||
/**
|
/**
|
||||||
* Constructor for the GuiImageData class.
|
* Constructor for the GuiImageData class.
|
||||||
*/
|
*/
|
||||||
|
185
source/system/memory.c
Normal file
185
source/system/memory.c
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <coreinit/memheap.h>
|
||||||
|
#include <coreinit/memfrmheap.h>
|
||||||
|
#include <coreinit/memexpheap.h>
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
#define MEMORY_ARENA_1 0
|
||||||
|
#define MEMORY_ARENA_2 1
|
||||||
|
#define MEMORY_ARENA_3 2
|
||||||
|
#define MEMORY_ARENA_4 3
|
||||||
|
#define MEMORY_ARENA_5 4
|
||||||
|
#define MEMORY_ARENA_6 5
|
||||||
|
#define MEMORY_ARENA_7 6
|
||||||
|
#define MEMORY_ARENA_8 7
|
||||||
|
#define MEMORY_ARENA_FG_BUCKET 8
|
||||||
|
|
||||||
|
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//! Memory functions
|
||||||
|
//! This is the only place where those are needed so lets keep them more or less private
|
||||||
|
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
static MEMHeapHandle mem1_heap = NULL;
|
||||||
|
static MEMHeapHandle bucket_heap = NULL;
|
||||||
|
|
||||||
|
void libgui_memoryInitialize(void) {
|
||||||
|
if(!mem1_heap) {
|
||||||
|
MEMHeapHandle mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1);
|
||||||
|
uint32_t mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4);
|
||||||
|
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
|
||||||
|
if(mem1_memory)
|
||||||
|
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!bucket_heap) {
|
||||||
|
MEMHeapHandle bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET);
|
||||||
|
uint32_t bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4);
|
||||||
|
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
|
||||||
|
if(bucket_memory)
|
||||||
|
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void libgui_memoryRelease(void) {
|
||||||
|
if(mem1_heap) {
|
||||||
|
MEMDestroyExpHeap(mem1_heap);
|
||||||
|
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3);
|
||||||
|
mem1_heap = NULL;
|
||||||
|
}
|
||||||
|
if(bucket_heap) {
|
||||||
|
MEMDestroyExpHeap(bucket_heap);
|
||||||
|
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3);
|
||||||
|
bucket_heap = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
//! wraps
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
void *__wrap_malloc(size_t size)
|
||||||
|
{
|
||||||
|
// pointer to a function resolve
|
||||||
|
return ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap_memalign(size_t align, size_t size)
|
||||||
|
{
|
||||||
|
if (align < 4)
|
||||||
|
align = 4;
|
||||||
|
|
||||||
|
// pointer to a function resolve
|
||||||
|
return ((void * (*)(size_t, size_t))(*pMEMAllocFromDefaultHeapEx))(size, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __wrap_free(void *p)
|
||||||
|
{
|
||||||
|
// pointer to a function resolve
|
||||||
|
if(p != 0)
|
||||||
|
((void (*)(void *))(*pMEMFreeToDefaultHeap))(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap_calloc(size_t n, size_t size)
|
||||||
|
{
|
||||||
|
void *p = __wrap_malloc(n * size);
|
||||||
|
if (p != 0) {
|
||||||
|
memset(p, 0, n * size);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t __wrap_malloc_usable_size(void *p)
|
||||||
|
{
|
||||||
|
//! TODO: this is totally wrong and needs to be addressed
|
||||||
|
return 0x7FFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap_realloc(void *p, size_t size)
|
||||||
|
{
|
||||||
|
void *new_ptr = __wrap_malloc(size);
|
||||||
|
if (new_ptr != 0)
|
||||||
|
{
|
||||||
|
memcpy(new_ptr, p, __wrap_malloc_usable_size(p) < size ? __wrap_malloc_usable_size(p) : size);
|
||||||
|
__wrap_free(p);
|
||||||
|
}
|
||||||
|
return new_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
//! reent versions
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
void *__wrap__malloc_r(struct _reent *r, size_t size)
|
||||||
|
{
|
||||||
|
return __wrap_malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap__calloc_r(struct _reent *r, size_t n, size_t size)
|
||||||
|
{
|
||||||
|
return __wrap_calloc(n, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap__memalign_r(struct _reent *r, size_t align, size_t size)
|
||||||
|
{
|
||||||
|
return __wrap_memalign(align, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __wrap__free_r(struct _reent *r, void *p)
|
||||||
|
{
|
||||||
|
__wrap_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t __wrap__malloc_usable_size_r(struct _reent *r, void *p)
|
||||||
|
{
|
||||||
|
return __wrap_malloc_usable_size(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__wrap__realloc_r(struct _reent *r, void *p, size_t size)
|
||||||
|
{
|
||||||
|
return __wrap_realloc(p, size);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
//! some wrappers
|
||||||
|
//!-------------------------------------------------------------------------------------------
|
||||||
|
void * MEM2_alloc(uint32_t size, uint32_t align) {
|
||||||
|
return memalign(align, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MEM2_free(void *ptr) {
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * MEM1_alloc(uint32_t size, uint32_t align) {
|
||||||
|
if (align < 4)
|
||||||
|
align = 4;
|
||||||
|
return MEMAllocFromExpHeapEx(mem1_heap, size, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MEM1_free(void *ptr) {
|
||||||
|
MEMFreeToExpHeap(mem1_heap, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * MEMBucket_alloc(uint32_t size, uint32_t align) {
|
||||||
|
if (align < 4)
|
||||||
|
align = 4;
|
||||||
|
return MEMAllocFromExpHeapEx(bucket_heap, size, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MEMBucket_free(void *ptr) {
|
||||||
|
MEMFreeToExpHeap(bucket_heap, ptr);
|
||||||
|
}
|
@ -17,7 +17,7 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gui/video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include "system/memory.h"
|
#include <gui/memory.h>
|
||||||
#include <gui/video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
#include <gui/video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
#include <gui/video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
@ -239,6 +239,7 @@ CVideo::~CVideo() {
|
|||||||
ColorShader::destroyInstance();
|
ColorShader::destroyInstance();
|
||||||
FXAAShader::destroyInstance();
|
FXAAShader::destroyInstance();
|
||||||
Shader3D::destroyInstance();
|
Shader3D::destroyInstance();
|
||||||
|
ShaderFractalColor::destroyInstance();
|
||||||
Texture2DShader::destroyInstance();
|
Texture2DShader::destroyInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user