mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-10 02:25:46 +01:00
For libwraster:
---------------
- Added retain/release mechanism to RImage by adding RRetainImage() and
RReleaseImage(). RDestroyImage() is an alias to RReleaseImage() now, but
will be removed in a future release because it no longer fits with the
semantics. Will be kept for a while to allow a smoother transition.
More about in wrlib/NEWS
For WINGs:
----------
- Small API change:
1. Renamed WMSetApplicationIconImage(), WMGetApplicationIconImage() and
WMSetWindowMiniwindowImage() to respectively WMSetApplicationIconPixmap(),
WMGetApplicationIconPixmap() and WMSetWindowMiniwindowPixmap()
They operate on a WMPixmap which is practically an X Pixmap with no alpha
channel information and the new name is more suggestive and also leaves
room for the new functions added for operating on images with alpha info.
2. Added WMSetApplicationIconImage() and WMGetApplicationIconImage() which
operate on an RImage and store alpha information too.
3. Added WMGetApplicationIconBlendedPixmap() which will take the image with
alpha set by WMSetApplicationIconImage() and will blend it with a color.
If color is NULL it will blend using the default panel color (#aeaaae)
All these changes will allow WINGs to handle images with alpha blending
correctly in panels and wherever else needed. More about in WINGs/NEWS.
- updated panels to use the newly available RImages if present and fallback
to old WMPixmaps if not, to properly show alpha blended images.
- replaced some still left malloc's with wmalloc's.
For Window Maker:
-----------------
- Fixed wrong mapping position of the "Docked Applications Panel" for some
icons.
- Smoother animation for the smiley =)
- Made images with alpha blending be shown correctly in the panels and the
icon chooser.
- The icon image set to be shown in panels ("Logo.WMPanel") will be
automatically updated if its entry in WMWindowAttributes changes (without
a need to restart as until now).
*** Note!!! ***
If you are developing applications with one of libwraster or libWINGs
then you should look to wrlib/NEWS and WINGs/NEWS to see what changed
and how should you update your code.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
- Added retain/release mechanism to RImage by adding RRetainImage() and
|
||||
RReleaseImage(). RDestroyImage() is an alias to RReleaseImage() now, but
|
||||
will be removed in a future release because it no longer fits with the
|
||||
semantics. Will be kept for a while to allow a smoother transition.
|
||||
More about in NEWS
|
||||
|
||||
- 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.
|
||||
|
||||
@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = no-dependencies
|
||||
|
||||
lib_LTLIBRARIES = libwraster.la
|
||||
|
||||
libwraster_la_LDFLAGS = -version-info 3:0:1
|
||||
libwraster_la_LDFLAGS = -version-info 4:0:2
|
||||
|
||||
bin_SCRIPTS = get-wraster-flags
|
||||
|
||||
|
||||
28
wrlib/NEWS
28
wrlib/NEWS
@@ -0,0 +1,28 @@
|
||||
|
||||
Sat Apr 21 09:12:09 EEST 2001 -Dan
|
||||
|
||||
API change
|
||||
----------
|
||||
|
||||
To allow a retain/release mechanism to be implemented for RImages, the
|
||||
following new functions were introduced:
|
||||
|
||||
RImage* RRetainImage(RImage* image);
|
||||
void RReleaseImage(RImage* image);
|
||||
|
||||
RDestroyImage() is now aliased to RReleaseImage(), but because it's no
|
||||
longer compatible with the new semantics, it was only kept to allow a
|
||||
smoother transition and the ability to run programs that were not updated
|
||||
yet.
|
||||
|
||||
Do _NOT_ continue to use RDestroyImage(), because it will be removed in a
|
||||
future version. You should start using RReleaseImage() in your code, and
|
||||
also update all your existing programs to use RReleaseImage().
|
||||
|
||||
Also keep in mind that its name is also misleading: RDestroyImage() no
|
||||
longer destroys images, unless they are not retained in some other place.
|
||||
|
||||
All existing code will continue to function with the new lib, even if not
|
||||
recompiled, but you are encouraged to update your code to these changes
|
||||
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ REdgeDetectImage(RImage *image)
|
||||
image2->data[1] = g;
|
||||
b = image->data[2];
|
||||
image2->data[2] = b;
|
||||
RDestroyImage(image2);
|
||||
RReleaseImage(image2);
|
||||
}
|
||||
|
||||
#undef MASK
|
||||
|
||||
@@ -209,7 +209,7 @@ giferr:
|
||||
}
|
||||
bye:
|
||||
if (image)
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
image = NULL;
|
||||
did_not_get_any_errors:
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ renderDGradient(unsigned width, unsigned height, int r0, int g0, int b0,
|
||||
|
||||
tmp = renderHGradient(2*width-1, 1, r0, g0, b0, rf, gf, bf);
|
||||
if (!tmp) {
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ renderDGradient(unsigned width, unsigned height, int r0, int g0, int b0,
|
||||
offset += a;
|
||||
}
|
||||
|
||||
RDestroyImage(tmp);
|
||||
RReleaseImage(tmp);
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ renderMDGradient(unsigned width, unsigned height, RColor **colors, int count)
|
||||
colors[1]->blue<<8);
|
||||
|
||||
if (!tmp) {
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
ptr = tmp->data;
|
||||
@@ -485,16 +485,17 @@ renderMDGradient(unsigned width, unsigned height, RColor **colors, int count)
|
||||
memcpy(&(image->data[j]), &ptr[3*(int)offset], width);
|
||||
offset += a;
|
||||
}
|
||||
RDestroyImage(tmp);
|
||||
RReleaseImage(tmp);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
RImage *RRenderInterwovenGradient(unsigned width, unsigned height,
|
||||
RColor colors1[2], int thickness1,
|
||||
RColor colors2[2], int thickness2)
|
||||
RImage*
|
||||
RRenderInterwovenGradient(unsigned width, unsigned height,
|
||||
RColor colors1[2], int thickness1,
|
||||
RColor colors2[2], int thickness2)
|
||||
{
|
||||
int i, j, k, l, ll;
|
||||
unsigned long r1, g1, b1, dr1, dg1, db1;
|
||||
|
||||
@@ -184,7 +184,7 @@ RLoadImage(RContext *context, char *file, int index)
|
||||
} else {
|
||||
free(RImageCache[i].file);
|
||||
RImageCache[i].file = NULL;
|
||||
RDestroyImage(RImageCache[i].image);
|
||||
RReleaseImage(RImageCache[i].image);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ RLoadImage(RContext *context, char *file, int index)
|
||||
/* if no slot available, dump least recently used one */
|
||||
if (!done) {
|
||||
free(RImageCache[oldest_idx].file);
|
||||
RDestroyImage(RImageCache[oldest_idx].image);
|
||||
RReleaseImage(RImageCache[oldest_idx].image);
|
||||
RImageCache[oldest_idx].file = malloc(strlen(file)+1);
|
||||
strcpy(RImageCache[oldest_idx].file, file);
|
||||
RImageCache[oldest_idx].image = RCloneImage(image);
|
||||
|
||||
@@ -223,7 +223,7 @@ RGetImageFromXPMData(RContext *context, char **data)
|
||||
alloca(0);
|
||||
#endif
|
||||
if (image)
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ RLoadXPM(RContext *context, char *file, int index)
|
||||
alloca(0);
|
||||
#endif
|
||||
if (image)
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
|
||||
bad_file:
|
||||
@@ -428,7 +428,7 @@ RLoadXPM(RContext *context, char *file, int index)
|
||||
alloca(0);
|
||||
#endif
|
||||
if (image)
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ RLoadPNG(RContext *context, char *file, int index)
|
||||
fclose(f);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
if (image)
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ RLoadPNG(RContext *context, char *file, int index)
|
||||
if (!png_rows) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
fclose(f);
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
#ifdef C_ALLOCA
|
||||
alloca(0);
|
||||
@@ -189,7 +189,7 @@ RLoadPNG(RContext *context, char *file, int index)
|
||||
if (!png_rows[y]) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
fclose(f);
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
#ifdef C_ALLOCA
|
||||
alloca(0);
|
||||
|
||||
@@ -55,6 +55,7 @@ RCreateImage(unsigned width, unsigned height, int alpha)
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->format = alpha ? RRGBAFormat : RRGBFormat;
|
||||
image->refCount = 1;
|
||||
|
||||
/* 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
|
||||
@@ -70,6 +71,44 @@ RCreateImage(unsigned width, unsigned height, int alpha)
|
||||
}
|
||||
|
||||
|
||||
RImage*
|
||||
RRetainImage(RImage *image)
|
||||
{
|
||||
if (image)
|
||||
image->refCount++;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RReleaseImage(RImage *image)
|
||||
{
|
||||
assert(image!=NULL);
|
||||
|
||||
image->refCount--;
|
||||
|
||||
if (image->refCount < 1) {
|
||||
free(image->data);
|
||||
free(image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Obsoleted function. Use RReleaseImage() instead. This was kept only to
|
||||
* allow a smoother transition and to avoid breaking existing programs, but
|
||||
* it will be removed in a future release. Right now is just an alias to
|
||||
* RReleaseImage(). Do _NOT_ use RDestroyImage() anymore in your programs.
|
||||
* Being an alias to RReleaseImage() this function no longer actually
|
||||
* destroys the image, unless the image is no longer retained in some other
|
||||
* place.
|
||||
*/
|
||||
void
|
||||
RDestroyImage(RImage *image)
|
||||
{
|
||||
RReleaseImage(image);
|
||||
}
|
||||
|
||||
|
||||
RImage*
|
||||
RCloneImage(RImage *image)
|
||||
@@ -126,16 +165,6 @@ RGetSubImage(RImage *image, int x, int y, unsigned width, unsigned height)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RDestroyImage(RImage *image)
|
||||
{
|
||||
assert(image!=NULL);
|
||||
|
||||
free(image->data);
|
||||
free(image);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* RCombineImages-
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
static RImage *rotateImage(RImage *image, float angle);
|
||||
|
||||
|
||||
RImage *RRotateImage(RImage *image, float angle)
|
||||
RImage*
|
||||
RRotateImage(RImage *image, float angle)
|
||||
{
|
||||
RImage *img;
|
||||
int nwidth, nheight;
|
||||
@@ -207,8 +208,9 @@ RImage *RRotateImage(RImage *image, float angle)
|
||||
*/
|
||||
|
||||
|
||||
static void copyLine(int x1, int y1, int x2, int y2, int nwidth, int format,
|
||||
unsigned char *dst, unsigned char **src)
|
||||
static void
|
||||
copyLine(int x1, int y1, int x2, int y2, int nwidth, int format,
|
||||
unsigned char *dst, unsigned char **src)
|
||||
{
|
||||
unsigned char *s = *src;
|
||||
int dx, dy;
|
||||
@@ -283,7 +285,8 @@ static void copyLine(int x1, int y1, int x2, int y2, int nwidth, int format,
|
||||
}
|
||||
|
||||
|
||||
static RImage *rotateImage(RImage *image, float angle)
|
||||
static RImage*
|
||||
rotateImage(RImage *image, float angle)
|
||||
{
|
||||
RImage *img;
|
||||
int nwidth, nheight;
|
||||
|
||||
@@ -617,7 +617,7 @@ RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||
}
|
||||
free(contrib);
|
||||
|
||||
RDestroyImage(tmp);
|
||||
RReleaseImage(tmp);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ testDraw()
|
||||
exit(1);
|
||||
}
|
||||
RCombineArea(img, icon, 0, 0, icon->width, icon->height, 8, 8);
|
||||
RDestroyImage(icon);
|
||||
RReleaseImage(icon);
|
||||
tmp = img;
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 64, 0);
|
||||
@@ -88,7 +88,7 @@ testDraw()
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 0, 64);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
img = RCloneImage(tile);
|
||||
|
||||
/* Alter random pixels in image with the same amount for r/g/b */
|
||||
@@ -103,7 +103,7 @@ testDraw()
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 64, 64);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
img = RCloneImage(tile);
|
||||
|
||||
/* Draw lines in all directions to test different slopes */
|
||||
@@ -133,7 +133,7 @@ testDraw()
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 0, 128);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
img = RCloneImage(tile);
|
||||
|
||||
/* Alter lines in all directions (test different slopes) */
|
||||
@@ -144,7 +144,7 @@ testDraw()
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 64, 128);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
/* Create a bevel around the icon, and save it for a later use */
|
||||
img = tmp;
|
||||
@@ -156,7 +156,7 @@ testDraw()
|
||||
cdelta.alpha = 0;
|
||||
ROperateLine(img, RSubtractOperation, 8, 56, 56, 56, &cdelta);
|
||||
ROperateLine(img, RSubtractOperation, 56, 8, 56, 55, &cdelta);
|
||||
RDestroyImage(tile);
|
||||
RReleaseImage(tile);
|
||||
tmp = RCloneImage(img);
|
||||
|
||||
/* Draw some solid lines over the icon */
|
||||
@@ -177,7 +177,7 @@ testDraw()
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 0, 192);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
/* Restore the image with the icon, and alter some lines */
|
||||
img = tmp;
|
||||
@@ -247,7 +247,7 @@ testBevel()
|
||||
RClearImage(img, &color);
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 140, 140, 0, 0);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
tile = RRenderGradient(64, 64, &from, &to, RGRD_DIAGONAL);
|
||||
|
||||
@@ -255,25 +255,25 @@ testBevel()
|
||||
RBevelImage(img, RBEV_SUNKEN);
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 3, 3);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
img = RCloneImage(tile);
|
||||
RBevelImage(img, RBEV_RAISED);
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 73, 3);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
img = RCloneImage(tile);
|
||||
RBevelImage(img, RBEV_RAISED2);
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 3, 73);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
img = RCloneImage(tile);
|
||||
RBevelImage(img, RBEV_RAISED3);
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 73, 73);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
XSetWindowBackgroundPixmap(dpy, win, back);
|
||||
XMapRaised(dpy, win);
|
||||
@@ -306,7 +306,7 @@ void testScale()
|
||||
|
||||
scaled = RScaleImage(image, 140, 140);
|
||||
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
RConvertImage(ctx, scaled, &pix);
|
||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||
XMapRaised(dpy, win);
|
||||
@@ -345,7 +345,7 @@ void testRotate()
|
||||
|
||||
rotated = RRotateImage(image, 90.0);
|
||||
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
RConvertImage(ctx, rotated, &pix);
|
||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||
XMapRaised(dpy, win);
|
||||
@@ -478,7 +478,7 @@ drawClip()
|
||||
|
||||
RConvertImage(ctx, img, &pix);
|
||||
XCopyArea(dpy, pix, back, ctx->copy_gc, 0, 0, 64, 64, 0, 0);
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
|
||||
XSetWindowBackgroundPixmap(dpy, win, back);
|
||||
XMapRaised(dpy, win);
|
||||
@@ -576,7 +576,7 @@ benchmark()
|
||||
}
|
||||
printf("Average: %f, %f, %f\n", d1/5, d2/5, d3/5);
|
||||
|
||||
RDestroyImage(img);
|
||||
RReleaseImage(img);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
|
||||
puts(RMessageForError(RErrorCode));
|
||||
exit(1);
|
||||
}
|
||||
RDestroyImage(tmp);
|
||||
RReleaseImage(tmp);
|
||||
|
||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||
XFreePixmap(dpy, pix);
|
||||
|
||||
@@ -42,7 +42,7 @@ main(int argc, char **argv)
|
||||
|
||||
img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
|
||||
tmp->height*atol(argv[2]));
|
||||
RDestroyImage(tmp);
|
||||
RReleaseImage(tmp);
|
||||
}
|
||||
*/
|
||||
#if 0
|
||||
|
||||
@@ -191,10 +191,11 @@ enum RImageFormat {
|
||||
* internal 24bit+alpha image representation
|
||||
*/
|
||||
typedef struct RImage {
|
||||
unsigned char *data; /* image data RGBA or RGB */
|
||||
unsigned char *data; /* image data RGBA or RGB */
|
||||
int width, height; /* size of the image */
|
||||
enum RImageFormat format;
|
||||
RColor background; /* background color */
|
||||
RColor background; /* background color */
|
||||
int refCount;
|
||||
} RImage;
|
||||
|
||||
|
||||
@@ -322,7 +323,18 @@ RImage *RCreateImageFromDrawable(RContext *context, Drawable drawable,
|
||||
|
||||
RImage *RLoadImage(RContext *context, char *file, int index);
|
||||
|
||||
RImage* RRetainImage(RImage *image);
|
||||
|
||||
void RReleaseImage(RImage *image);
|
||||
|
||||
/* Obsoleted function. Use RReleaseImage() instead. This was kept only to
|
||||
* allow a smoother transition and to avoid breaking existing programs, but
|
||||
* it will be removed in a future release. Right now is just an alias to
|
||||
* RReleaseImage(). Do _NOT_ use RDestroyImage() anymore in your programs.
|
||||
* Being an alias to RReleaseImage() this function no longer actually
|
||||
* destroys the image, unless the image is no longer retained in some other
|
||||
* place.
|
||||
*/
|
||||
void RDestroyImage(RImage *image);
|
||||
|
||||
RImage *RGetImageFromXPMData(RContext *context, char **xpmData);
|
||||
|
||||
@@ -87,7 +87,7 @@ RGetImageFromXPMData(RContext *context, char **xpmData)
|
||||
if (color_table[i])
|
||||
free(color_table[i]);
|
||||
}
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
XpmFreeXpmImage(&xpm);
|
||||
return NULL;
|
||||
@@ -210,7 +210,7 @@ RLoadXPM(RContext *context, char *file, int index)
|
||||
if (color_table[i])
|
||||
free(color_table[i]);
|
||||
}
|
||||
RDestroyImage(image);
|
||||
RReleaseImage(image);
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
XpmFreeXpmImage(&xpm);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user