mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
make xrender optional
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@642 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
20
Makefile.pl
20
Makefile.pl
@@ -36,6 +36,7 @@ require("./pl/utils.pl");
|
||||
param_set("stb-image", 1);
|
||||
param_set("stb-truetype", 0);
|
||||
param_set("freetype2", 1);
|
||||
param_set("xrender", 1);
|
||||
param_set("opengl", 0);
|
||||
param_set("vulkan", 0);
|
||||
param_set("vulkan-string-helper", 1);
|
||||
@@ -44,6 +45,7 @@ my %features = (
|
||||
"stb-image" => "use stb_image instead of libjpeg/libpng",
|
||||
"stb-truetype" => "use stb_truetype",
|
||||
"freetype2" => "use FreeType2",
|
||||
"xrender" => "use XRender",
|
||||
"opengl" => "build OpenGL widget",
|
||||
"vulkan" => "build Vulkan widget",
|
||||
"vulkan-string-helper" => "use Vulkan string helper"
|
||||
@@ -51,7 +53,8 @@ my %features = (
|
||||
my @features_keys = (
|
||||
"1stb-image", "1stb-truetype",
|
||||
"1freetype2", "1opengl",
|
||||
"1vulkan", "2vulkan-string-helper"
|
||||
"2xrender", "1vulkan",
|
||||
"2vulkan-string-helper"
|
||||
);
|
||||
|
||||
foreach my $l (@ARGV) {
|
||||
@@ -84,11 +87,11 @@ foreach my $l (@ARGV) {
|
||||
print(" --without-FEATURE Do not use FEATURE\n");
|
||||
|
||||
foreach my $l (@features_keys) {
|
||||
my $flag =
|
||||
( (substr($l, 0, 1) eq '1')
|
||||
my $flag = (
|
||||
(substr($l, 0, 1) eq '1')
|
||||
? (param_get(substr($l, 1)) ? "--disable-" : "--enable-")
|
||||
: (param_get(substr($l, 1)) ? "--without-" : "--with-"))
|
||||
. substr($l, 1);
|
||||
: (param_get(substr($l, 1)) ? "--without-" : "--with-")
|
||||
) . substr($l, 1);
|
||||
my $do = param_get(substr($l, 1)) ? "Do not " : "";
|
||||
my $feat = $features{ substr($l, 1) };
|
||||
if (not(param_get($l))) {
|
||||
@@ -119,7 +122,10 @@ foreach my $e (param_list()) {
|
||||
if (($e eq "vulkan-string-helper") and param_get("vulkan")) {
|
||||
push(@l, $e);
|
||||
}
|
||||
elsif (not($e eq "vulkan-string-helper") and param_get($e)) {
|
||||
elsif (($e eq "xrender") and ($backend eq "x11")) {
|
||||
push(@l, $e);
|
||||
}
|
||||
elsif (not($e eq "vulkan-string-helper") and not($e eq "xrender") and param_get($e)) {
|
||||
push(@l, $e);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +150,7 @@ print(OUT
|
||||
" clang-format --verbose -i `find src include -name \"*.c\" -or -name \"*.h\"`\n"
|
||||
);
|
||||
print(OUT
|
||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools Makefile.pl -name \"*.pl\"`\n"
|
||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl Makefile.pl -name \"*.pl\"`\n"
|
||||
);
|
||||
print(OUT "\n");
|
||||
print(OUT "lib: src/${library_prefix}Mw${library_suffix}\n");
|
||||
|
||||
@@ -34,6 +34,9 @@ if(param_get("freetype2")){
|
||||
add_libs(`pkg-config --libs freetype2`);
|
||||
}
|
||||
}
|
||||
if(param_get("xrender")){
|
||||
add_cflags("-DUSE_XRENDER");
|
||||
}
|
||||
|
||||
new_object("src/icon/*.c");
|
||||
new_object("src/font/*.c");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user