make xrender optional

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@642 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-08 22:47:11 +00:00
parent 9b45083747
commit 2f6a0d1ada
4 changed files with 26 additions and 10 deletions

View File

@@ -451,7 +451,9 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
r->data = malloc(sizeof(unsigned long) * width * height);
r->handle = handle;
r->use_render = XRenderQueryExtension(handle->display, &evbase, &erbase) ? 1 : 0;
#ifdef USE_XRENDER
r->use_xrender = XRenderQueryExtension(handle->display, &evbase, &erbase) ? 1 : 0;
#endif
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);
@@ -499,6 +501,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) {
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
if(rect->width == 0 || rect->height == 0) return;
#ifdef USE_XRENDER
if(pixmap->image != NULL && pixmap->use_render) {
Pixmap px = XCreatePixmap(handle->display, handle->window, pixmap->width, pixmap->height, pixmap->depth);
Pixmap mask = XCreatePixmap(handle->display, handle->window, rect->width, rect->height, 1);
@@ -565,7 +568,9 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
XFreePixmap(handle->display, mask);
XFreePixmap(handle->display, px);
XFreePixmap(handle->display, pxsrc);
} else if(pixmap->image != NULL) {
} else
#endif
if(pixmap->image != NULL) {
XImage* dest;
XImage* destmask;
Pixmap mask = XCreatePixmap(handle->display, handle->window, rect->width, rect->height, 1);

View File

@@ -9,7 +9,9 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#ifdef USE_XRENDER
#include <X11/extensions/Xrender.h>
#endif
struct _MwLL {
Display* display;
@@ -58,7 +60,7 @@ struct _MwLLPixmap {
int depth;
unsigned char* data;
MwLL handle;
int use_render;
int use_xrender;
Display* display;
XImage* image;
XImage* mask;