1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Hermes support

This commit is contained in:
kojima
2001-02-18 00:41:22 +00:00
parent e926227b3e
commit 8d988e5eae
9 changed files with 173 additions and 150 deletions

View File

@@ -6,6 +6,7 @@ Changes since version 0.64.0:
- applied patch for wkdemenu (Malcolm Cowe <malk@bruhaha.co.uk>) - applied patch for wkdemenu (Malcolm Cowe <malk@bruhaha.co.uk>)
- added WINDOWS_MENU submenu type for root menu (Bastien Nocera <hadess@hadess.net>) - added WINDOWS_MENU submenu type for root menu (Bastien Nocera <hadess@hadess.net>)
- added kbd shortcuts for icon chooser - added kbd shortcuts for icon chooser
- use Hermes in wrlib
Changes since version 0.63.1: Changes since version 0.63.1:
............................. .............................

View File

@@ -87,9 +87,6 @@
/* define if your X server has XInternAtoms() */ /* define if your X server has XInternAtoms() */
#undef HAVE_XINTERNATOMS #undef HAVE_XINTERNATOMS
/* define if processor is x86 */ /* define if you want Hermes support */
#undef ASM_X86 #undef HAVE_HERMES
/* define if processor is x86 with MMX(tm) support */
#undef ASM_X86_MMX

View File

@@ -167,44 +167,6 @@ AC_TYPE_SIGNAL
dnl Compiler/architecture specific optimizations
dnl ============================================
dnl GCC/as with MMX support
dnl --------------------
# until we fix it, leave it disabled
if test "$ac_cv_prog_gcc" = yes; then
x86=0
changequote(,)dnl
case "$host_cpu" in
i[3456]86) x86=1
;;
esac
changequote([,])dnl
if test "$host_os" != "linux" -a "$host_os" != "linux-gnu" ; then
x86=0
fi
if test $x86 = 1; then
AC_DEFINE(ASM_X86)
AC_CACHE_CHECK(whether gcc supports MMX(tm) inline asm,
ac_cv_c_inline_mmx,
[AC_TRY_LINK(,[asm ("movq %mm0, %mm1");],
ac_cv_c_inline_mmx=yes,
ac_cv_c_inline_mmx=no)])
if test "x$ac_cv_c_inline_mmx" = xyes; then
AC_DEFINE(ASM_X86_MMX)
fi
fi
fi
dnl gettext dnl gettext
dnl ======= dnl =======
@@ -601,6 +563,28 @@ dnl End of stuff that uses X
dnl =============================================== dnl ===============================================
dnl Hermes Support
dnl ==============
AC_ARG_ENABLE(hermes,
[ --disable-hermes disable Hermes support for wrlib ],
hermes=$enableval, hermes=yes, hermes=no)
if test x$hermes = xyes; then
WM_CHECK_LIB(Hermes, Hermes_ConverterRequest, [])
if test x$ac_cv_lib_Hermes_Hermes_ConverterRequest = xyes; then
WM_CHECK_HEADER(Hermes/Hermes.h)
if test x$ac_cv_header_Hermes_Hermes_h = xyes; then
GFXLIBS="$GFXLIBS -lHermes"
AC_DEFINE(HAVE_HERMES)
fi
fi
fi
dnl PNG Support dnl PNG Support
dnl =========== dnl ===========
png=yes png=yes
@@ -1018,6 +1002,9 @@ echo "Installation path prefix: $prefix"
echo "Installation path prefix for binaries: $_bindir" echo "Installation path prefix for binaries: $_bindir"
echo "Installation path for WPrefs.app: $wprefsdir" | sed -e 's|\$(prefix)|'"$prefix|" echo "Installation path for WPrefs.app: $wprefsdir" | sed -e 's|\$(prefix)|'"$prefix|"
echo "Graphic format libraries: $supported_gfx" echo "Graphic format libraries: $supported_gfx"
if test x$hermes = xyes; then
echo "Hermes support for wrlib enabled"
fi
echo "Sound support: $sound" echo "Sound support: $sound"
echo "Translated message files to install: $mof" echo "Translated message files to install: $mof"
if test "x$MOFILES" != "x"; then if test "x$MOFILES" != "x"; then

View File

