Revise shapePhoto() to not use TkPhotoGetValidRegion()#8
Open
chrstphrchvz wants to merge 4 commits intodkfellows:trunkfrom
Open
Revise shapePhoto() to not use TkPhotoGetValidRegion()#8chrstphrchvz wants to merge 4 commits intodkfellows:trunkfrom
shapePhoto() to not use TkPhotoGetValidRegion()#8chrstphrchvz wants to merge 4 commits intodkfellows:trunkfrom
Conversation
Owner
|
Requiring post-8.3 is trivial these days. Anyone using a version of Tk that doesn't have an alpha channel in photo images is also quite able to use the old versions of this code. |
shape.c:404:47: error: cannot take the address of an rvalue of type 'void *'
404 | imageName = Tcl_GetStringFromObj(objv[0], &NULL);
| ^~~~~
Remove unneeded includes, macros, and configure checks
7257da3 to
5be84f9
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
shapePhoto()currently works by obtaining a region fromTkPhotoGetValidRegion()and passing it toShape_CombineRegion()(and in turnXShapeCombineRegion()on X11). However,TkPhotoGetValidRegion()is not a public Tk C API. And as discussed at https://core.tcl-lang.org/tk/info/919066 it takes a very long time to compute the region for some images, and I am not aware of an instance in core Tk or an extension where using this region is strictly necessary. Tk could draw photo image instances using a clip mask rather than a region (as attempted in chrstphrchvz/tk#4). I propose thatshapePhoto()follow a similar approach: use the public APITk_PhotoGetImage()to access alpha channel data and create a bitmap (pixmap with depth of 1) for use a clip mask to be passed toShape_CombineBitmap()(and in turnXShapeCombineMask()on X11).Note that this would leave
Shape_CombineRegion()unused within the shape extension.If Tk 8.3 or later can be required, then this approach allows photo shape source support to be enabled unconditionally. That should also make it okay for demos to use a photo shape source. As an example, I propose revising the dragger.tcl demo: instead of using doc-mask.xbm as a bitmap shape source, make doc-img.gif have a transparent background and use it as a photo shape source; the demo should look the same as before.
I have tested this using recent Tk core-8-6-branch on XQuartz (macOS), after applying demo and build fixes/workarounds (some from #7, some not reported). Some build fixes are currently included in this pull request, but can be moved to another pull request if desirable.