mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 08:39:45 +00:00
wayland: Pre-multiply custom cursor image alpha
Since the Wayland SHM buffer format is implicitly premultiplied and the GLFWimage pixels are defined to be non-premultiplied, we need to convert the non-premultiplied pixels to premultiplied when filling the buffer. Related to #707.
This commit is contained in:
committed by
Camilla Berglund
parent
cb08dc574c
commit
71c72db1e3
+6
-4
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user