From 263e26ceb950f6a61aee3007f815267d03fb9ded Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 2 Nov 2025 20:42:06 +0000 Subject: [PATCH] some redesign git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@572 b9cfdab3-6d41-4d17-bbe4-086880011989 --- .gitattributes | 2 - BorMakefile | 7 +- CMakeLists.txt | 1 - GNUmakefile | 4 - NTMakefile | 7 +- README.txt | 2 - WatMakefile | 13 +-- examples/basic/color_picker.c | 2 +- include/Mw/BaseTypes.h | 2 +- include/Mw/LowLevel.h | 2 +- include/Mw/LowLevelMath.h | 134 ----------------------- include/Mw/StringDefs.h | 28 ++--- src/backend/gdi.c | 73 ++++++++----- src/backend/gdi.h | 9 +- src/backend/x11.c | 28 ++--- src/backend/x11.h | 3 +- src/color_picker/color_picker.c | 17 ++- src/color_picker/color_picker.h | 26 ++--- src/draw.c | 2 +- src/math/default.c | 112 ------------------- src/math/math.c | 186 -------------------------------- src/math/math_internal.h | 43 -------- src/math/mmx.c | 129 ---------------------- tools/genmk.pl | 1 - 24 files changed, 113 insertions(+), 720 deletions(-) delete mode 100644 include/Mw/LowLevelMath.h delete mode 100644 src/math/default.c delete mode 100644 src/math/math.c delete mode 100644 src/math/math_internal.h delete mode 100644 src/math/mmx.c diff --git a/.gitattributes b/.gitattributes index 43d16e6..b43059c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,8 +9,6 @@ /external/libpng/include/*.h linguist-generated /external/libpng/src/*.c linguist-generated /external/libpng/src/*.h linguist-generated -/external/fdlibm/src/*.c linguist-generated -/external/fdlibm/src/*.h linguist-generated /resource/doxygen-theme/* linguist-generated /src/icon/*.c linguist-generated /src/font/*.c linguist-generated diff --git a/BorMakefile b/BorMakefile index 5829e8f..0e2a70f 100644 --- a/BorMakefile +++ b/BorMakefile @@ -61,15 +61,12 @@ clean: del /f /q src\font\ttf.obj del /f /q src\font\boldfont.obj del /f /q src\font\font.obj - del /f /q src\math\default.obj - del /f /q src\math\math.obj - del /f /q src\math\mmx.obj del /f /q src\color_picker\color_picker.obj del /f /q src\backend\gdi.obj del /f /q src\Mw.dll -src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\color_picker\color_picker.obj src\backend\gdi.obj - $(LD) $(LDFLAGS) -e$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\color_picker\color_picker.obj src\backend\gdi.obj -lopengl32.lib -lgdi32.lib -luser32.lib +src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\color_picker\color_picker.obj src\backend\gdi.obj + $(LD) $(LDFLAGS) -e$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\color_picker\color_picker.obj src\backend\gdi.obj -lopengl32.lib -lgdi32.lib -luser32.lib implib src\Mw.lib src\Mw.dll .c.obj: diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f5ace3..4480797 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ option(BUILD_EXAMPLES "Build examples" OFF) option(USE_STB_IMAGE "Use stb_image" ON) option(USE_STB_TRUETYPE "Use stb_truetype" OFF) option(USE_FREETYPE2 "Use FreeType 2" ON) -option(USE_FDLIBM "Use fdlibm" OFF) file( GLOB diff --git a/GNUmakefile b/GNUmakefile index 1394a24..7c80014 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -42,7 +42,6 @@ include mk/stb.mk include mk/freetype2.mk include mk/opengl.mk include mk/vulkan.mk -include mk/math.mk .PHONY: all install format clean lib examples @@ -76,9 +75,6 @@ examples/gldemos/%$(EXEC): examples/gldemos/%.o src/$(LIB)Mw$(SO) examples/%$(EXEC): examples/%.o src/$(LIB)Mw$(SO) $(CC) $(E_LDFLAGS) -o $@ $< $(E_LIBS) -src/math/mmx.o: src/math/mmx.c - $(CC) $(L_CFLAGS) -mmmx -c -o $@ $< - src/%.o: src/%.c $(CC) $(L_CFLAGS) -c -o $@ $< diff --git a/NTMakefile b/NTMakefile index bb2796f..61f49eb 100644 --- a/NTMakefile +++ b/NTMakefile @@ -61,15 +61,12 @@ clean: del /f /q src\font\ttf.obj del /f /q src\font\boldfont.obj del /f /q src\font\font.obj - del /f /q src\math\default.obj - del /f /q src\math\math.obj - del /f /q src\math\mmx.obj del /f /q src\color_picker\color_picker.obj del /f /q src\backend\gdi.obj del /f /q src\Mw.dll -src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\color_picker\color_picker.obj src\backend\gdi.obj - $(LD) $(LDFLAGS) /OUT:$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\color_picker\color_picker.obj src\backend\gdi.obj opengl32.lib gdi32.lib user32.lib +src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\color_picker\color_picker.obj src\backend\gdi.obj + $(LD) $(LDFLAGS) /OUT:$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\color_picker\color_picker.obj src\backend\gdi.obj opengl32.lib gdi32.lib user32.lib .c.obj: diff --git a/README.txt b/README.txt index fb668c2..1a3868e 100644 --- a/README.txt +++ b/README.txt @@ -88,8 +88,6 @@ D. MinGW-w64/GCC/Clang USE_FREETYPE2 - Use FreeType2 or not. - USE_FDLIBM - Use fdlibm or not. - PREFIX - Installation destination directory. diff --git a/WatMakefile b/WatMakefile index d68c4d5..c5f2899 100644 --- a/WatMakefile +++ b/WatMakefile @@ -60,15 +60,12 @@ clean: .SYMBOLIC %erase src/font/ttf.obj %erase src/font/boldfont.obj %erase src/font/font.obj - %erase src/math/default.obj - %erase src/math/math.obj - %erase src/math/mmx.obj %erase src/color_picker/color_picker.obj %erase src/backend/gdi.obj %erase src/Mw.dll -src/Mw.dll: src/core.obj src/text.obj src/string.obj src/draw.obj src/default.obj src/filechooser.obj src/lowlevel.obj src/error.obj src/unicode.obj src/color.obj src/directory.obj src/messagebox.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/icon/info.obj src/icon/note.obj src/icon/warning.obj src/icon/error.obj src/icon/news.obj src/icon/directory.obj src/icon/file.obj src/icon/back.obj src/icon/forward.obj src/icon/up.obj src/icon/computer.obj src/icon/search.obj src/icon/down.obj src/icon/left.obj src/icon/right.obj src/cursor/default.obj src/cursor/cross.obj src/cursor/text.obj src/cursor/hidden.obj src/widget/button.obj src/widget/frame.obj src/widget/opengl.obj src/widget/window.obj src/widget/menu.obj src/widget/entry.obj src/widget/submenu.obj src/widget/viewport.obj src/widget/image.obj src/widget/scrollbar.obj src/widget/checkbox.obj src/widget/label.obj src/widget/listbox.obj src/widget/numberentry.obj src/widget/progressbar.obj src/widget/radiobox.obj src/font/boldttf.obj src/font/ttf.obj src/font/boldfont.obj src/font/font.obj src/math/default.obj src/math/math.obj src/math/mmx.obj src/color_picker/color_picker.obj src/backend/gdi.obj - $(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file src/core.obj file src/text.obj file src/string.obj file src/draw.obj file src/default.obj file src/filechooser.obj file src/lowlevel.obj file src/error.obj file src/unicode.obj file src/color.obj file src/directory.obj file src/messagebox.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/icon/info.obj file src/icon/note.obj file src/icon/warning.obj file src/icon/error.obj file src/icon/news.obj file src/icon/directory.obj file src/icon/file.obj file src/icon/back.obj file src/icon/forward.obj file src/icon/up.obj file src/icon/computer.obj file src/icon/search.obj file src/icon/down.obj file src/icon/left.obj file src/icon/right.obj file src/cursor/default.obj file src/cursor/cross.obj file src/cursor/text.obj file src/cursor/hidden.obj file src/widget/button.obj file src/widget/frame.obj file src/widget/opengl.obj file src/widget/window.obj file src/widget/menu.obj file src/widget/entry.obj file src/widget/submenu.obj file src/widget/viewport.obj file src/widget/image.obj file src/widget/scrollbar.obj file src/widget/checkbox.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/numberentry.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/font/boldttf.obj file src/font/ttf.obj file src/font/boldfont.obj file src/font/font.obj file src/math/default.obj file src/math/math.obj file src/math/mmx.obj file src/color_picker/color_picker.obj file src/backend/gdi.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib +src/Mw.dll: src/core.obj src/text.obj src/string.obj src/draw.obj src/default.obj src/filechooser.obj src/lowlevel.obj src/error.obj src/unicode.obj src/color.obj src/directory.obj src/messagebox.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/icon/info.obj src/icon/note.obj src/icon/warning.obj src/icon/error.obj src/icon/news.obj src/icon/directory.obj src/icon/file.obj src/icon/back.obj src/icon/forward.obj src/icon/up.obj src/icon/computer.obj src/icon/search.obj src/icon/down.obj src/icon/left.obj src/icon/right.obj src/cursor/default.obj src/cursor/cross.obj src/cursor/text.obj src/cursor/hidden.obj src/widget/button.obj src/widget/frame.obj src/widget/opengl.obj src/widget/window.obj src/widget/menu.obj src/widget/entry.obj src/widget/submenu.obj src/widget/viewport.obj src/widget/image.obj src/widget/scrollbar.obj src/widget/checkbox.obj src/widget/label.obj src/widget/listbox.obj src/widget/numberentry.obj src/widget/progressbar.obj src/widget/radiobox.obj src/font/boldttf.obj src/font/ttf.obj src/font/boldfont.obj src/font/font.obj src/color_picker/color_picker.obj src/backend/gdi.obj + $(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file src/core.obj file src/text.obj file src/string.obj file src/draw.obj file src/default.obj file src/filechooser.obj file src/lowlevel.obj file src/error.obj file src/unicode.obj file src/color.obj file src/directory.obj file src/messagebox.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/icon/info.obj file src/icon/note.obj file src/icon/warning.obj file src/icon/error.obj file src/icon/news.obj file src/icon/directory.obj file src/icon/file.obj file src/icon/back.obj file src/icon/forward.obj file src/icon/up.obj file src/icon/computer.obj file src/icon/search.obj file src/icon/down.obj file src/icon/left.obj file src/icon/right.obj file src/cursor/default.obj file src/cursor/cross.obj file src/cursor/text.obj file src/cursor/hidden.obj file src/widget/button.obj file src/widget/frame.obj file src/widget/opengl.obj file src/widget/window.obj file src/widget/menu.obj file src/widget/entry.obj file src/widget/submenu.obj file src/widget/viewport.obj file src/widget/image.obj file src/widget/scrollbar.obj file src/widget/checkbox.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/numberentry.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/font/boldttf.obj file src/font/ttf.obj file src/font/boldfont.obj file src/font/font.obj file src/color_picker/color_picker.obj file src/backend/gdi.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib @@ -180,12 +177,6 @@ src/font/boldfont.obj: src/font/boldfont.c $(CC) $(CFLAGS) -fo=$@ $< src/font/font.obj: src/font/font.c $(CC) $(CFLAGS) -fo=$@ $< -src/math/default.obj: src/math/default.c - $(CC) $(CFLAGS) -fo=$@ $< -src/math/math.obj: src/math/math.c - $(CC) $(CFLAGS) -fo=$@ $< -src/math/mmx.obj: src/math/mmx.c - $(CC) $(CFLAGS) -fo=$@ $< src/color_picker/color_picker.obj: src/color_picker/color_picker.c $(CC) $(CFLAGS) -fo=$@ $< src/backend/gdi.obj: src/backend/gdi.c diff --git a/examples/basic/color_picker.c b/examples/basic/color_picker.c index 0e8b41d..c71c620 100644 --- a/examples/basic/color_picker.c +++ b/examples/basic/color_picker.c @@ -7,7 +7,7 @@ MwWidget window; MwWidget button; void color_callback(MwWidget handle, void* user_data, void* call_data) { - char hexColor[8]; + char hexColor[8]; MwRGB* rgb = call_data; (void)handle; diff --git a/include/Mw/BaseTypes.h b/include/Mw/BaseTypes.h index 2917a63..0e5fd0f 100644 --- a/include/Mw/BaseTypes.h +++ b/include/Mw/BaseTypes.h @@ -11,7 +11,7 @@ typedef struct _MwRect MwRect; typedef struct _MwSizeHints MwSizeHints; typedef struct _MwFont MwFont; typedef struct _MwCursor MwCursor; -typedef struct _MwRGB MwRGB; +typedef struct _MwRGB MwRGB; typedef unsigned char MwBool; #define MwTRUE ((MwBool)1) diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 49ce7cb..86c43d6 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -106,7 +106,7 @@ MWDECL void MwLLNextEvent(MwLL handle); MWDECL void MwLLSleep(int ms); MWDECL MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height); -MWDECL void MwLLPixmapUpdate(MwLL handle, MwLLPixmap pixmap); +MWDECL void MwLLPixmapUpdate(MwLLPixmap pixmap); MWDECL void MwLLDestroyPixmap(MwLLPixmap pixmap); MWDECL void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap); MWDECL void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap); diff --git a/include/Mw/LowLevelMath.h b/include/Mw/LowLevelMath.h deleted file mode 100644 index 84844e9..0000000 --- a/include/Mw/LowLevelMath.h +++ /dev/null @@ -1,134 +0,0 @@ -/* $Id$ */ -/*! - * @file Mw/LowLevelMath.h - * @brief A few portable functions for simultaneously supporting SIMD and not supporting it - * @warning This is mostly used internally. Anything undocumented, and/or anything with an _ prefix (that doesn't have a corresponding typedef) should be avoided. - */ - -#ifndef __MW_LOWLEVEL_MATH_H__ -#define __MW_LOWLEVEL_MATH_H__ - -#include -#include - -#if defined(__i386__) || defined(__x86_64__) || defined(__WATCOMC__) -#define MwLLMath_x86 -#endif - -/*! - * @brief SIMD vector - */ -typedef struct _MwLLVec MwLLVec; - -/*! - * @brief SIMD vector type - * @warning Not exhaustive, enums subject to be added later. - */ -enum MwLLVecType { - MwLLVecTypeU8 = 0, - MwLLVecTypeU16, - MwLLVecTypeU32, - MwLLVecTypeU64, - MwLLVecTypeI8, - MwLLVecTypeI16, - MwLLVecTypeI32, - MwLLVecTypeI64, - - MwLLVecType_Max, -}; - -/*! - * @brief Create a SIMD Vector (variadic) - * @warning Prefer using the macro version. - */ -MWDECL MwLLVec* MwLLVaVecCreate(int ty, MwU64 size, ...); - -/*! - * @brief Destroy the given SIMD Vector - */ -MWDECL void MwLLVecDestroy(MwLLVec* vec); - -/*! - * @brief index the given SIMD Vector (u8) - */ -MWDECL MwU8 MwLLVecIndexU8(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (u16) - */ -MWDECL MwU16 MwLLVecIndexU16(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (u32) - */ -MWDECL MwU32 MwLLVecIndexU32(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (u64) - */ -MWDECL MwU64 MwLLVecIndexU64(MwLLVec* vec, MwU64 index); - -/*! - * @brief index the given SIMD Vector (i8) - */ -MWDECL MwI8 MwLLVecIndexI8(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (i16) - */ -MWDECL MwI16 MwLLVecIndexI16(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (i32) - */ -MWDECL MwI32 MwLLVecIndexI32(MwLLVec* vec, MwU64 index); -/*! - * @brief index the given SIMD Vector (i64) - */ -MWDECL MwI64 MwLLVecIndexI64(MwLLVec* vec, MwU64 index); - -/*! - * @brief SIMD Vector add - */ -MWDECL void MwLLMathAdd(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector multiply - */ -MWDECL void MwLLMathMultiply(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector subtract - */ -MWDECL void MwLLMathSub(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector reciprocal - */ -MWDECL void MwLLMathReciprocal(MwLLVec* a, MwLLVec* out); -/*! - * @brief SIMD Vector square root - */ -MWDECL void MwLLMathSquareRoot(MwLLVec* a, MwLLVec* out); -/*! - * @brief SIMD Vector bitwise and - */ -MWDECL void MwLLMathAnd(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector bitwise or - */ -MWDECL void MwLLMathOr(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector bitwise shift right - */ -MWDECL void MwLLMathShiftRight(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector bitwise shift left - */ -MWDECL void MwLLMathShiftLeft(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector bitwise equal - */ -MWDECL void MwLLMathEqual(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector greater then - */ -MWDECL void MwLLMathGreaterThen(MwLLVec* a, MwLLVec* b, MwLLVec* out); -/*! - * @brief SIMD Vector lesser then - */ -MWDECL void MwLLMathLesserThen(MwLLVec* a, MwLLVec* b, MwLLVec* out); - -#endif diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index 83a5abc..f180d2e 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -39,20 +39,20 @@ #define MwNfont "Vfont" #define MwNboldFont "VboldFont" -#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox) */ -#define MwNresizeHandler "Cresize" /* NULL */ -#define MwNtickHandler "Ctick" /* NULL */ -#define MwNmenuHandler "Cmenu" /* MwMenu */ -#define MwNmouseDownHandler "CmouseDown" /* MwLLMouse* */ -#define MwNmouseUpHandler "CmouseUp" /* same as MwNmouseDownHandler */ -#define MwNmouseMoveHandler "CmouseMove" /* MwPoint* */ -#define MwNchangedHandler "Cchanged" /* NULL */ -#define MwNkeyHandler "Ckey" /* int* (MwLLKeyEnum or character code) */ -#define MwNkeyReleaseHandler "CkeyRelease" /* same as MwNkeyHandler */ -#define MwNcloseHandler "Cclose" /* NULL */ -#define MwNfocusInHandler "CfocusIn" /* NULL */ -#define MwNfocusOutHandler "CfocusOut" /* NULL */ -#define MwNfileChosenHandler "CfileChosen" /* char* */ +#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox) */ +#define MwNresizeHandler "Cresize" /* NULL */ +#define MwNtickHandler "Ctick" /* NULL */ +#define MwNmenuHandler "Cmenu" /* MwMenu */ +#define MwNmouseDownHandler "CmouseDown" /* MwLLMouse* */ +#define MwNmouseUpHandler "CmouseUp" /* same as MwNmouseDownHandler */ +#define MwNmouseMoveHandler "CmouseMove" /* MwPoint* */ +#define MwNchangedHandler "Cchanged" /* NULL */ +#define MwNkeyHandler "Ckey" /* int* (MwLLKeyEnum or character code) */ +#define MwNkeyReleaseHandler "CkeyRelease" /* same as MwNkeyHandler */ +#define MwNcloseHandler "Cclose" /* NULL */ +#define MwNfocusInHandler "CfocusIn" /* NULL */ +#define MwNfocusOutHandler "CfocusOut" /* NULL */ +#define MwNfileChosenHandler "CfileChosen" /* char* */ #define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */ #endif diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 96e61a7..9d403ea 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -281,8 +281,17 @@ void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) { } MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { - MwLLColor c = malloc(sizeof(*c)); - HDC dc = GetDC(handle->hWnd); + MwLLColor c = malloc(sizeof(*c)); + + c->brush = NULL; + + MwLLColorUpdate(handle, c, r, g, b); + + return c; +} + +void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) { + HDC dc = GetDC(handle->hWnd); if(r > 255) r = 255; if(g > 255) g = 255; @@ -291,14 +300,13 @@ MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { if(g < 0) g = 0; if(b < 0) b = 0; + if(c->brush != NULL) DeleteObject(c->brush); c->brush = CreateSolidBrush(GetNearestColor(dc, RGB(r, g, b))); c->red = r; c->green = g; c->blue = b; ReleaseDC(handle->hWnd, dc); - - return c; } void MwLLFreeColor(MwLLColor color) { @@ -366,16 +374,9 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei MwLLPixmap r = malloc(sizeof(*r)); HDC dc = GetDC(handle->hWnd); BITMAPINFOHEADER bmih; - RGBQUAD* quad; - int y, x; - int w = (width + (16 - (width % 16))) / 8; - WORD* words; - WORD* words2; - if(16 * (width / 16) == width) w -= 2; - - words = malloc(w * height); - words2 = malloc(w * height); + r->data_buffer = malloc(width * height * 4); + memcpy(r->data_buffer, data, 4 * width * height); r->width = width; r->height = height; @@ -392,16 +393,36 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei bmih.biClrUsed = 0; bmih.biClrImportant = 0; - r->hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&quad, NULL, (DWORD)0); + r->hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&r->quad, NULL, (DWORD)0); - memset(words, 0, w * height); - memset(words2, 0, w * height); - for(y = 0; y < height; y++) { + r->hMask = NULL; + r->hMask2 = NULL; + + ReleaseDC(handle->hWnd, dc); + + MwLLPixmapUpdate(r); + + return r; +} + +void MwLLPixmapUpdate(MwLLPixmap r) { + int y, x; + int w = (r->width + (16 - (r->width % 16))) / 8; + WORD* words; + WORD* words2; + + if(16 * (r->width / 16) == r->width) w -= 2; + + words = malloc(w * r->height); + words2 = malloc(w * r->height); + memset(words, 0, w * r->height); + memset(words2, 0, w * r->height); + for(y = 0; y < r->height; y++) { BYTE* l = (BYTE*)&words[y * (w / 2)]; BYTE* l2 = (BYTE*)&words2[y * (w / 2)]; - for(x = 0; x < width; x++) { - RGBQUAD* q = &quad[y * width + x]; - unsigned char* px = &data[(y * width + x) * 4]; + for(x = 0; x < r->width; x++) { + RGBQUAD* q = &r->quad[y * r->width + x]; + unsigned char* px = &r->data_buffer[(y * r->width + x) * 4]; q->rgbRed = px[0]; q->rgbGreen = px[1]; @@ -415,18 +436,18 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei } } - r->hMask = CreateBitmap(width, height, 1, 1, words); - r->hMask2 = CreateBitmap(width, height, 1, 1, words2); + if(r->hMask != NULL) DeleteObject(r->hMask); + if(r->hMask2 != NULL) DeleteObject(r->hMask2); + + r->hMask = CreateBitmap(r->width, r->height, 1, 1, words); + r->hMask2 = CreateBitmap(r->width, r->height, 1, 1, words2); free(words); free(words2); - - ReleaseDC(handle->hWnd, dc); - - return r; } void MwLLDestroyPixmap(MwLLPixmap pixmap) { + free(pixmap->data_buffer); DeleteObject(pixmap->hMask); DeleteObject(pixmap->hMask2); DeleteObject(pixmap->hBitmap); diff --git a/src/backend/gdi.h b/src/backend/gdi.h index e01aec1..46f7697 100644 --- a/src/backend/gdi.h +++ b/src/backend/gdi.h @@ -45,11 +45,12 @@ struct _MwLLColor { struct _MwLLPixmap { int width; int height; - unsigned char* data_scratch_buf; + unsigned char* data_buffer; - HBITMAP hBitmap; - HBITMAP hMask; - HBITMAP hMask2; + RGBQUAD* quad; + HBITMAP hBitmap; + HBITMAP hMask; + HBITMAP hMask2; }; #endif diff --git a/src/backend/x11.c b/src/backend/x11.c index 6d26caa..64eaa7b 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -437,8 +437,8 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei int evbase, erbase; XWindowAttributes attr; - r->data_buf = malloc(sizeof(unsigned long) * width * height); - memcpy(r->data_buf, data, sizeof(unsigned long) * width * height); + r->data_buffer = malloc(4 * width * height); + memcpy(r->data_buffer, data, 4 * width * height); XGetWindowAttributes(handle->display, handle->window, &attr); @@ -447,25 +447,26 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei r->height = height; r->display = handle->display; r->data = malloc(sizeof(unsigned long) * width * height); + r->handle = handle; r->use_render = XRenderQueryExtension(handle->display, &evbase, &erbase) ? 1 : 0; r->image = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), r->depth, ZPixmap, 0, di, width, height, 32, width * 4); r->mask = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 1, ZPixmap, 0, dm, width, height, 32, width * 4); - MwLLPixmapUpdate(handle, r); + MwLLPixmapUpdate(r); return r; } -void MwLLPixmapUpdate(MwLL handle, MwLLPixmap r) { - int y, x; +void MwLLPixmapUpdate(MwLLPixmap r) { + int y, x; for(y = 0; y < r->height; y++) { for(x = 0; x < r->width; x++) { - unsigned char* px = &r->data_buf[(y * r->width + x) * 4]; - MwLLColor c = NULL; - unsigned long p; + unsigned char* px = &r->data_buffer[(y * r->width + x) * 4]; + MwLLColor c = NULL; + unsigned long p; - c = MwLLAllocColor(handle, px[0], px[1], px[2]); + c = MwLLAllocColor(r->handle, px[0], px[1], px[2]); p = c->pixel; MwLLFreeColor(c); @@ -486,11 +487,10 @@ void MwLLPixmapUpdate(MwLL handle, MwLLPixmap r) { } void MwLLDestroyPixmap(MwLLPixmap pixmap) { - if(pixmap->image != NULL) { - XDestroyImage(pixmap->image); - XDestroyImage(pixmap->mask); - free(pixmap->data); - } + free(pixmap->data_buf); + XDestroyImage(pixmap->image); + XDestroyImage(pixmap->mask); + free(pixmap->data); free(pixmap); } diff --git a/src/backend/x11.h b/src/backend/x11.h index 5c07641..eed7d45 100644 --- a/src/backend/x11.h +++ b/src/backend/x11.h @@ -55,10 +55,11 @@ struct _MwLLPixmap { int width; int height; unsigned char* data; - unsigned char* data_buf; + unsigned char* data_buffer; int depth; + MwLL handle; int use_render; Display* display; XImage* image; diff --git a/src/color_picker/color_picker.c b/src/color_picker/color_picker.c index 2c84437..e959b67 100644 --- a/src/color_picker/color_picker.c +++ b/src/color_picker/color_picker.c @@ -2,10 +2,9 @@ #include #include "color_picker.h" -#include static void hsv2rgb(MwU32 h, MwU32 s, MwU32 v, MwU32* r, MwU32* g, MwU32* b) { - MwU8 sextant = h >> 8; + MwU8 sextant = h >> 8; MwU16 ww; MwU32 h_fraction, d; @@ -61,12 +60,12 @@ static void hsv2rgb(MwU32 h, MwU32 s, MwU32 v, MwU32* r, MwU32* g, MwU32* b) { } static void color_picker_image_update(color_picker* picker) { - int y, x; + int y, x; for(y = 0; y < PICKER_SIZE; y++) { for(x = 0; x < PICKER_SIZE; x++) { - int i = ((y * PICKER_SIZE) + x) * 4; - int _x = x - (PICKER_SIZE / 2); - int _y = y - (PICKER_SIZE / 2); + int i = ((y * PICKER_SIZE) + x) * 4; + int _x = x - (PICKER_SIZE / 2); + int _y = y - (PICKER_SIZE / 2); double dist; if(picker->dist_table[y][x] == 0) { @@ -81,6 +80,7 @@ static void color_picker_image_update(color_picker* picker) { picker->color_picker_image_data[i + 3] = 0; } else { MwHSV hsv_v; + MwRGB color; if(picker->hue_table[y][x].generated == 0) { double xd = (M_PI / 180.) * ((double)_x); double yd = (M_PI / 180.) * ((double)_y); @@ -100,7 +100,6 @@ static void color_picker_image_update(color_picker* picker) { hsv_v = picker->hue_table[y][x]; hsv_v.v = HSV_VAL_MAX - (picker->value * HSV_VAL_MAX); - MwRGB color; hsv2rgb(hsv_v.h, hsv_v.s, hsv_v.v, &color.red, &color.green, &color.blue); picker->color_picker_image_data[i] = color.red; @@ -137,9 +136,9 @@ static void color_picker_click(MwWidget handle, void* user, void* call) { i = ((mouse->point.y * PICKER_SIZE) + mouse->point.x) * 4; - picker->chosen_color.red = picker->color_picker_image_data[i]; + picker->chosen_color.red = picker->color_picker_image_data[i]; picker->chosen_color.green = picker->color_picker_image_data[i + 1]; - picker->chosen_color.blue = picker->color_picker_image_data[i + 2]; + picker->chosen_color.blue = picker->color_picker_image_data[i + 2]; sprintf(hexColor, "#%02X%02X%02X", picker->chosen_color.red, picker->chosen_color.green, picker->chosen_color.blue); diff --git a/src/color_picker/color_picker.h b/src/color_picker/color_picker.h index 0de7cd4..dd0e705 100644 --- a/src/color_picker/color_picker.h +++ b/src/color_picker/color_picker.h @@ -36,19 +36,19 @@ struct _MwHSV { }; struct _color_picker { - MwWidget parent; - MwWidget color_picker_img; - MwWidget value_slider; - MwWidget color_display; - MwWidget color_display_text; - MwWidget finish; - MwLLPixmap color_picker_pixmap; - double value; - unsigned char* color_picker_image_data; - MwPoint point; - double dist_table[PICKER_SIZE][PICKER_SIZE]; - MwHSV hue_table[PICKER_SIZE][PICKER_SIZE]; - MwRGB chosen_color; + MwWidget parent; + MwWidget color_picker_img; + MwWidget value_slider; + MwWidget color_display; + MwWidget color_display_text; + MwWidget finish; + MwLLPixmap color_picker_pixmap; + double value; + unsigned char* color_picker_image_data; + MwPoint point; + double dist_table[PICKER_SIZE][PICKER_SIZE]; + MwHSV hue_table[PICKER_SIZE][PICKER_SIZE]; + MwRGB chosen_color; }; color_picker* color_picker_setup(MwWidget parent, int w, int h); diff --git a/src/draw.c b/src/draw.c index 989cef3..90979a7 100644 --- a/src/draw.c +++ b/src/draw.c @@ -691,7 +691,7 @@ void MwReloadRaw(MwWidget handle, unsigned char* rgb, int width, int height, MwL if(handle->bgcolor == NULL) MwLLFreeColor(base); - MwLLPixmapUpdate(handle->lowlevel, px); + MwLLPixmapUpdate(px); } void MwGetColor(MwLLColor color, int* red, int* green, int* blue) { diff --git a/src/math/default.c b/src/math/default.c deleted file mode 100644 index 13ca8b0..0000000 --- a/src/math/default.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $Id$ */ -#include -#include "math_internal.h" - -#define MAKE_DEFAULT_TABLE(suffix, ty) \ - static void add_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] + ((ty*)b->buffer)[i]; \ - } \ - }; \ - static void sub_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] - ((ty*)b->buffer)[i]; \ - } \ - }; \ - static void multiply_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] * ((ty*)b->buffer)[i]; \ - } \ - }; \ - static void reciprocal_##suffix(MwLLVec* a, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = pow(((ty*)a->buffer)[i], -1); \ - } \ - }; \ - static void squareRoot_##suffix(MwLLVec* a, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = sqrt(((ty*)a->buffer)[i]); \ - } \ - } \ - static void shiftRight_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] >> ((ty*)b->buffer)[i]; \ - } \ - }; \ - static void shiftLeft_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] << ((ty*)b->buffer)[i]; \ - } \ - } \ - static void equal_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] == ((ty*)b->buffer)[i]; \ - } \ - }; \ - static void greaterThen_##suffix(MwLLVec* a, MwLLVec* b, MwLLVec* out) { \ - int i = 0; \ - for(; i < a->size; i++) { \ - ((ty*)out->buffer)[i] = ((ty*)a->buffer)[i] >= ((ty*)b->buffer)[i]; \ - } \ - }; \ - static MwLLMathVTable table_##suffix = {add_##suffix, multiply_##suffix, sub_##suffix, reciprocal_##suffix, squareRoot_##suffix, NULL, NULL, shiftRight_##suffix, shiftLeft_##suffix, equal_##suffix, greaterThen_##suffix, NULL}; - -MAKE_DEFAULT_TABLE(u8, MwU8); -MAKE_DEFAULT_TABLE(u16, MwU16); -MAKE_DEFAULT_TABLE(u32, MwU32); -MAKE_DEFAULT_TABLE(u64, MwU64); -MAKE_DEFAULT_TABLE(i8, MwI8); -MAKE_DEFAULT_TABLE(i16, MwI16); -MAKE_DEFAULT_TABLE(i32, MwI32); -MAKE_DEFAULT_TABLE(i64, MwI64); - -#if 0 -static MwLLMathVTable* defaultMultiTable[MwLLVecType_Max] = { - &table_u8, /*MwLLVecTypeU8*/ - &table_u16, /*MwLLVecTypeU16*/ - &table_u32, /*MwLLVecTypeU32*/ - &table_u64, /*MwLLVecTypeU64*/ - &table_i8, /*MwLLVecTypeI8*/ - &table_i16, /*MwLLVecTypeI16*/ - &table_i32, /*MwLLVecTypeI32*/ - &table_i64, /*MwLLVecTypeI64*/ -}; -#endif -void default_apply(MwLLVec* v) { - switch(v->ty) { - case MwLLVecTypeU8: - v->vtable = table_u8; - break; - case MwLLVecTypeU16: - v->vtable = table_u16; - break; - case MwLLVecTypeU32: - v->vtable = table_u32; - break; - case MwLLVecTypeU64: - v->vtable = table_u64; - break; - case MwLLVecTypeI8: - v->vtable = table_i8; - break; - case MwLLVecTypeI16: - v->vtable = table_i16; - break; - case MwLLVecTypeI32: - v->vtable = table_i32; - break; - case MwLLVecTypeI64: - v->vtable = table_i64; - break; - case MwLLVecType_Max: - break; - } -} diff --git a/src/math/math.c b/src/math/math.c deleted file mode 100644 index 6a00fd2..0000000 --- a/src/math/math.c +++ /dev/null @@ -1,186 +0,0 @@ -/* $Id$ */ -#include - -#include "math_internal.h" - -#if defined(MwLLMath_x86) -struct x86Features { - MwBool mmx; - MwBool sse2; -}; - -static struct x86Features -getCPUFeatures(void) { - MwU32 _eax = 1; - MwU32 _edx; - struct x86Features features; - -#ifdef __WATCOMC__ - __asm { - mov eax, _eax - cpuid - mov _eax, eax - mov _edx, edx - } -#else - asm volatile( - "cpuid" : "=a"(_eax), "=d"(_edx) - : "a"(1) : "ebx", "ecx"); -#endif - - if(_edx & FEATX86_MMX) { - features.mmx = MwTRUE; - } - if(_edx & FEATX86_SSE2) { - features.sse2 = MwTRUE; - } - return features; -} -#endif - -static int round_multiple(int num, int mul) { - return ((num + mul - 1) / mul) * mul; -} - -MwLLVec* MwLLVaVecCreate(int ty, MwU64 size, ...) { - struct x86Features features = getCPUFeatures(); - MwLLVec* vec = malloc(sizeof(MwLLVec)); - va_list va; - int i = 0; - int size_rounded = size; - - memset(vec, 0, sizeof(MwLLVec)); - - vec->size = size; - -#ifdef MwLLMath_x86 - if(features.mmx) { - size_rounded = round_multiple(size, 64); - } -#endif - - va_start(va, size); - - switch(ty) { - case MwLLVecTypeU8: - case MwLLVecTypeI8: - vec->buffer = malloc(size_rounded * sizeof(MwU8)); - memset(vec->buffer, 0, size_rounded); - for(; i < size; i++) { - ((MwU8*)vec->buffer)[i] = va_arg(va, int); - } - break; - case MwLLVecTypeU16: - case MwLLVecTypeI16: - vec->buffer = malloc(size_rounded * sizeof(MwU16)); - memset(vec->buffer, 0, size_rounded); - for(; i < size; i++) { - ((MwU16*)vec->buffer)[i] = va_arg(va, int); - } - break; - case MwLLVecTypeU32: - case MwLLVecTypeI32: - vec->buffer = malloc(size_rounded * sizeof(MwU32)); - memset(vec->buffer, 0, size_rounded); - for(; i < size; i++) { - ((MwU32*)vec->buffer)[i] = va_arg(va, int); - } - break; - case MwLLVecTypeU64: - case MwLLVecTypeI64: - vec->buffer = malloc(size_rounded * sizeof(MwU64)); - memset(vec->buffer, 0, size_rounded); - for(; i < size; i++) { - ((MwU64*)vec->buffer)[i] = va_arg(va, int); - } - break; - default: - printf("Unknown MwLLVecType %d\n", ty); - break; - } - - va_end(va); - - default_apply(vec); - -#ifdef MwLLMath_x86 - if(features.mmx) { - mmx_apply(vec); - } -#endif - - return vec; -} - -// TODO: Flag for telling debug builds so we can selectively take this out -#define dbg_assert(a) assert(a) - -void MwLLMathAdd(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.add(a, b, out); -} -void MwLLMathSub(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.sub(a, b, out); -} -void MwLLMathMultiply(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.multiply(a, b, out); -} -void MwLLMathReciprocal(MwLLVec* a, MwLLVec* out) { - dbg_assert(a->size == out->size); - a->vtable.reciprocal(a, out); -} -void MwLLMathSquareRoot(MwLLVec* a, MwLLVec* out) { - dbg_assert(a->size == out->size); - a->vtable.squareRoot(a, out); -} - -void MwLLMathShiftRight(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.shiftRight(a, b, out); -} -void MwLLMathShiftLeft(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->ty == b->ty && a->ty == out->ty && b->ty == out->ty); - a->vtable.shiftLeft(a, b, out); -} -void MwLLMathEqual(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); -} -void MwLLMathGreaterThen(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.shiftRight(a, b, out); -} -void MwLLMathAnd(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.and (a, b, out); -} -void MwLLMathOr(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - dbg_assert(a->size == b->size && a->size == out->size && b->size && out->size); - a->vtable.or (a, b, out); -} - -MWDECL MwU8 MwLLVecIndexU8(MwLLVec* vec, MwU64 index) { - return ((MwU8*)vec->buffer)[index]; -}; -MWDECL MwU16 MwLLVecIndexU16(MwLLVec* vec, MwU64 index) { - return ((MwU16*)vec->buffer)[index]; -}; -MWDECL MwU32 MwLLVecIndexU32(MwLLVec* vec, MwU64 index) { - return ((MwU32*)vec->buffer)[index]; -}; -MWDECL MwU64 MwLLVecIndexU64(MwLLVec* vec, MwU64 index) { - return ((MwU64*)vec->buffer)[index]; -}; -MWDECL MwI8 MwLLVecIndexI8(MwLLVec* vec, MwU64 index) { - return ((MwI8*)vec->buffer)[index]; -}; -MWDECL MwI16 MwLLVecIndexI16(MwLLVec* vec, MwU64 index) { - return ((MwI16*)vec->buffer)[index]; -}; -MWDECL MwI32 MwLLVecIndexI32(MwLLVec* vec, MwU64 index) { - return ((MwI32*)vec->buffer)[index]; -}; -MWDECL MwI64 MwLLVecIndexI64(MwLLVec* vec, MwU64 index) { - return ((MwI64*)vec->buffer)[index]; -}; diff --git a/src/math/math_internal.h b/src/math/math_internal.h deleted file mode 100644 index 6011616..0000000 --- a/src/math/math_internal.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $Id$ */ - -#ifndef __MW_LOWLEVEL_INTERNAL_MATH_H__ -#define __MW_LOWLEVEL_INTERNAL_MATH_H__ - -#include -#include - -typedef struct _MwLLMathVTable MwLLMathVTable; - -struct _MwLLMathVTable { - void (*add)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*multiply)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*sub)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*reciprocal)(MwLLVec* a, MwLLVec* out); - void (*squareRoot)(MwLLVec* a, MwLLVec* out); - void (*and)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*or)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*shiftRight)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*shiftLeft)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*equal)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*greaterThen)(MwLLVec* a, MwLLVec* b, MwLLVec* out); - void (*lesserThen)(MwLLVec* a, MwLLVec* b, MwLLVec* out); -}; - -struct _MwLLVec { - void* buffer; - int ty; - MwU64 size; - MwLLMathVTable vtable; -}; - -void default_apply(MwLLVec*); - -/* Bitfield of cpu features we get from x86's CPUID */ -#if defined(MwLLMath_x86) -#define FEATX86_MMX (1 << 23) -// #define FEATX86_SSE (1 << 25) -#define FEATX86_SSE2 (1 << 26) -void mmx_apply(MwLLVec*); -#endif - -#endif diff --git a/src/math/mmx.c b/src/math/mmx.c deleted file mode 100644 index c5398d0..0000000 --- a/src/math/mmx.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $Id$ */ -#include - -#ifdef MwLLMath_x86 -#include "math_internal.h" -#include - -#define DO_MMX_INTRINSIC(intrin, _ty, _cty) \ - int i = 0; \ - for(; i < a->size; i += 8) { \ - __m64 m = intrin(((__m64*)a->buffer)[i], ((__m64*)b->buffer)[i]); \ - memcpy(&((_cty*)out->buffer)[i], &m, sizeof(m)); \ - } - -static void mmx_add8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_paddb, u8, MwU8) -} -static void mmx_sub8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psubb, u8, MwU8); -} -static void mmx_equal8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpeqb, u8, MwU8); -} -static void mmx_add16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_paddw, u16, MwU16); -} -static void mmx_sub16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psubw, u16, MwU16); -} -static void mmx_shiftRight16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psrlw, u16, MwU16); -} -static void mmx_shiftLeft16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psllw, u16, MwU16); -} -static void mmx_equal16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpeqw, u16, MwU16); -} - -static void mmx_add32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_paddd, u32, MwU32); -} -static void mmx_sub32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psubd, u32, MwU32); -} -static void mmx_shiftRight32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psrld, u32, MwU32); -} -static void mmx_shiftLeft32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pslld, u32, MwU32); -} -static void mmx_equal32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpeqw, u32, MwU32); -} - -static void mmx_addi8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_paddsb, i8, MwI8); -} -static void mmx_subi8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psubsb, i8, MwI8); -} -static void mmx_addi16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_paddsw, i16, MwI16); -} -static void mmx_subi16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_psubsw, i16, MwI16); -} -static void mmx_greaterTheni8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpgtb, i8, MwI8); -} -static void mmx_greaterTheni16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpgtw, i16, MwI16); -} -static void mmx_greaterTheni32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { - DO_MMX_INTRINSIC(_m_pcmpgtd, i32, MwI16); -} - -void mmx_apply(MwLLVec* vec) { - switch(vec->ty) { - case MwLLVecTypeU8: - vec->vtable.add = mmx_add8; - vec->vtable.sub = mmx_sub8; - vec->vtable.equal = mmx_equal8; - break; - case MwLLVecTypeU16: - vec->vtable.add = mmx_add16; - vec->vtable.sub = mmx_sub16; - vec->vtable.shiftLeft = mmx_shiftLeft16; - vec->vtable.shiftRight = mmx_shiftRight16; - vec->vtable.equal = mmx_equal16; - break; - case MwLLVecTypeU32: - vec->vtable.add = mmx_add32; - vec->vtable.sub = mmx_sub32; - vec->vtable.shiftLeft = mmx_shiftLeft32; - vec->vtable.shiftRight = mmx_shiftRight32; - vec->vtable.equal = mmx_equal32; - break; - case MwLLVecTypeU64: - break; - case MwLLVecTypeI8: - vec->vtable.add = mmx_addi8; - vec->vtable.sub = mmx_subi8; - vec->vtable.greaterThen = mmx_greaterTheni8; - vec->vtable.equal = mmx_equal8; - break; - case MwLLVecTypeI16: - vec->vtable.add = mmx_addi16; - vec->vtable.sub = mmx_subi16; - vec->vtable.shiftLeft = mmx_shiftLeft16; - vec->vtable.shiftRight = mmx_shiftRight16; - vec->vtable.greaterThen = mmx_greaterTheni16; - vec->vtable.equal = mmx_equal16; - break; - case MwLLVecTypeI32: - vec->vtable.add = mmx_add32; - vec->vtable.sub = mmx_sub32; - vec->vtable.shiftLeft = mmx_shiftLeft32; - vec->vtable.shiftRight = mmx_shiftRight32; - vec->vtable.greaterThen = mmx_greaterTheni32; - vec->vtable.equal = mmx_equal32; - break; - case MwLLVecTypeI64: - break; - case MwLLVecType_Max: - break; - } -} -#endif diff --git a/tools/genmk.pl b/tools/genmk.pl index 056e1e8..8ec4d0a 100755 --- a/tools/genmk.pl +++ b/tools/genmk.pl @@ -150,7 +150,6 @@ scan("src/cursor"); scan("src/widget"); scan("src/text"); scan("src/font"); -scan("src/math"); scan("src/color_picker"); push(@cfiles, "src/backend/gdi.c");