Skip to content

Commit

Permalink
fixes for x11
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Nov 25, 2023
1 parent 80c4562 commit d36e4cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
18 changes: 9 additions & 9 deletions unix/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
#define COLOR_B16(x) (((x)<<8)&0xFF00)

static int rop_map[] = {
GXclear /* ropBlackness */, /* dest = 0 */
GXand /* ropAndPut */, /* dest &= src */
GXandReverse /* ropNotDestAnd */, /* dest = (!dest) & src */
GXcopy /* ropCopyPut */, /* dest = src */
GXandInverted /* ropNotSrcAnd */, /* dest &= !src */
GXnoop /* ropNoOper */, /* dest = dest */
GXxor /* ropXorPut */, /* dest ^= src */
GXand /* ropAndPut */, /* dest &= src */
GXor /* ropOrPut */, /* dest |= src */
GXcopyInverted /* ropNotPut */, /* dest = !src */
GXnor /* ropNotOr */, /* dest = !(src | dest) */
GXequiv /* ropNotXor */, /* dest ^= !src */
GXinvert /* ropInvert */, /* dest = !dest */
GXclear /* ropBlackness */, /* dest = 0 */
GXandReverse /* ropNotDestAnd */, /* dest = (!dest) & src */
GXorReverse /* ropNotDestOr */, /* dest = (!dest) | src */
GXset /* ropWhiteness */, /* dest = 1 */
GXandInverted /* ropNotSrcAnd */, /* dest &= !src */
GXcopyInverted /* ropNotPut */, /* dest = !src */
GXorInverted /* ropNotSrcOr */, /* dest |= !src */
GXequiv /* ropNotXor */, /* dest ^= !src */
GXnand /* ropNotAnd */, /* dest = !(src & dest) */
GXnor /* ropNotOr */, /* dest = !(src | dest) */
GXnoop /* ropNoOper */ /* dest = dest */
GXset /* ropWhiteness */ /* dest = 1 */
};

int
Expand Down
31 changes: 24 additions & 7 deletions unix/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@ img_render_icon_on_picture( Handle self, Handle image, PutImageRequest * req, Bo
Picture picture;

/* XXX is 255 still good? request alpha_channel=255 because PictOpOver emulates SrcCopy here */
printf("EKEKE\n");
if (!(cache = prima_image_cache((PImage) image,
CACHE_LAYERED_ALPHA,
255, 255, 255)))
Expand All @@ -2182,6 +2183,7 @@ img_render_icon_on_picture( Handle self, Handle image, PutImageRequest * req, Bo

picture = prima_render_create_picture(pixmap, 32);
RENDER_APPLY_TRANSFORM(picture);
printf("%d %d\n", req->rop,PIcon(image)->maskType);
RENDER_COMPOSITE( ofs,
(req-> rop == ropCopyPut && PIcon(image)->maskType == imbpp8) ? PictOpSrc : PictOpOver,
picture);
Expand Down Expand Up @@ -2441,7 +2443,7 @@ get_image_src_format( Handle self, Handle image, int * rop )
}

static PutImageFunc**
get_image_dst_format( Handle self, int rop, int src_type, Bool use_xrender )
get_image_dst_format( Handle self, Handle image, int rop, int src_type, Bool use_xrender )
{
DEFXX;

Expand All @@ -2453,6 +2455,9 @@ get_image_dst_format( Handle self, int rop, int src_type, Bool use_xrender )
/* xrender cannot rops */
if ( src_type != SRC_LAYERED && src_type != SRC_ARGB && rop != ropCopyPut && rop != ropBlend )
return img_render_nullset;
/* bpp1 requires xor/and rops */
if ( XT_IS_ICON(X(image)) && PIcon(image)->maskType == imbpp1)
return img_render_nullset;
}

if (XT_IS_BITMAP(XX) || (( XT_IS_PIXMAP(XX) || XT_IS_APPLICATION(XX)) && guts.depth==1))
Expand Down Expand Up @@ -2501,17 +2506,21 @@ apc_gp_put_image( Handle self, Handle image, int x, int y, int xFrom, int yFrom,

if ( rop == ropDefault ) rop = get_default_rop(image);
src = get_image_src_format(self, image, &rop);
if ( rop > ropWhiteness ) return false;
if ( src == SRC_LAYERED || src == SRC_ARGB ) {
if ( rop != ropCopyPut && rop != ropBlend ) return false;
} else {
if ( rop > ropWhiteness ) return false;
}
if ( src < 0 ) {
warn("cannot guess image type");
return false;
}
if (!(dst = get_image_dst_format(self, rop, src, true))) {
if (!(dst = get_image_dst_format(self, image, rop, src, true))) {
warn("cannot guess surface type");
return false;
}
if ( !dst[src] ) {
if (!( dst = get_image_dst_format(self, rop, src, false))) {
if (!( dst = get_image_dst_format(self, image, rop, src, false))) {
warn("cannot guess surface type");
return false;
}
Expand Down Expand Up @@ -3071,7 +3080,11 @@ apc_gp_stretch_image_x11( Handle self, Handle image,

if ( rop == ropDefault ) rop = get_default_rop(image);
src = get_image_src_format(self, image, &rop);
if ( rop > ropWhiteness ) return false;
if ( src == SRC_LAYERED || src == SRC_ARGB ) {
if ( rop != ropCopyPut && rop != ropBlend ) return false;
} else {
if ( rop > ropWhiteness ) return false;
}
if ( src < 0 ) return false;

XRENDER_SYNC;
Expand Down Expand Up @@ -3277,10 +3290,14 @@ apc_gp_stretch_image( Handle self, Handle image,

if ( rop == ropDefault ) rop = get_default_rop(image);
src = get_image_src_format(self, image, &rop);
if ( rop > ropWhiteness ) return false;
if ( src == SRC_LAYERED || src == SRC_ARGB ) {
if ( rop != ropCopyPut && rop != ropBlend ) return false;
} else {
if ( rop > ropWhiteness ) return false;
}
if ( src < 0 ) return false;

if (!(dst = get_image_dst_format(self, rop, src, true))) {
if (!(dst = get_image_dst_format(self, image, rop, src, true))) {
warn("cannot guess surface type");
return false;
}
Expand Down

0 comments on commit d36e4cd

Please sign in to comment.