yshui / picom

A lightweight compositor for X11
Other
3.93k stars 575 forks source link

backend: give images a type #1182

Closed yshui closed 4 months ago

yshui commented 4 months ago

It's quite confusing what should be passed into what because too many things are void *. So give images a type to make things a bit clearer. Because of C's limited type system, we lose the ability to annotate them as nonnull or const, well you win some you lose some.

Also while doing this I noticed error handling around this is a bit lacking.

codecov[bot] commented 4 months ago

Codecov Report

Attention: 61 lines in your changes are missing coverage. Please review.

Comparison is base (7f3f8b3) 36.24% compared to head (2d98518) 36.10%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/yshui/picom/pull/1182/graphs/tree.svg?width=650&height=150&src=pr&token=NRSegi0Gze&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui)](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui) ```diff @@ Coverage Diff @@ ## next #1182 +/- ## ========================================== - Coverage 36.24% 36.10% -0.15% ========================================== Files 50 50 Lines 11485 11490 +5 ========================================== - Hits 4163 4148 -15 - Misses 7322 7342 +20 ``` | [Files](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui) | Coverage Δ | | |---|---|---| | [src/backend/gl/gl\_common.h](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZ2wvZ2xfY29tbW9uLmg=) | `19.44% <ø> (ø)` | | | [src/common.h](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2NvbW1vbi5o) | `77.77% <ø> (ø)` | | | [src/win.h](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL3dpbi5o) | `78.12% <ø> (ø)` | | | [src/backend/gl/egl.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZ2wvZWdsLmM=) | `17.24% <0.00%> (ø)` | | | [src/backend/gl/glx.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZ2wvZ2x4LmM=) | `31.06% <0.00%> (ø)` | | | [src/backend/gl/blur.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZ2wvYmx1ci5j) | `0.00% <0.00%> (ø)` | | | [src/backend/backend\_common.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvYmFja2VuZF9jb21tb24uYw==) | `39.38% <20.00%> (ø)` | | | [src/backend/dummy/dummy.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZHVtbXkvZHVtbXkuYw==) | `65.38% <35.00%> (-0.41%)` | :arrow_down: | | [src/backend/gl/gl\_common.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQvZ2wvZ2xfY29tbW9uLmM=) | `26.20% <0.00%> (-0.04%)` | :arrow_down: | | [src/backend/xrender/xrender.c](https://app.codecov.io/gh/yshui/picom/pull/1182?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui#diff-c3JjL2JhY2tlbmQveHJlbmRlci94cmVuZGVyLmM=) | `0.00% <0.00%> (ø)` | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/yshui/picom/pull/1182/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yuxuan+Shui)
yshui commented 4 months ago

wait, i am having second thoughts.

i think instead of

typedef struct {
    void *p;
} image_handle;

it would be better to have:

typedef struct {
    /* intentionally left blank */
} *image_handle;