@@ -20,6 +20,7 @@ libwraster_la_SOURCES = \
CrCmap.c \ CrCmap.c \
DelCmap.c \ DelCmap.c \
CmapAlloc.c \ CmapAlloc.c \
wrasterP.h \
raster.c \ raster.c \
draw.c \ draw.c \
color.c \ color.c \
@@ -28,7 +29,6 @@ libwraster_la_SOURCES = \
gradient.c \ gradient.c \
xpixmap.c \ xpixmap.c \
convert.c \ convert.c \
x86_specific.c \
context.c \ context.c \
misc.c \ misc.c \
scale.c \ scale.c \
@@ -44,18 +44,6 @@ libwraster_la_SOURCES = \
gif.c gif.c
LTCOMPILE2=`echo $(LTCOMPILE) | sed -e s/-fomit-frame-pointer//`
COMPILE2=`echo $(COMPILE) | sed -e s/-fomit-frame-pointer//`
# cant compile asm stuff with optimizations
x86_specific.lo: x86_specific.c
$(LTCOMPILE2) -O0 -c $<
x86_specific.o: x86_specific.c
$(COMPILE2) -O0 -c $<
INCLUDES = $(DFLAGS) @HEADER_SEARCH_PATH@ INCLUDES = $(DFLAGS) @HEADER_SEARCH_PATH@

View File

@@ -2,4 +2,3 @@
supports PseudoColor and TrueColor in some depths) supports PseudoColor and TrueColor in some depths)
- Gimp's xcf format? - Gimp's xcf format?
- add clipping code to RCombineArea() - add clipping code to RCombineArea()
- remake and optimize converters

View File

