Ticket UUID: | f215a9fdaad50b6a2963258464cfd2f50f4d64 | |||
Title: | Revisiting [df4b603950] | |||
Type: | Patch | Version: | core-9-0-branch | |
Submitter: | chrstphrchvz | Created on: | 2025-08-08 17:40:50 | |
Subsystem: | 82. X11 Emulation | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Open | Last Modified: | 2025-08-16 01:42:49 | |
Resolution: | None | Closed By: | nobody | |
Closed on: | ||||
Description: |
To me, [df4b603950] seems like a combination of 2 issues. The primary issue was that TkScrollWindow() did not compute damage correctly when a widget was outside the visible portion of a toplevel, causing artifacts to appear. I think Marc's changes to TkScrollWindow() have fixed this. I find the distortion in those artifacts to be a secondary issue, because if only the changes to TkScrollWindow() were made, then there would have been no more artifacts to notice. I think there still exists a problem with CreateCGImageFromDrawableRect() where it can unexpectedly return a smaller image than requested. That led to the distorted scaling artifacts, but currently it can also lead to a buffer overread in XGetImage(). I want to say that the cause is that I neglected how CGImageCreateWithImageInRect() understandably does not “pad” the output image when specifying a rectangle extending outside of the input image. What I think CreateCGImageFromDrawableRect() should do instead is just always create a new bitmap context with the requested width and height, draw the image of the source drawable (pixmap or toplevel) at the correct offset into the new bitmap context (i.e. no need to obtain a subimage with CGImageCreateWithImageInRect()), then return the image from the new bitmap context. With this approach, there is nothing in XCopyArea() specifically to change from before; it continues to work with pixmaps and remains unaware of things like a toplevel's NSView. Here is the approach based on [b1b79d9302] (i.e. main branch from 5 months ago): https://github.com/chrstphrchvz/tk/commit/0bbbbc3c7e If there is interest in this, I can create a branch on Fossil. | |||
User Comments: |
chrstphrchvz added on 2025-08-16 01:42:49:
Please see Fossil branch bug-df4b603950-alt marc_culler (claiming to be Marc Culler) added on 2025-08-15 21:10:06: Hi Christopher. I think this sounds very good. > If there is interest in this, I can create a branch on Fossil. Would you please be so kind as to do that? Thanks. chrstphrchvz added on 2025-08-11 17:38:59: The approach here also allows [de6ef8276c] to be fixed; I verified this by no longer defining TK_CAN_RENDER_RGBA in tkMacOSXPort.h. chrstphrchvz added on 2025-08-08 23:05:10: Example script using TkImg to trigger a buffer overread in XGetImage() on a non-Retina display: package require Tk package require Img The overread occurs on the line: because XGetImage() is using a width (e.g. 223 pixels) which is wider than the image from CreateCGImageFromDrawableRect() (e.g. 180 pixels).pixel32 pixel = *((pixel32 *)(bitmap + m)); |
