Import Tk 8.6.10

This commit is contained in:
Steve Dower
2020-09-24 22:55:34 +01:00
parent 5ba5cbc9af
commit 42c69189d9
365 changed files with 24323 additions and 12832 deletions

View File

@@ -19,6 +19,9 @@
*/
#include "tkImgPhoto.h"
#ifdef MAC_OSX_TK
#define TKPUTIMAGE_CAN_BLEND
#endif
/*
* Declaration for internal Xlib function used here:
@@ -30,7 +33,7 @@ extern int _XInitImageFuncPtrs(XImage *image);
* Forward declarations
*/
#ifndef MAC_OSX_TK
#ifndef TKPUTIMAGE_CAN_BLEND
static void BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr,
int xOffset, int yOffset, int width, int height);
#endif
@@ -306,7 +309,7 @@ TkImgPhotoGet(
nGreen = nBlue = 0;
mono = 1;
instancePtr->visualInfo = *visInfoPtr;
switch (visInfoPtr->class) {
switch (visInfoPtr->c_class) {
case DirectColor:
case TrueColor:
nRed = 1 << CountBits(visInfoPtr->red_mask);
@@ -411,7 +414,7 @@ TkImgPhotoGet(
*
*----------------------------------------------------------------------
*/
#ifndef MAC_OSX_TK
#ifndef TKPUTIMAGE_CAN_BLEND
#ifndef _WIN32
#define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift))
#define GetGValue(rgb) (UCHAR(((rgb) & green_mask) >> green_shift))
@@ -486,7 +489,7 @@ BlendComplexAlpha(
* optimized.
*/
#if !(defined(_WIN32) || defined(MAC_OSX_TK))
#if !defined(_WIN32)
if (bgImg->depth < 24) {
unsigned char red_mlen, green_mlen, blue_mlen;
@@ -534,7 +537,7 @@ BlendComplexAlpha(
}
return;
}
#endif /* !_WIN32 && !MAC_OSX_TK */
#endif /* !_WIN32 */
for (y = 0; y < height; y++) {
line = (y + yOffset) * iPtr->masterPtr->width;
@@ -577,7 +580,7 @@ BlendComplexAlpha(
}
#undef ALPHA_BLEND
}
#endif /* MAC_OSX_TK */
#endif /* TKPUTIMAGE_CAN_BLEND */
/*
*----------------------------------------------------------------------
@@ -609,7 +612,9 @@ TkImgPhotoDisplay(
* to imageX and imageY. */
{
PhotoInstance *instancePtr = clientData;
#ifndef TKPUTIMAGE_CAN_BLEND
XVisualInfo visInfo = instancePtr->visualInfo;
#endif
/*
* If there's no pixmap, it means that an error occurred while creating
@@ -620,14 +625,13 @@ TkImgPhotoDisplay(
return;
}
#ifdef MAC_OSX_TK
#ifdef TKPUTIMAGE_CAN_BLEND
/*
* The Mac version of TkPutImage handles RGBA images directly. There is
* If TkPutImage can handle RGBA Ximages directly there is
* no need to call XGetImage or to do the Porter-Duff compositing by hand.
* We just let the CG graphics library do it, using the graphics hardware.
*/
unsigned char *rgbaPixels = instancePtr->masterPtr->pix32;
unsigned char *rgbaPixels = instancePtr->masterPtr->pix32;
XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels,
(unsigned int)instancePtr->width,
(unsigned int)instancePtr->height,
@@ -638,9 +642,10 @@ TkImgPhotoDisplay(
photo->data = NULL;
XDestroyImage(photo);
#else
if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA)
&& visInfo.depth >= 15
&& (visInfo.class == DirectColor || visInfo.class == TrueColor)) {
&& (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) {
Tk_ErrorHandler handler;
XImage *bgImg = NULL;
@@ -695,7 +700,7 @@ TkImgPhotoDisplay(
XSetClipMask(display, instancePtr->gc, None);
XSetClipOrigin(display, instancePtr->gc, 0, 0);
}
XFlush(display);
(void)XFlush(display);
#endif
}
@@ -943,7 +948,7 @@ IsValidPalette(
mono = 0;
}
switch (instancePtr->visualInfo.class) {
switch (instancePtr->visualInfo.c_class) {
case DirectColor:
case TrueColor:
if ((nRed > (1 << CountBits(instancePtr->visualInfo.red_mask)))
@@ -1208,8 +1213,8 @@ AllocateColors(
* store them in *colors.
*/
if ((colorPtr->visualInfo.class == DirectColor)
|| (colorPtr->visualInfo.class == TrueColor)) {
if ((colorPtr->visualInfo.c_class == DirectColor)
|| (colorPtr->visualInfo.c_class == TrueColor)) {
/*
* Direct/True Color: allocate shades of red, green, blue
@@ -1363,8 +1368,8 @@ AllocateColors(
*/
#ifndef _WIN32
if ((colorPtr->visualInfo.class != DirectColor)
&& (colorPtr->visualInfo.class != TrueColor)) {
if ((colorPtr->visualInfo.c_class != DirectColor)
&& (colorPtr->visualInfo.c_class != TrueColor)) {
colorPtr->flags |= MAP_COLORS;
}
#endif /* _WIN32 */
@@ -1390,8 +1395,8 @@ AllocateColors(
} else {
g = (i * (nGreen - 1) + 127) / 255;
b = (i * (nBlue - 1) + 127) / 255;
if ((colorPtr->visualInfo.class == DirectColor)
|| (colorPtr->visualInfo.class == TrueColor)) {
if ((colorPtr->visualInfo.c_class == DirectColor)
|| (colorPtr->visualInfo.c_class == TrueColor)) {
colorPtr->redValues[i] =
colors[r].pixel & colorPtr->visualInfo.red_mask;
colorPtr->greenValues[i] =
@@ -1585,7 +1590,7 @@ TkImgDisposeInstance(
if (instancePtr->pixels != None) {
Tk_FreePixmap(instancePtr->display, instancePtr->pixels);
}
if (instancePtr->gc != None) {
if (instancePtr->gc != NULL) {
Tk_FreeGC(instancePtr->display, instancePtr->gc);
}
if (instancePtr->imagePtr != NULL) {
@@ -1649,8 +1654,8 @@ TkImgDitherInstance(
* DirectColor with many colors).
*/
if ((colorPtr->visualInfo.class == DirectColor)
|| (colorPtr->visualInfo.class == TrueColor)) {
if ((colorPtr->visualInfo.c_class == DirectColor)
|| (colorPtr->visualInfo.c_class == TrueColor)) {
int nRed, nGreen, nBlue, result;
result = sscanf(colorPtr->id.palette, "%d/%d/%d", &nRed,