@@ -32,6 +32,12 @@
#include <math.h> #include <math.h>
#include "wrasterP.h"
#ifdef HAVE_HERMES
#include <Hermes/Hermes.h>
#endif
#include "StdCmap.h" #include "StdCmap.h"
#include "wraster.h" #include "wraster.h"
@@ -700,17 +706,64 @@ RCreateContext(Display *dpy, int screen_number, RContextAttributes *attribs)
context->copy_gc = XCreateGC(dpy, context->drawable, GCFunction context->copy_gc = XCreateGC(dpy, context->drawable, GCFunction
|GCGraphicsExposures, &gcv); |GCGraphicsExposures, &gcv);
if (context->vclass == PseudoColor || context->vclass == StaticColor) { #ifdef HAVE_HERMES
context->hermes_data = malloc(sizeof(RHermesData));
if (!setupPseudoColorColormap(context)) { if (!context->hermes_data) {
RErrorCode = RERR_NOMEMORY;
free(context);
return NULL; return NULL;
} }
context->hermes_data->palette = Hermes_PaletteInstance();
{
unsigned long flags = 0;
if (context->attribs->render_mode == RDitheredRendering)
flags |= HERMES_CONVERT_DITHER;
context->hermes_data->converter = Hermes_ConverterInstance(flags);
}
#endif
if (context->vclass == PseudoColor || context->vclass == StaticColor) {
if (!setupPseudoColorColormap(context)) {
free(context);
return NULL;
}
#ifdef HAVE_HERMES
{
int32 palette[256];
int i;
for (i = 0; i < context->ncolors; i++) {
palette[i] = ((context->colors[i].red >> 8) << 16) ||
((context->colors[i].green >> 8) << 8) ||
((context->colors[i].blue >> 8));
}
Hermes_PaletteSet(context->hermes_data->palette, palette);
}
#endif
} else if (context->vclass == GrayScale || context->vclass == StaticGray) { } else if (context->vclass == GrayScale || context->vclass == StaticGray) {
context->colors = allocateGrayScale(context); context->colors = allocateGrayScale(context);
if (!context->colors) { if (!context->colors) {
free(context);
return NULL; return NULL;
} }
#ifdef HAVE_HERMES
{
int32 palette[256];
int i;
for (i = 0; i < context->ncolors; i++) {
palette[i] = ((context->colors[i].red >> 8) << 16) ||
((context->colors[i].green >> 8) << 8) ||
((context->colors[i].blue >> 8));
}
Hermes_PaletteSet(context->hermes_data->palette, palette);
}
#endif
} else if (context->vclass == TrueColor) { } else if (context->vclass == TrueColor) {
/* calc offsets to create a TrueColor pixel */ /* calc offsets to create a TrueColor pixel */
context->red_offset = count_offset(context->visual->red_mask); context->red_offset = count_offset(context->visual->red_mask);
@@ -721,6 +774,10 @@ RCreateContext(Display *dpy, int screen_number, RContextAttributes *attribs)
context->attribs->render_mode = RBestMatchRendering; context->attribs->render_mode = RBestMatchRendering;
} }
#ifdef HAVE_HERMES
#endif
/* check avaiability of MIT-SHM */ /* check avaiability of MIT-SHM */
#ifdef XSHM #ifdef XSHM
if (!(context->attribs->flags & RC_UseSharedMemory)) { if (!(context->attribs->flags & RC_UseSharedMemory)) {

View File

@@ -29,11 +29,12 @@
#include <assert.h> #include <assert.h>
#ifdef BENCH #ifdef BENCH
#include "bench.h" #include "bench.h"
#endif #endif
#include "wraster.h" #include "wrasterP.h"
#ifdef XSHM #ifdef XSHM
extern Pixmap R_CreateXImageMappedPixmap(RContext *context, RXImage *ximage); extern Pixmap R_CreateXImageMappedPixmap(RContext *context, RXImage *ximage);
@@ -41,40 +42,6 @@ extern Pixmap R_CreateXImageMappedPixmap(RContext *context, RXImage *ximage);
#endif #endif
#ifdef ASM_X86
extern void x86_PseudoColor_32_to_8(unsigned char *image,
unsigned char *ximage,
char *err, char *nerr,
short *ctable,
int dr, int dg, int db,
unsigned long *pixels,
int cpc,
int width, int height,
int bytesPerPixel,
int line_offset);
#endif /* ASM_X86 */
#ifdef ASM_X86_MMX
extern int x86_check_mmx();
extern void x86_mmx_TrueColor_32_to_16(unsigned char *image,
unsigned short *ximage,
short *err, short *nerr,
short *rtable, short *gtable,
short *btable,
int dr, int dg, int db,
unsigned int roffs,
unsigned int goffs,
unsigned int boffs,
int width, int height,
int line_offset);
#endif /* ASM_X86_MMX */
typedef struct RConversionTable { typedef struct RConversionTable {
unsigned short table[256]; unsigned short table[256];
@@ -306,38 +273,6 @@ image2TrueColor(RContext *ctx, RImage *image)
#ifdef DEBUG #ifdef DEBUG
puts("true color dither"); puts("true color dither");
#endif #endif
#ifdef ASM_X86_MMX
if (ctx->depth == 16 && image->format == RRGBAFormat
&& x86_check_mmx()) {
short *err;
short *nerr;
err = malloc(8*(image->width+3));
nerr = malloc(8*(image->width+3));
if (!err || !nerr) {
if (nerr)
free(nerr);
RErrorCode = RERR_NOMEMORY;
RDestroyXImage(ctx, ximg);
return NULL;
}
memset(err, 0, 8*(image->width+3));
memset(nerr, 0, 8*(image->width+3));
x86_mmx_TrueColor_32_to_16(image->data,
(unsigned short*)ximg->image->data,
err+8, nerr+8,
rtable, gtable, btable,
dr, dg, db,
roffs, goffs, boffs,
image->width, image->height,
ximg->image->bytes_per_line - 2*image->width);
free(err);
free(nerr);
} else
#endif /* ASM_X86_MMX */
{ {
char *err; char *err;
char *nerr; char *nerr;
@@ -526,20 +461,9 @@ image2PseudoColor(RContext *ctx, RImage *image)
memset(err, 0, 4*(image->width+3)); memset(err, 0, 4*(image->width+3));
memset(nerr, 0, 4*(image->width+3)); memset(nerr, 0, 4*(image->width+3));
/*#ifdef ASM_X86*/
#if 0
x86_PseudoColor_32_to_8(image->data, ximg->image->data,
err+4, nerr+4,
rtable,
dr, dg, db, ctx->pixels, cpc,
image->width, image->height,
channels,
ximg->image->bytes_per_line - image->width);
#else
convertPseudoColor_to_8(ximg, image, err+4, nerr+4, convertPseudoColor_to_8(ximg, image, err+4, nerr+4,
rtable, gtable, btable, rtable, gtable, btable,
dr, dg, db, ctx->pixels, cpc); dr, dg, db, ctx->pixels, cpc);
#endif
free(err); free(err);
free(nerr); free(nerr);
@@ -843,6 +767,67 @@ image2Bitmap(RContext *ctx, RImage *image, int threshold)
} }
#ifdef HAVE_HERMES
static RXImage*
hermesConvert(RContext *context, RImage *image)
{
HermesFormat source;
HermesFormat dest;
RXImage *ximage;
ximage = RCreateXImage(context, context->depth,
image->width, image->height);
if (!ximage) {
return NULL;
}
if (image->format == RRGBFormat) {
source.b = 0x00ffffff;
source.g = 0xff00ffff;
source.r = 0xffff00ff;
source.a = 0x00000000;
source.bits = 24;
} else {
source.b = 0x00ffffff;
source.g = 0xff00ffff;
source.r = 0xffff00ff;
source.a = 0xff000000;
source.bits = 32;
}
source.indexed = 0;
source.has_colorkey = 0;
dest.r = context->visual->red_mask;
dest.g = context->visual->green_mask;
dest.b = context->visual->blue_mask;
dest.a = 0;
dest.bits = context->depth;
if (context->vclass == TrueColor)
dest.indexed = 0;
else
dest.indexed = 1;
dest.has_colorkey = 0;
Hermes_ConverterRequest(context->hermes_data->converter, &source, &dest);
Hermes_ConverterPalette(context->hermes_data->converter,
context->hermes_data->palette, 0);
Hermes_ConverterCopy(context->hermes_data->converter,
image->data, 0, 0, image->width, image->height,
image->width * (image->format == RRGBFormat ? 3 : 4),
ximage->image->data, 0, 0,
image->width, image->height,
ximage->image->bytes_per_line);
return ximage;
}
#endif /* HAVE_HERMES */
int int
RConvertImage(RContext *context, RImage *image, Pixmap *pixmap) RConvertImage(RContext *context, RImage *image, Pixmap *pixmap)
@@ -856,14 +841,17 @@ RConvertImage(RContext *context, RImage *image, Pixmap *pixmap)
assert(image!=NULL); assert(image!=NULL);
assert(pixmap!=NULL); assert(pixmap!=NULL);
#ifdef HAVE_HERMES
ximg = hermesConvert(context, image);
#else /* !HAVE_HERMES */
/* clear error message */ /* clear error message */
if (context->vclass == TrueColor) { switch (context->vclass) {
case TrueColor:
ximg = image2TrueColor(context, image); ximg = image2TrueColor(context, image);
break;
} else if (context->vclass == PseudoColor case PseudoColor:
|| context->vclass == StaticColor) { case StaticColor:
#ifdef BENCH #ifdef BENCH
cycle_bench(1); cycle_bench(1);
#endif #endif
@@ -874,10 +862,14 @@ RConvertImage(RContext *context, RImage *image, Pixmap *pixmap)
#ifdef BENCH #ifdef BENCH
cycle_bench(0); cycle_bench(0);
#endif #endif
} else if (context->vclass == GrayScale || context->vclass == StaticGray) { break;
case GrayScale:
case StaticGray:
ximg = image2GrayScale(context, image); ximg = image2GrayScale(context, image);
break;
} }
#endif /* !HAVE_HERMES */
if (!ximg) { if (!ximg) {
return False; return False;

View File

@@ -45,7 +45,7 @@ main(int argc, char **argv)
RDestroyImage(tmp); RDestroyImage(tmp);
} }
*/ */
#if 1 #if 0
if (argc > 2) { if (argc > 2) {
img = RScaleImage(img, img->width*atof(argv[2]), img = RScaleImage(img, img->width*atof(argv[2]),
img->height*atof(argv[2])); img->height*atof(argv[2]));
@@ -77,7 +77,7 @@ main(int argc, char **argv)
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
400, 400, 0, 0, 0); img->width, img->height, 0, 0, 0);
XSetWindowBackgroundPixmap(dpy, win, pix); XSetWindowBackgroundPixmap(dpy, win, pix);
XClearWindow(dpy, win); XClearWindow(dpy, win);
XMapRaised(dpy, win); XMapRaised(dpy, win);

View File

@@ -148,6 +148,8 @@ typedef struct RContext {
unsigned int use_shared_pixmap:1; unsigned int use_shared_pixmap:1;
unsigned int optimize_for_speed:1; unsigned int optimize_for_speed:1;
} flags; } flags;
struct RHermesData *hermes_data; /* handle for Hermes stuff */
} RContext; } RContext;