From 3f31b9852c313b6b9a670e9c202a7fb339e5d448 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 28 Aug 2006 01:50:09 -0700 Subject: [PATCH] Work on getting libpng to actually do something useful... --- com32/lib/MCONFIG | 12 +++++++++--- com32/lib/Makefile | 6 ++++-- com32/lib/math/pow.S | 25 +++++++++++++++++++++++++ com32/lib/sys/vesa/background.c | 18 +++++------------- 4 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 com32/lib/math/pow.S diff --git a/com32/lib/MCONFIG b/com32/lib/MCONFIG index 35d34d7c..1263b516 100644 --- a/com32/lib/MCONFIG +++ b/com32/lib/MCONFIG @@ -12,12 +12,18 @@ OBJCOPY = objcopy # zlib and libpng configuration flags LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \ - -DPNG_NO_MNG_FEATURES -DPNG_NO_FLOATING_POINT_SUPPORTED \ - -DPNG_NO_WRITE_FLUSH -DPNG_NO_WRITE_tIME -DPNG_NO_READ_tIME + -FPNG_NO_WRITE_SUPPORTED \ + -DPNG_NO_MNG_FEATURES \ + -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME + +# We need some features in libpng which apparently aren't available in the +# fixed-point versions. It's OK, because we have to have a non-graphical +# fallback anyway, just use that on old machines... +# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED REQFLAGS = -g -m32 -mregparm=3 -DREGPARM=3 -D__COM32__ -I. -I./sys -I../include OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \ - -falign-labels=0 + -falign-labels=0 -ffast-math WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline CFLAGS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d $(OPTFLAGS) \ diff --git a/com32/lib/Makefile b/com32/lib/Makefile index cfbeeb22..a3aaa51d 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -44,11 +44,13 @@ LIBOBJS = \ zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \ zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o \ \ - libpng/png.o libpng/pngset.o libpng/pngrutil.o \ + libpng/png.o libpng/pngset.o libpng/pngget.o libpng/pngrutil.o \ libpng/pngtrans.o libpng/pngwutil.o libpng/pngread.o \ libpng/pngrio.o libpng/pngwio.o libpng/pngwrite.o \ libpng/pngrtran.o libpng/pngwtran.o libpng/pngmem.o \ - libpng/pngerror.o libpng/pngpread.o + libpng/pngerror.o libpng/pngpread.o \ + \ + math/pow.o BINDIR = /usr/bin LIBDIR = /usr/lib diff --git a/com32/lib/math/pow.S b/com32/lib/math/pow.S new file mode 100644 index 00000000..5a124aba --- /dev/null +++ b/com32/lib/math/pow.S @@ -0,0 +1,25 @@ +# +# pow.S +# +# double pow(double base, double exponent) +# + + .text + .globl pow + .type pow,@function +pow: + fldl 12(%esp) + fldl 4(%esp) + fyl2x + fld %st(0) + frndint + fsubr %st,%st(1) + fxch %st(1) + f2xm1 + fld1 + faddp %st,%st(1) + fscale + fstp %st(1) + ret + + .size pow,.-pow diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c index 7de2d5a4..5a34ef82 100644 --- a/com32/lib/sys/vesa/background.c +++ b/com32/lib/sys/vesa/background.c @@ -55,8 +55,6 @@ int vesacon_load_background(const char *filename) png_infop end_ptr = NULL; png_color_16p image_background; static const png_color_16 my_background = {0,0,0,0,0}; - double gamma; - const double screen_gamma = 2.2; png_bytep row_pointers[VIDEO_Y_SIZE]; int passes; int i; @@ -123,6 +121,11 @@ int vesacon_load_background(const char *filename) png_set_bgr(png_ptr); + if (info_ptr->bit_depth == 16) + png_set_strip_16(png_ptr); + else if (info_ptr->bit_depth < 8) + png_set_packing(png_ptr); + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) png_set_background(png_ptr, image_background, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); @@ -130,17 +133,6 @@ int vesacon_load_background(const char *filename) png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - - if (info_ptr->bit_depth == 16) - png_set_strip_16(png_ptr); - else if (info_ptr->bit_depth < 8) - png_set_packing(png_ptr); - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - /* Whew! Now we should get the stuff we want... */ for (i = 0; i < info_ptr->height; i++) row_pointers[i] = (png_bytep *)__vesacon_background[i]; -- 2.11.4.GIT