diff --git a/src/internal.h b/src/internal.h index 358da256..0e41fbd7 100644 --- a/src/internal.h +++ b/src/internal.h @@ -233,6 +233,13 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c y = t; \ } +// Helper for non-premultiplied alpha to premultiplied alpha conversion +static inline unsigned char _glfwMultiplyAlpha(unsigned char alpha, + unsigned char value) +{ + return (unsigned char) ((value * (unsigned int) alpha) / 255); +} + //======================================================================== // Platform-independent structures diff --git a/src/wl_window.c b/src/wl_window.c index 521dc3c2..ca91a2f5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -588,10 +588,12 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, unsigned char* target = data; for (i = 0; i < image->width * image->height; i++, source += 4) { - *target++ = source[2]; - *target++ = source[1]; - *target++ = source[0]; - *target++ = source[3]; + unsigned char alpha = source[3]; + + *target++ = _glfwMultiplyAlpha(alpha, source[2]); + *target++ = _glfwMultiplyAlpha(alpha, source[1]); + *target++ = _glfwMultiplyAlpha(alpha, source[0]); + *target++ = alpha; } cursor->wl.buffer =