Skip to content

Commit

Permalink
removed 'libxbr-standalone' dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
CommonLoon102 committed Apr 20, 2021
1 parent b69ba4a commit 8ff3f25
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 91 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "3p/libxbr-standalone"]
path = 3p/libxbr-standalone
url = https://github.com/Treeki/libxbr-standalone.git
ignore = dirty
[submodule "3p/vcpkg"]
path = 3p/vcpkg
url = https://github.com/microsoft/vcpkg.git
Expand Down
1 change: 0 additions & 1 deletion 3p/libxbr-standalone
Submodule libxbr-standalone deleted from 3835e9
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include_directories(
${SDL2_INCLUDE_DIRS}
)

file(GLOB SRC *.cpp 3p/inih/ini.c 3p/libxbr-standalone/xbr.c)
file(GLOB SRC *.cpp)
list(FILTER SRC EXCLUDE REGEX ".*android.cpp|system_psp.cpp|system_wii.cpp")
add_executable(${CMAKE_PROJECT_NAME}
${SRC}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ SRCS = andy.cpp benchmark.cpp fileio.cpp fs_posix.cpp game.cpp \

SCALERS := scaler_nearest.cpp scaler_xbr.cpp

OBJS = $(SRCS:.cpp=.o) $(SCALERS:.cpp=.o) 3p/libxbr-standalone/xbr.o
DEPS = $(SRCS:.cpp=.d) $(SCALERS:.cpp=.d) 3p/libxbr-standalone/xbr.d
OBJS = $(SRCS:.cpp=.o) $(SCALERS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d) $(SCALERS:.cpp=.d)

all: hode

Expand Down
6 changes: 4 additions & 2 deletions scaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

#include "intern.h"

typedef void (*ScaleProc32)(int factor, uint32_t *dst, int dstPitch, const uint32_t *src, int srcPitch, int w, int h);
typedef void (*PaletteProc)(const uint32_t *palette);
typedef void (*ScaleProc)(uint32_t *dst, int dstPitch, const uint8_t *src, int srcPitch, int w, int h, const uint32_t *palette);

struct Scaler {
const char *name;
int factorMin, factorMax;
ScaleProc32 scale;
PaletteProc palette;
ScaleProc scale[3];
};

extern const Scaler scaler_nearest;
Expand Down
50 changes: 15 additions & 35 deletions scaler_nearest.cpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@

#include "scaler.h"

static void scale_nearest(int factor, uint32_t *dst, int dstPitch, const uint32_t *src, int srcPitch, int w, int h) {
switch (factor) {
case 2:
while (h--) {
uint32_t *p = dst;
for (int i = 0; i < w; ++i, p += 2) {
uint32_t c = *(src + i);
*(p) = c;
*(p + 1) = c;
*(p + dstPitch) = c;
*(p + dstPitch + 1) = c;
template <int N>
static void scale_nearest(uint32_t *dst, int dstPitch, const uint8_t *src, int srcPitch, int w, int h, const uint32_t *palette) {
while (h--) {
uint32_t *p = dst;
for (int i = 0; i < w; ++i, p += N) {
const uint32_t c = palette[src[i]];
for (int j = 0; j < N; ++j) {
for (int k = 0; k < N; ++k) {
*(p + j * dstPitch + k) = c;
}
}
dst += dstPitch * 2;
src += srcPitch;
}
break;
case 3:
while (h--) {
uint32_t *p = dst;
for (int i = 0; i < w; ++i, p += 3) {
uint32_t c = *(src + i);
*(p) = c;
*(p + 1) = c;
*(p + 2) = c;
*(p + dstPitch) = c;
*(p + dstPitch + 1) = c;
*(p + dstPitch + 2) = c;
*(p + 2 * dstPitch) = c;
*(p + 2 * dstPitch + 1) = c;
*(p + 2 * dstPitch + 2) = c;
}
dst += dstPitch * 3;
src += srcPitch;
}
break;
dst += dstPitch * N;
src += srcPitch;
}
}

const Scaler scaler_nearest = {
"nearest",
2, 3,
scale_nearest
2, 4,
0,
{ scale_nearest<2>, scale_nearest<3>, scale_nearest<4> }
};
Loading

0 comments on commit 8ff3f25

Please sign in to comment.