mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
parent
165171f9c8
commit
93b4c828c1
@ -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
|
||||
|
@ -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 =
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user