-
Notifications
You must be signed in to change notification settings - Fork 14
feat: remove enum corner_location
#156
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ | |
|
|
||
| #include "render/egl.h" | ||
| #include "scenefx/types/fx/clipped_region.h" | ||
| #include "scenefx/types/fx/corner_location.h" | ||
|
|
||
| struct fx_gles_render_pass { | ||
| struct wlr_render_pass base; | ||
|
|
@@ -55,15 +54,14 @@ struct fx_gradient { | |
| struct fx_render_texture_options { | ||
| struct wlr_render_texture_options base; | ||
| const struct wlr_box *clip_box; // Used to clip csd. Ignored if NULL | ||
| enum corner_location corners; | ||
| int corner_radius; | ||
| struct fx_corner_fradii corners; | ||
| bool discard_transparent; | ||
| struct clipped_region clipped_region; | ||
| struct clipped_fregion clipped_region; | ||
| }; | ||
|
|
||
| struct fx_render_rect_options { | ||
| struct wlr_render_rect_options base; | ||
| struct clipped_region clipped_region; | ||
| struct clipped_fregion clipped_region; | ||
| }; | ||
|
|
||
| struct fx_render_rect_grad_options { | ||
|
|
@@ -73,21 +71,19 @@ struct fx_render_rect_grad_options { | |
|
|
||
| struct fx_render_rounded_rect_options { | ||
| struct wlr_render_rect_options base; | ||
| int corner_radius; | ||
| enum corner_location corners; | ||
| struct clipped_region clipped_region; | ||
| struct fx_corner_fradii corners; | ||
| struct clipped_fregion clipped_region; | ||
| }; | ||
|
|
||
| struct fx_render_rounded_rect_grad_options { | ||
| struct wlr_render_rect_options base; | ||
| struct fx_gradient gradient; | ||
| int corner_radius; | ||
| enum corner_location corners; | ||
| struct fx_corner_fradii corners; | ||
| }; | ||
|
|
||
| struct fx_render_box_shadow_options { | ||
| struct wlr_box box; | ||
| struct clipped_region clipped_region; | ||
| struct clipped_fregion clipped_region; | ||
| /* Clip region, leave NULL to disable clipping */ | ||
| const pixman_region32_t *clip; | ||
|
|
||
|
|
@@ -104,9 +100,8 @@ struct fx_render_blur_pass_options { | |
| bool use_optimized_blur; | ||
| bool ignore_transparent; | ||
| float blur_strength; | ||
| int corner_radius; | ||
| enum corner_location corners; | ||
| struct clipped_region clipped_region; | ||
| struct fx_corner_radii corners; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the other options have a |
||
| struct clipped_fregion clipped_region; | ||
| }; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,119 @@ | |
|
|
||
| #include <wlr/util/box.h> | ||
|
|
||
| #include "scenefx/types/fx/corner_location.h" | ||
| // uint16_t is a reasonable enough range for corner radius | ||
| // and makes it 8 bytes wide, making it cheap with optimisations | ||
| // Note: layout is on purpose to be clockwise | ||
| struct fx_corner_radii { | ||
| uint16_t top_left; | ||
| uint16_t top_right; | ||
| uint16_t bottom_right; | ||
| uint16_t bottom_left; | ||
| }; | ||
|
|
||
| struct fx_corner_fradii { | ||
| float top_left; | ||
| float top_right; | ||
| float bottom_right; | ||
| float bottom_left; | ||
| }; | ||
|
Comment on lines
+16
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fradii stuff is just needed on the scenefx side as far as I could tell, we should move it and its functions to a private header (unless I missed a case) |
||
|
|
||
| #define CORNER_RADIUS_MAX (UINT16_MAX) | ||
|
|
||
| static __always_inline uint16_t corner_radius_clamp(int radius) { | ||
| if (radius <= 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| if (radius > CORNER_RADIUS_MAX) { | ||
| return CORNER_RADIUS_MAX; | ||
| } | ||
|
|
||
| return radius; | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_new(int top_left, int top_right, int bottom_right, int bottom_left) { | ||
| return (struct fx_corner_radii) { | ||
| corner_radius_clamp(top_left), | ||
| corner_radius_clamp(top_right), | ||
| corner_radius_clamp(bottom_right), | ||
| corner_radius_clamp(bottom_left), | ||
| }; | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_all(int radius) { | ||
| return corner_radii_new(radius, radius, radius, radius); | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_none() { | ||
| return corner_radii_all(0); | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_top(int radius) { | ||
| return corner_radii_new(radius, radius, 0, 0); | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_bottom(int radius) { | ||
| return corner_radii_new(0, 0, radius, radius); | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_left(int radius) { | ||
| return corner_radii_new(radius, 0, 0, radius); | ||
| } | ||
|
|
||
| static __always_inline struct fx_corner_radii corner_radii_right(int radius) { | ||
| return corner_radii_new(0, radius, radius, 0); | ||
| } | ||
|
|
||
| struct fx_corner_radii fx_corner_radii_extend(struct fx_corner_radii corners, int extend); | ||
|
|
||
| void fx_corner_radii_transform(enum wl_output_transform transform, | ||
| struct fx_corner_radii *corners); | ||
|
|
||
| struct fx_corner_fradii fx_corner_radii_scale(struct fx_corner_radii, float scale); | ||
|
|
||
| bool fx_corner_radii_eq(struct fx_corner_radii lhs, struct fx_corner_radii rhs); | ||
|
|
||
| /** | ||
| * Retains the corner values from `input` based on if the corresponding corner value in `filter` is non-zero | ||
| * | ||
| * This can be compared to an `AND` operation | ||
| */ | ||
| static __always_inline struct fx_corner_radii fx_corner_radii_filter(struct fx_corner_radii input, struct fx_corner_radii filter) { | ||
| return corner_radii_new( | ||
| input.top_left && filter.top_left ? input.top_left : 0, | ||
| input.top_right && filter.top_right ? input.top_right : 0, | ||
| input.bottom_right && filter.bottom_right ? input.bottom_right : 0, | ||
| input.bottom_left && filter.bottom_left ? input.bottom_left : 0 | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Picks the value of the corner from `lhs` if non-zero, otherwise picks the corner value from `rhs` | ||
| * | ||
| * This can be compared to an `OR` operation | ||
| */ | ||
| static __always_inline struct fx_corner_radii fx_corner_radii_pick(struct fx_corner_radii lhs, struct fx_corner_radii rhs) { | ||
| return corner_radii_new( | ||
| lhs.top_left ? lhs.top_left : rhs.top_left, | ||
| lhs.top_right ? lhs.top_right : rhs.top_right, | ||
| lhs.bottom_right ? lhs.bottom_right : rhs.bottom_right, | ||
| lhs.bottom_left ? lhs.bottom_left : rhs.bottom_left | ||
| ); | ||
| }; | ||
|
|
||
| bool fx_corner_radii_is_empty(const struct fx_corner_radii* corners); | ||
|
|
||
| bool fx_corner_fradii_is_empty(const struct fx_corner_fradii* corners); | ||
|
|
||
| struct clipped_region { | ||
| struct wlr_box area; | ||
| int corner_radius; | ||
| enum corner_location corners; | ||
| struct fx_corner_radii corners; | ||
| }; | ||
|
|
||
| struct clipped_fregion { | ||
| struct wlr_box area; | ||
| struct fx_corner_fradii corners; | ||
| }; | ||
|
|
||
| struct clipped_region clipped_region_get_default(void); | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these changes actually add some LOC over the original implementation overall, I think we should scrap this bit to keep the diff lean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we save some LOC in fx_pass.c but I think we add more in shaders.c for a positive overall LOC diff, esp considering the
glUniform1fcalls in fx_pass can be oneliners now