Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua imlib2 fixes #1729

Merged
merged 13 commits into from
Mar 11, 2024
Merged

Lua imlib2 fixes #1729

merged 13 commits into from
Mar 11, 2024

Conversation

simotek
Copy link
Contributor

@simotek simotek commented Feb 22, 2024

Checklist

  • I have described the changes
  • I have linked to any relevant GitHub issues, if applicable
  • Documentation in doc/ has been updated
  • All new code is licensed under GPLv3

Description

A range of fixes for the cairo_imlib2 lua helper, after using it for a couple of days

1. Significantly improve error reporting

Previously if you had an error in your code you would get an error message for each call to imlib2 which lead to alot of spam. Instead we now detect and print our own error message for common errors then return to help with this.

2. Implement Stride in a standard way

This doesn't actually fix anything but I noticed it could be improved when I was debugging something else.

3. Scale Alpha masks correctly.

We weren't scaling the output of the alpha mask to the size of the image we were displaying, which lead to the ugly artifacts that can be seen below. (Ignore the general incompleteness of the actual config its half done)

** Broken Image: **
shot-2024-02-22_17-36-46

** Fixed Image: **
shot-2024-02-22_17-35-14

4. Add Docs

Adds similar docs to the one's being worked on for cairo-text-helper

@github-actions github-actions bot added the documentation Issue or PR that suggests documentation improvements label Feb 22, 2024
Copy link

netlify bot commented Feb 22, 2024

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit 745df42
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/65ef627403a8680008e475ce

Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start, but can you use the logging functions from logging.h instead of printf? I think NORM_ERR should do what you need.

doc/lua.yaml Outdated Show resolved Hide resolved
@brndnmtthws brndnmtthws added bug Bug report or bug fix PR enhancement Issue that suggests an enhancement labels Feb 22, 2024
@simotek
Copy link
Contributor Author

simotek commented Feb 23, 2024

To make this really usable for my use case I suspect i'll have one more feature commit to add to this PR later today but as this stands hopefully it is an improvement on the existing codebase.

@simotek
Copy link
Contributor Author

simotek commented Feb 26, 2024

I've added one more function cairo_place_image which splits the existing function in half, keeping the existing API but also adding another that is more useful in some cases. Hopefully i'll get to fixing up that nix build tomorrow.

lua/CMakeLists.txt Outdated Show resolved Hide resolved
@simotek
Copy link
Contributor Author

simotek commented Mar 5, 2024

@brndnmtthws I have no idea why Nix build / build-and-check (macos-latest) (pull_request) is failing, it seems not to find imlib2 or something, but all the other builds seem fine.

@brndnmtthws
Copy link
Owner

@brndnmtthws I have no idea why Nix build / build-and-check (macos-latest) (pull_request) is failing, it seems not to find imlib2 or something, but all the other builds seem fine.

Yeah that's odd, let me see if I can figure it out.

@github-actions github-actions bot added the sources PR modifies project sources label Mar 5, 2024
@brndnmtthws
Copy link
Owner

imlib2.h and Imlib2.h conflict because we are now including src/, and I guess macos is less strict about case sensitivity.

simotek and others added 13 commits March 11, 2024 15:57
Each of the following cases cause large numbers of cryptic imlib2
prints, so detect them and print a single error for each.
Previously if the source image was a different to the displayed
image the alpha channel was incorrect, as it wasn't scaled leading
to a series of artifacts.
Unfortunately we can't use logging.h directly from conky as its
in C++ and lua bindings only have access to a C compiler.

Instead we now have a very simple C implementation of logging.h to
use within the bindings.

This change also adds NULL checks to catch some extra invalid
states
In some cases you are already working with a cairo_t and know
your destination image size, this adds an API that allows you
to handle these cases more easily. Along with now being able to
draw images with an alpha level. It also leaves the original API
unchanged.
Along with some other minor merge / C++ fixes.`
Co-authored-by: Brenden Matthews <github@brenden.brndn.io>
@brndnmtthws brndnmtthws merged commit eb25f87 into brndnmtthws:main Mar 11, 2024
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report or bug fix PR documentation Issue or PR that suggests documentation improvements enhancement Issue that suggests an enhancement sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants