diff --git a/BorMakefile b/BorMakefile index a53da65..90d7e3c 100644 --- a/BorMakefile +++ b/BorMakefile @@ -6,7 +6,7 @@ LD = bcc32 CFLAGS = -Iinclude -D_MILSKO -DUSE_GDI -DUSE_STB_IMAGE -DSTBI_NO_SIMD CXXFLAGS = -Iinclude LDFLAGS = -tWD -.SUFFIXES: .c .cc .obj +.SUFFIXES: .obj .c .cc all: src\Mw.dll oosrc\MwOO.dll clean: del /f /q src\core.obj diff --git a/NTMakefile b/NTMakefile index e1d4cc3..26ef2ae 100644 --- a/NTMakefile +++ b/NTMakefile @@ -6,7 +6,7 @@ LD = link /nologo CFLAGS = /Iinclude /D_MILSKO /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD CXXFLAGS = /Iinclude LDFLAGS = /DLL -.SUFFIXES: .c .cc .obj +.SUFFIXES: .obj .c .cc all: src\Mw.dll oosrc\MwOO.dll clean: del /f /q src\core.obj diff --git a/resource/icon/error.png b/resource/icon/error.png index fd36911..f1712c4 100644 Binary files a/resource/icon/error.png and b/resource/icon/error.png differ diff --git a/resource/icon/info.png b/resource/icon/info.png index 5c8a50c..0a8d2e1 100644 Binary files a/resource/icon/info.png and b/resource/icon/info.png differ diff --git a/resource/icon/news.png b/resource/icon/news.png index f95f73c..9157f9d 100644 Binary files a/resource/icon/news.png and b/resource/icon/news.png differ diff --git a/resource/icon/note.png b/resource/icon/note.png index 79c0b46..76cd080 100644 Binary files a/resource/icon/note.png and b/resource/icon/note.png differ diff --git a/resource/icon/question.png b/resource/icon/question.png index 575a4e4..ccd9ac9 100644 Binary files a/resource/icon/question.png and b/resource/icon/question.png differ diff --git a/resource/icon/warning.png b/resource/icon/warning.png index 5cab4ab..d74b011 100644 Binary files a/resource/icon/warning.png and b/resource/icon/warning.png differ diff --git a/src/backend/x11.c b/src/backend/x11.c index 626ce6b..c74ad02 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -297,11 +297,8 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei r->use_shm = XShmQueryExtension(handle->display) ? 1 : 0; r->data = malloc(width * height * 4); - if(!XRenderQueryExtension(handle->display, &evbase, &erbase)) { - fprintf(stderr, "XRender missing - cannot proceed pixmap creation\n"); - r->image = NULL; - return r; - } + r->use_render = XRenderQueryExtension(handle->display, &evbase, &erbase) ? 1 : 0; + r->use_render = 0; if(r->use_shm) { r->image = XShmCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 24, ZPixmap, NULL, &r->shm, width, height); @@ -358,7 +355,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) { } void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { - if(pixmap->image != NULL) { + if(pixmap->image != NULL && pixmap->use_render) { Pixmap px = XCreatePixmap(handle->display, handle->window, pixmap->width, pixmap->height, 24); XRenderPictFormat* format = XRenderFindStandardFormat(handle->display, PictStandardRGB24); XRenderPictureAttributes attr; @@ -397,6 +394,62 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { XRenderFreePicture(handle->display, dest); XFreePixmap(handle->display, px); + } else if(pixmap->image != NULL) { + int use_shm = XShmQueryExtension(handle->display) ? 1 : 0; + XImage* dest; + XShmSegmentInfo shm; + char* d = malloc(rect->width * rect->height * 4); + int y, x; + + /* FIXME */ + use_shm = 0; + + for(y = 0; y < (int)rect->height; y++) { + for(x = 0; x < (int)rect->width; x++) { + double sy = (double)y / rect->height * pixmap->height; + double sx = (double)x / rect->width * pixmap->width; + char* ipx; + char* opx; + sy = (int)sy; + sx = (int)sx; + + ipx = &pixmap->image->data[(int)(pixmap->width * sy + sx) * 4]; + opx = &d[(rect->width * y + x) * 4]; + memcpy(opx, ipx, 4); + } + } + + if(use_shm) { + dest = XShmCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 24, ZPixmap, NULL, &shm, rect->width, rect->height); + shm.shmid = shmget(IPC_PRIVATE, dest->bytes_per_line * rect->height, IPC_CREAT | 0777); + if(shm.shmid == -1) { + XDestroyImage(dest); + use_shm = 0; + } else { + free(d); + shm.shmaddr = d = dest->data = shmat(shm.shmid, 0, 0); + shm.readOnly = False; + XShmAttach(handle->display, &shm); + } + } + if(!use_shm) { + dest = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 24, ZPixmap, 0, d, rect->width, rect->height, 32, rect->width * 4); + } + + if(use_shm) { + XShmPutImage(handle->display, handle->pixmap, handle->gc, dest, 0, 0, rect->x, rect->y, rect->width, rect->height, False); + } else { + XPutImage(handle->display, handle->pixmap, handle->gc, dest, 0, 0, rect->x, rect->y, rect->width, rect->height); + } + + if(use_shm) { + XShmDetach(handle->display, &shm); + } + XDestroyImage(dest); + if(use_shm) { + shmdt(shm.shmaddr); + shmctl(shm.shmid, IPC_RMID, 0); + } } } diff --git a/src/backend/x11.h b/src/backend/x11.h index 2ed8982..79d2c74 100644 --- a/src/backend/x11.h +++ b/src/backend/x11.h @@ -44,6 +44,7 @@ struct _MwLLPixmap { unsigned char* data; int use_shm; + int use_render; XShmSegmentInfo shm; Display* display; XImage* image; diff --git a/tools/genmk.pl b/tools/genmk.pl index 240f159..14b4ae9 100755 --- a/tools/genmk.pl +++ b/tools/genmk.pl @@ -104,7 +104,7 @@ sub generate { $dll = "system nt_dll"; $lib = "library "; - $suffix = 0; # is watcom make broken with suffix rule + $suffix = 0; # watcom suffix rule works kinda strange $symbolic = ".SYMBOLIC"; $dir = "/"; $del = "%erase"; @@ -128,7 +128,7 @@ sub generate { print(OUT "\n"); if ($suffix) { - print(OUT ".SUFFIXES: .c .cc .obj\n"); + print(OUT ".SUFFIXES: .obj .c .cc\n"); } print(OUT "all: src${dir}Mw.dll oosrc${dir}MwOO.dll\n"); print(OUT "clean: $symbolic\n");