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

Fixed crashes in 24 and 32bpp after introduction of hermeslib support

This commit is contained in:
dan
2001-02-26 00:43:44 +00:00
parent 64defd4d22
commit c720860ed3
11 changed files with 201 additions and 191 deletions

View File

@@ -486,7 +486,7 @@ WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg,
static void
handleKeyPress3(XEvent *event, void *clientData)
{
WMGenericPanel *panel = (WMAlertPanel*)clientData;
WMGenericPanel *panel = (WMGenericPanel*)clientData;
KeySym ksym;
XLookupString(&event->xkey, NULL, 0, &ksym, NULL);

View File

@@ -1,3 +1,8 @@
- Fixed crashing for Pseudocolor visuals with BestMatchRendering
- Small speed improvement for 24 and 32 bpp, if internal converter is used
- Small speed improvement for generating gradients.
- Fixed RSaveXPM() to output correct xpm images.
- fixed code dependant on the order of evaluation. code like
*ptr++ = *ptr++ = *ptr++ = color;
is wrong, because there is no guarantee that ptr will be incremented

View File

@@ -18,6 +18,12 @@
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Problems:
* 1. Using Grayscale visual with Dithering crashes wmaker
* 2. Ghost dock/appicon is wrong in Pseudocolor, Staticgray, Grayscale
*/
#include <config.h>
@@ -42,6 +48,8 @@ extern Pixmap R_CreateXImageMappedPixmap(RContext *context, RXImage *ximage);
#endif
#define HAS_ALPHA(I) ((I)->format == RRGBAFormat)
typedef struct RConversionTable {
unsigned short table[256];
@@ -254,16 +262,26 @@ image2TrueColor(RContext *ctx, RImage *image)
#ifdef DEBUG
puts("true color match");
#endif
for (y=0, ofs=0; y < image->height; y++) {
for (x=0; x < image->width; x++, ofs+=channels-3) {
/* reduce pixel */
r = rtable[ptr[ofs++]];
g = gtable[ptr[ofs++]];
b = btable[ptr[ofs++]];
pixel = (r<<roffs) | (g<<goffs) | (b<<boffs);
XPutPixel(ximg->image, x, y, pixel);
}
}
if (rmask==0xff && gmask==0xff && bmask==0xff) {
for (y=0; y < image->height; y++) {
for (x=0; x < image->width; x++, ptr+=channels) {
/* reduce pixel */
pixel = (*(ptr)<<roffs) | (*(ptr+1)<<goffs) | (*(ptr+2)<<boffs);
XPutPixel(ximg->image, x, y, pixel);
}
}
} else {
for (y=0, ofs=0; y < image->height; y++) {
for (x=0; x < image->width; x++, ofs+=channels-3) {
/* reduce pixel */
r = rtable[ptr[ofs++]];
g = gtable[ptr[ofs++]];
b = btable[ptr[ofs++]];
pixel = (r<<roffs) | (g<<goffs) | (b<<boffs);
XPutPixel(ximg->image, x, y, pixel);
}
}
}
} else {
/* dither */
const int dr=0xff/rmask;
@@ -427,7 +445,7 @@ image2PseudoColor(RContext *ctx, RImage *image)
printf("pseudo color match with %d colors per channel\n", cpc);
#endif
for (y=0; y<image->height; y++) {
for (x=0; x<image->width; x++, ptr+=channels-1) {
for (x=0; x<image->width; x++, ptr+=channels-3) {
/* reduce pixel */
r = rtable[*ptr++];
g = gtable[*ptr++];
@@ -783,29 +801,41 @@ hermesConvert(RContext *context, RImage *image)
return NULL;
}
if (image->format == RRGBFormat) {
source.b = 0x00ffffff;
source.g = 0xff00ffff;
source.r = 0xffff00ff;
source.a = 0x00000000;
source.bits = 24;
if (HAS_ALPHA(image)) {
if (ximage->image->byte_order==LSBFirst) {
source.r = 0x000000ff;
source.g = 0x0000ff00;
source.b = 0x00ff0000;
source.a = 0xff000000;
} else {
source.r = 0xff000000;
source.g = 0x00ff0000;
source.b = 0x0000ff00;
source.a = 0x000000ff;
}
source.bits = 32;
} else {
source.b = 0x00ffffff;
source.g = 0xff00ffff;
source.r = 0xffff00ff;
source.a = 0xff000000;
source.bits = 32;
if (ximage->image->byte_order==LSBFirst) {
source.r = 0x0000ff;
source.g = 0x00ff00;
source.b = 0xff0000;
} else {
source.r = 0xff0000;
source.g = 0x00ff00;
source.b = 0x0000ff;
}
source.a = 0x000000;
source.bits = 24;
}
source.indexed = 0;
source.has_colorkey = 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;
dest.bits = ximage->image->bits_per_pixel;
if (context->vclass == TrueColor)
dest.indexed = 0;
else

View File

@@ -116,6 +116,7 @@ renderHGradient(unsigned width, unsigned height, int r0, int g0, int b0,
{
int i;
unsigned long r, g, b, dr, dg, db;
unsigned lineSize = width*3;
RImage *image;
unsigned char *ptr;
@@ -144,7 +145,7 @@ renderHGradient(unsigned width, unsigned height, int r0, int g0, int b0,
/* copy the first line to the other lines */
for (i=1; i<height; i++) {
memcpy(&(image->data[i*width*3]), image->data, width*3);
memcpy(&(image->data[i*lineSize]), image->data, lineSize);
}
return image;
}
@@ -280,6 +281,7 @@ renderMHGradient(unsigned width, unsigned height, RColor **colors, int count)
{
int i, j, k;
unsigned long r, g, b, dr, dg, db;
unsigned lineSize = width*3;
RImage *image;
unsigned char *ptr;
unsigned width2;
@@ -333,7 +335,7 @@ renderMHGradient(unsigned width, unsigned height, RColor **colors, int count)
/* copy the first line to the other lines */
for (i=1; i<height; i++) {
memcpy(&(image->data[i*width*3]), image->data, width*3);
memcpy(&(image->data[i*lineSize]), image->data, lineSize);
}
return image;
}
@@ -346,6 +348,7 @@ renderMVGradient(unsigned width, unsigned height, RColor **colors, int count)
{
int i, j, k;
unsigned long r, g, b, dr, dg, db;
unsigned lineSize = width*3;
RImage *image;
unsigned char *ptr, *tmp;
unsigned height2;
@@ -426,8 +429,8 @@ renderMVGradient(unsigned width, unsigned height, RColor **colors, int count)
}
for (j=k+1; j<height; j++) {
memcpy(ptr, tmp, width*3);
ptr += width*3;
memcpy(ptr, tmp, lineSize);
ptr += lineSize;
}
}

View File

@@ -91,31 +91,31 @@ RBevelImage(RImage *image, int bevel_type)
void
RFillImage(RImage *image, RColor *color)
{
unsigned char *d = image->data;
unsigned lineSize;
int i;
if (image->format == RRGBAFormat) {
unsigned char *d = image->data;
int i;
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
*d++ = color->alpha;
}
for (i = 1; i < image->height; i++, d += image->width*4) {
memcpy(d, image->data, image->width*4);
}
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
*d++ = color->alpha;
}
lineSize = image->width*4;
for (i = 1; i < image->height; i++, d+=lineSize) {
memcpy(d, image->data, lineSize);
}
} else {
unsigned char *d = image->data;
int i;
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
}
for (i = 1; i < image->height; i++, d += image->width*3) {
memcpy(d, image->data, image->width*3);
}
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
}
lineSize = image->width*3;
for (i = 1; i < image->height; i++, d+=lineSize) {
memcpy(d, image->data, lineSize);
}
}
}
@@ -123,41 +123,37 @@ RFillImage(RImage *image, RColor *color)
void
RClearImage(RImage *image, RColor *color)
{
if (color->alpha==255) {
if (image->format == RRGBAFormat) {
unsigned char *d = image->data;
int i;
unsigned char *d = image->data;
unsigned lineSize;
int i;
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
*d++ = 0xff;
}
for (i = 1; i < image->height; i++, d += image->width*4) {
memcpy(d, image->data, image->width*4);
}
if (color->alpha==255) {
if (image->format == RRGBAFormat) {
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
*d++ = 0xff;
}
lineSize = image->width*4;
for (i = 1; i < image->height; i++, d+=lineSize) {
memcpy(d, image->data, lineSize);
}
} else {
unsigned char *d = image->data;
int i;
for (i = 0; i < image->width; i++) {
*d++ = color->red;
*d++ = color->green;
*d++ = color->blue;
}
for (i = 1; i < image->height; i++, d += image->width*3) {
memcpy(d, image->data, image->width*3);
lineSize = image->width*3;
for (i = 1; i < image->height; i++, d+=lineSize) {
memcpy(d, image->data, lineSize);
}
}
} else {
int bytes = image->width*image->height;
int i;
unsigned char *d;
int alpha, nalpha, r, g, b;
d = image->data;
alpha = color->alpha;
r = color->red * alpha;
g = color->green * alpha;
@@ -165,12 +161,9 @@ RClearImage(RImage *image, RColor *color)
nalpha = 255 - alpha;
for (i=0; i<bytes; i++) {
*d = (((int)*d * nalpha) + r)/256;
d++;
*d = (((int)*d * nalpha) + g)/256;
d++;
*d = (((int)*d * nalpha) + b)/256;
d++;
*d = (((int)*d * nalpha) + r)/256; d++;
*d = (((int)*d * nalpha) + g)/256; d++;
*d = (((int)*d * nalpha) + b)/256; d++;
if (image->format == RRGBAFormat) {
d++;
}

View File

@@ -181,14 +181,9 @@ RGetImageFromXPMData(RContext *context, char **data)
*b = color_table[2][k];
if (a) {
*a = color_table[3][k];
r += 4;
g += 4;
b += 4;
a += 4;
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3;
g += 3;
b += 3;
r += 3; g += 3; b += 3;
}
}
} else {
@@ -208,14 +203,9 @@ RGetImageFromXPMData(RContext *context, char **data)
*b = color_table[2][k];
if (a) {
*a = color_table[3][k];
r += 4;
g += 4;
b += 4;
a += 4;
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3;
g += 3;
b += 3;
r += 3; g += 3; b += 3;
}
}
}
@@ -379,11 +369,15 @@ RLoadXPM(RContext *context, char *file, int index)
if (k==ccount)
k = 0;
*(r++) = color_table[0][k];
*(g++) = color_table[1][k];
*(b++) = color_table[2][k];
if (a)
*(a++) = color_table[3][k];
*r = color_table[0][k];
*g = color_table[1][k];
*b = color_table[2][k];
if (a) {
*a = color_table[3][k];
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3; g += 3; b += 3;
}
}
} else {
for (j=1; j<=w*2; j++) {
@@ -398,11 +392,15 @@ RLoadXPM(RContext *context, char *file, int index)
k = 0;
}
*(r++) = color_table[0][k];
*(g++) = color_table[1][k];
*(b++) = color_table[2][k];
if (a)
*(a++) = color_table[3][k];
*r = color_table[0][k];
*g = color_table[1][k];
*b = color_table[2][k];
if (a) {
*a = color_table[3][k];
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3; g += 3; b += 3;
}
}
}
}
@@ -594,11 +592,16 @@ RSaveXPM(RImage *image, char *filename)
colorCount = 1;
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
if (!a || *a++>127)
if (!a || *a>127) {
if (!addcolor(&colormap, *r, *g, *b, &colorCount)) {
goto uhoh;
}
r++; g++; b++;
}
}
if (a) {
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3; g += 3; b += 3;
}
}
}
@@ -611,7 +614,7 @@ RSaveXPM(RImage *image, char *filename)
colorCount, charsPerPixel);
/* write colormap data */
if (image->data[3]) {
if (a) {
for (i=0; i<charsPerPixel; i++)
transp[i] = ' ';
transp[i] = 0;
@@ -638,7 +641,7 @@ RSaveXPM(RImage *image, char *filename)
for (x = 0; x < image->width; x++) {
if (!a || *a++>127) {
if (!a || *a>127) {
tmpc = lookfor(colormap, (unsigned)*r<<16|(unsigned)*g<<8|(unsigned)*b);
fprintf(file, index2str(buf, tmpc->index, charsPerPixel));
@@ -646,7 +649,11 @@ RSaveXPM(RImage *image, char *filename)
fprintf(file, transp);
}
r++; g++; b++;
if (a) {
r += 4; g += 4; b += 4; a += 4;
} else {
r += 3; g += 3; b += 3;
}
}
if (y < image->height-1)

View File

@@ -54,11 +54,8 @@ RCreateImage(unsigned width, unsigned height, int alpha)
memset(image, 0, sizeof(RImage));
image->width = width;
image->height = height;
if (alpha) {
image->format = RRGBAFormat;
} else {
image->format = RRGBFormat;
}
image->format = alpha ? RRGBAFormat : RRGBFormat;
/* the +4 is to give extra bytes at the end of the buffer,
* so that we can optimize image conversion for MMX(tm).. see convert.c
*/
@@ -183,24 +180,18 @@ RCombineImages(RImage *image, RImage *src)
for (i=0; i<image->height*image->width; i++) {
alpha = *(s+3);
calpha = 255 - alpha;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
s++;
}
} else {
for (i=0; i<image->height*image->width; i++) {
alpha = *(s+3);
calpha = 255 - alpha;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; d++; s++;
*d++ |= *s++;
}
}
@@ -225,59 +216,50 @@ RCombineImagesWithOpaqueness(RImage *image, RImage *src, int opaqueness)
s = src->data;
c_opaqueness = 255 - opaqueness;
#define OP opaqueness
#define COP c_opaqueness
if (!HAS_ALPHA(src)) {
int dalpha = HAS_ALPHA(image);
#define COP c_opaqueness
for (i=0; i < image->width*image->height; i++) {
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
d++; s++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
d++; s++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
d++; s++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; d++; s++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; d++; s++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; d++; s++;
if (dalpha) {
d++;
}
}
#undef COP
} else {
int tmp;
if (!HAS_ALPHA(image)) {
for (i=0; i<image->width*image->height; i++) {
tmp = (*(s+3) * opaqueness)/256;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
s++;
}
} else {
for (i=0; i<image->width*image->height; i++) {
tmp = (*(s+3) * opaqueness)/256;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256;
d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d |= tmp;
d++; s++;
}
}
}
#undef OP
#undef COP
}
int
calculateCombineArea(RImage *des, RImage *src,
int *sx, int *sy,
int *swidth, int *sheight,
int *dx, int *dy) {
calculateCombineArea(RImage *des, RImage *src, int *sx, int *sy,
int *swidth, int *sheight, int *dx, int *dy)
{
if (*dx < 0) {
*sx = -*dx;
*swidth = *swidth + *dx;
@@ -363,12 +345,9 @@ RCombineArea(RImage *image, RImage *src, int sx, int sy, unsigned width,
for (x=0; x < width; x++) {
alpha = *(s+3);
calpha = 255 - alpha;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
s++; d++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
s++; d++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256;
s++; d++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; s++; d++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; s++; d++;
*d = (((int)*d * calpha) + ((int)*s * alpha))/256; s++; d++;
s++;
if (dalpha)
d++;
@@ -387,8 +366,7 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
{
int x, y, dwi, swi;
int c_opaqueness;
unsigned char *d;
unsigned char *s;
unsigned char *s, *d;
int dalpha = HAS_ALPHA(image);
int dch = (dalpha ? 4 : 3);
@@ -399,27 +377,25 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
dwi = (image->width - width)*dch;
c_opaqueness = 255 - opaqueness;
#define OP opaqueness
if (!HAS_ALPHA(src)) {
#define COP c_opaqueness
if (!HAS_ALPHA(src)) {
s = src->data + sy*src->width*3;
swi = (src->width - width) * 3;
for (y=0; y < height; y++) {
for (x=0; x < width; x++) {
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
s++; d++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
s++; d++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256;
s++; d++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; s++; d++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; s++; d++;
*d = (((int)*d *(int)COP) + ((int)*s *(int)OP))/256; s++; d++;
if (dalpha)
d++;
}
d += dwi; s += swi;
}
#undef COP
} else {
int tmp;
@@ -428,13 +404,10 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
for (y=0; y < height; y++) {
for (x=0; x < width; x++) {
tmp= (*(s+3) * opaqueness)/256;
*d = (((int)*d *(int)(255-tmp)) + ((int)*s *(int)tmp))/256;
d++; s++;
*d = (((int)*d *(int)(255-tmp)) + ((int)*s *(int)tmp))/256;
d++; s++;
*d = (((int)*d *(int)(255-tmp)) + ((int)*s *(int)tmp))/256;
d++; s++;
tmp = (*(s+3) * opaqueness)/256;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
*d = (((int)*d * (255-tmp)) + ((int)*s * tmp))/256; d++; s++;
s++;
if (dalpha)
d++;
@@ -443,6 +416,7 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
}
}
#undef OP
#undef COP
}
@@ -469,12 +443,9 @@ RCombineImageWithColor(RImage *image, RColor *color)
alpha = *(d+3);
nalpha = 255 - alpha;
*d = (((int)*d * alpha) + (r * nalpha))/256;
d++;
*d = (((int)*d * alpha) + (g * nalpha))/256;
d++;
*d = (((int)*d * alpha) + (b * nalpha))/256;
d++;
*d = (((int)*d * alpha) + (r * nalpha))/256; d++;
*d = (((int)*d * alpha) + (g * nalpha))/256; d++;
*d = (((int)*d * alpha) + (b * nalpha))/256; d++;
d++;
}
}

View File

@@ -30,7 +30,7 @@
#include <math.h>
#ifndef PI
#define PI 3.14159265
#define PI 3.141592654
#endif

View File

@@ -412,6 +412,7 @@ CLIST *contrib; /* array of contribution lists */
#define CLAMP(v,l,h) ((v)<(l) ? (l) : (v) > (h) ? (h) : v)
/* return of calloc is not checked if NULL in the function below! */
RImage*
RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height)
{

View File

@@ -163,7 +163,7 @@ RCreateImageFromDrawable(RContext *context, Drawable drawable, Pixmap mask)
if (!XGetGeometry(context->dpy, drawable, &baz, &foo, &foo,
&w, &h, &bar, &bar)) {
printf("wrlib:invalid window or pixmap passed to RCreateImageFromPixmap\n");
printf("wrlib: invalid window or pixmap passed to RCreateImageFromPixmap\n");
return NULL;
}
pimg = XGetImage(context->dpy, drawable, 0, 0, w, h, AllPlanes,

View File

@@ -120,7 +120,7 @@ RCreateXImage(RContext *context, int depth, unsigned width, unsigned height)
IPC_CREAT|0777);
if (rximg->info.shmid < 0) {
context->attribs->use_shared_memory = 0;
perror("wrlib:could not allocate shared memory segment");
perror("wrlib: could not allocate shared memory segment");
XDestroyImage(rximg->image);
goto retry_without_shm;
}
@@ -129,8 +129,8 @@ RCreateXImage(RContext *context, int depth, unsigned width, unsigned height)
if (rximg->info.shmaddr == (void*)-1) {
context->attribs->use_shared_memory = 0;
if (shmctl(rximg->info.shmid, IPC_RMID, 0) < 0)
perror("wrlib:shmctl");
perror("wrlib:could not allocate shared memory");
perror("wrlib: shmctl");
perror("wrlib: could not allocate shared memory");
XDestroyImage(rximg->image);
goto retry_without_shm;
}
@@ -149,9 +149,9 @@ RCreateXImage(RContext *context, int depth, unsigned width, unsigned height)
context->attribs->use_shared_memory = 0;
XDestroyImage(rximg->image);
if (shmdt(rximg->info.shmaddr) < 0)
perror("wrlib:shmdt");
perror("wrlib: shmdt");
if (shmctl(rximg->info.shmid, IPC_RMID, 0) < 0)
perror("wrlib:shmctl");
perror("wrlib: shmctl");
/* printf("wrlib:error attaching shared memory segment to XImage\n");
*/
goto retry_without_shm;
@@ -174,9 +174,9 @@ RDestroyXImage(RContext *context, RXImage *rximage)
XShmDetach(context->dpy, &rximage->info);
XDestroyImage(rximage->image);
if (shmdt(rximage->info.shmaddr) < 0)
perror("wrlib:shmdt");
perror("wrlib: shmdt");
if (shmctl(rximage->info.shmid, IPC_RMID, 0) < 0)
perror("wrlib:shmctl");
perror("wrlib: shmctl");
} else {
XDestroyImage(rximage->image);
}