diff --git a/src/internal.h b/src/internal.h index 0e41fbd7..358da256 100644 --- a/src/internal.h +++ b/src/internal.h @@ -233,13 +233,6 @@ 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 ca91a2f5..b3b9bea2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -588,12 +588,12 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, unsigned char* target = data; for (i = 0; i < image->width * image->height; i++, source += 4) { - unsigned char alpha = source[3]; + unsigned int alpha = source[3]; - *target++ = _glfwMultiplyAlpha(alpha, source[2]); - *target++ = _glfwMultiplyAlpha(alpha, source[1]); - *target++ = _glfwMultiplyAlpha(alpha, source[0]); - *target++ = alpha; + *target++ = (unsigned char) ((source[2] * alpha) / 255); + *target++ = (unsigned char) ((source[1] * alpha) / 255); + *target++ = (unsigned char) ((source[0] * alpha) / 255); + *target++ = (unsigned char) alpha; } cursor->wl.buffer = diff --git a/src/x11_init.c b/src/x11_init.c index 0125a8b7..e73bb131 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -690,12 +690,12 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot) for (i = 0; i < image->width * image->height; i++, target++, source += 4) { - unsigned char alpha = source[3]; + unsigned int alpha = source[3]; *target = (alpha << 24) | - (_glfwMultiplyAlpha(alpha, source[0]) << 16) | - (_glfwMultiplyAlpha(alpha, source[1]) << 8) | - _glfwMultiplyAlpha(alpha, source[2]); + ((unsigned char) ((source[0] * alpha) / 255) << 16) | + ((unsigned char) ((source[1] * alpha) / 255) << 8) | + ((unsigned char) ((source[2] * alpha) / 255) << 0); } cursor = XcursorImageLoadCursor(_glfw.x11.display, native);