Tk Source Code

View Ticket
Login
Ticket UUID: b17dcd7168676c6cb8dd9ade07ddca1a39d912a4
Title: Windows: imgPhInstance-7.* test failures (wayland branch)
Type: Bug Version: wayland
Submitter: jan.nijtmans Created on: 2026-11-13 15:43:02
Subsystem: 41. Photo Images Assigned To: kevin_walzer
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2026-11-13 19:24:51
Resolution: None Closed By: nobody
    Closed on:
Description:

Running testcases on Windows (wayland branch)

tkImgPhoto.c
D:\a\tk\tk\tk\win\..\generic\tkImgPhoto.c(2453): warning C4101: 'offset': unreferenced local variable
tkImgPhInstance.c
D:\a\tk\tk\tk\win\..\generic\tkImgPhInstance.c(944): warning C4101: 'offset': unreferenced local variable
...
imgPhInstance.test

==== imgPhInstance-7.1 -gamma is applied FAILED ==== Contents of test case:

.c create image 10 10 -anchor nw -image photo.gamma update # 255 * (165/255) ** (1/2.0) = 205 pixelNear .c 20 20 #ffcd00

---- Result was: 0 ---- Result should have been (exact matching): 1 ==== imgPhInstance-7.1 FAILED

==== imgPhInstance-7.2 -palette is applied FAILED ==== Contents of test case:

.c create image 10 10 -anchor nw -image photo.palette update set colors {} for {set y 14} {$y < 18} {incr y} { for {set x 14} {$x < 18} {incr x} { lappend colors [testpixel .c $x $y] } } join [lsort -unique $colors]

---- Result was: #000000 ---- Result should have been (exact matching): #000000 #ffffff ==== imgPhInstance-7.2 FAILED

==== imgPhInstance-7.3 -palette 2 draws black and white pixels in place, Bug 481255 FAILED ==== Contents of test case:

set result {} foreach width {1 10 16 17 33 40} { image create photo photo.palette -width $width -height 3 -palette 2 for {set y 0} {$y < 3} {incr y} { for {set x 0} {$x < $width} {incr x} { set color [expr {($x + $y) % 3 ? "#ffffff" : "#000000"}] photo.palette put $color -to $x $y } } .c create image 10 10 -anchor nw -image photo.palette update for {set y 0} {$y < 3} {incr y} { for {set x 0} {$x < $width} {incr x} { set color [expr {($x + $y) % 3 ? "#ffffff" : "#000000"}] if {[testpixel .c [expr {10 + $x}] [expr {10 + $y}]] ne $color} { lappend result $width break } } if {[lindex $result end] eq $width} break } .c delete all image delete photo.palette } set result

---- Result was: 1 10 16 17 33 40 ---- Result should have been (exact matching):

==== imgPhInstance-7.3 FAILED

If I revert tkImgPhoto.c and tkImgPhInstance.c to the 'trunk' versions (removing the wayland-specific edits in those 2 files). The warnings are gone and the testcases pass.

So, something still needs to be done related to this.

User Comments: serhiy.storchaka added on 2026-11-13 19:24:51:

I do not propose to remove TK_CAN_RENDER_RGBA, and Jan's branch is only an experiment. The proposed change is only the condition of the early return in TkImgDitherInstance():

-#ifdef TK_CAN_RENDER_RGBA
+#ifdef TK_USE_WAYLAND
     /* Images with 8-bit color do not need dithering. */
     return;
 #else
 ...
-#endif  /*TK_CAN_RENDER_RGBA*/
+#endif  /*TK_USE_WAYLAND*/

Nothing changes on Wayland. On Windows and macOS, which also define TK_CAN_RENDER_RGBA, the pixmap of the instance is dithered again, as on main. imgPhInstance-7.* are skipped on Wayland (pixelProbe); they fail on Windows.


kevin_walzer added on 2026-11-13 18:40:43:
This is what I get testing with this branch on Wayland:

kevin@vbox:~/tk/tests$ tclsh9.1 imgPhInstance.test
imgPhInstance.test:	Total	11	Passed	0	Skipped	11	Failed	0
Number of tests skipped for each constraint:
	11	pixelProbe

There's a separate constraint that skips all the tests. 

I'm not happy with removing TK_CAN_RENDER_RGBA  - this is pretty foundational to Wayland.

serhiy.storchaka added on 2026-11-13 16:25:49:

The cause is [7170274de3]: TkImgDitherInstance() returns immediately if TK_CAN_RENDER_RGBA is defined, which is also the case on Windows and macOS. The fixes for [32f2e19de8] and [de6ef8276c] draw images with a non-default -gamma or -palette from the pixmap of the instance, which is filled by TkImgDitherInstance(), so now an empty pixmap is drawn.

The minimal fix is to limit that early return to Wayland, where -gamma and -palette would still be ignored. [8beb2a08a0] (branch rgba-gamma-palette) fixes them on all platforms which render RGBA images, including Wayland, without the pixmap.


jan.nijtmans added on 2026-11-13 15:47:38:

I created a [901032026|branch], which reverts the wayland-specific changes in tkImgPhoto.c and tkImgPhInstance.c. The imgPhInstance-7.* testcases now pass on Windows (but probably break things on Wayland).

Kevin, does this give any hints?