opt: optimize scale caculate
This commit is contained in:
46
src/maomao.c
46
src/maomao.c
@@ -147,7 +147,7 @@ struct dvec2 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ivec2 {
|
struct ivec2 {
|
||||||
int x, y;
|
int x, y, width, height;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -1183,42 +1183,47 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
|||||||
struct ivec2 offset;
|
struct ivec2 offset;
|
||||||
offset.x = 0;
|
offset.x = 0;
|
||||||
offset.y = 0;
|
offset.y = 0;
|
||||||
|
offset.width = 0;
|
||||||
|
offset.height = 0;
|
||||||
|
|
||||||
if (!ISTILED(c) && !c->animation.tagining && !c->animation.tagouted &&
|
if (!ISTILED(c) && !c->animation.tagining && !c->animation.tagouted &&
|
||||||
!c->animation.tagouting)
|
!c->animation.tagouting)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
|
int bottom_out_offset =
|
||||||
|
GEZERO(c->animation.current.y + c->animation.current.height -
|
||||||
|
c->mon->m.y - c->mon->m.height);
|
||||||
|
int right_out_offset =
|
||||||
|
GEZERO(c->animation.current.x + c->animation.current.width -
|
||||||
|
c->mon->m.x - c->mon->m.width);
|
||||||
|
int left_out_offset = GEZERO(c->mon->m.x - c->animation.current.x);
|
||||||
|
int top_out_offset = GEZERO(c->mon->m.y - c->animation.current.y);
|
||||||
|
int bw = (int)c->bw;
|
||||||
|
|
||||||
// // make tagout tagin animations not visible in other monitors
|
// // make tagout tagin animations not visible in other monitors
|
||||||
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
|
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
|
||||||
c->animation.tagouting) {
|
c->animation.tagouting) {
|
||||||
if (c->animation.current.x < c->mon->m.x) {
|
if (left_out_offset > 0) {
|
||||||
offsetx = c->mon->m.x - c->bw - c->animation.current.x;
|
offsetx = GEZERO(left_out_offset - bw);
|
||||||
offsetx = offsetx < 0 ? 0 : offsetx;
|
|
||||||
clip_box->x = clip_box->x + offsetx;
|
clip_box->x = clip_box->x + offsetx;
|
||||||
clip_box->width = clip_box->width - offsetx;
|
clip_box->width = clip_box->width - offsetx;
|
||||||
} else if (c->animation.current.x + c->animation.current.width >
|
} else if (right_out_offset > 0) {
|
||||||
c->mon->m.x + c->mon->m.width) {
|
clip_box->width = clip_box->width - right_out_offset;
|
||||||
clip_box->width = clip_box->width - (c->animation.current.x +
|
|
||||||
c->animation.current.width -
|
|
||||||
c->mon->m.x - c->mon->m.width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->animation.current.y < c->mon->m.y) {
|
if (top_out_offset > 0) {
|
||||||
offsety = c->mon->m.y - c->bw - c->animation.current.y;
|
offsety = GEZERO(top_out_offset - bw);
|
||||||
offsety = offsety < 0 ? 0 : offsety;
|
|
||||||
clip_box->y = clip_box->y + offsety;
|
clip_box->y = clip_box->y + offsety;
|
||||||
clip_box->height = clip_box->height - offsety;
|
clip_box->height = clip_box->height - offsety;
|
||||||
} else if (c->animation.current.y + c->animation.current.height >
|
} else if (bottom_out_offset > 0) {
|
||||||
c->mon->m.y + c->mon->m.height) {
|
clip_box->height = clip_box->height - bottom_out_offset;
|
||||||
clip_box->height =
|
|
||||||
clip_box->height -
|
|
||||||
(c->animation.current.y + c->animation.current.height -
|
|
||||||
c->mon->m.y - c->mon->m.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset.x = offsetx;
|
offset.x = offsetx;
|
||||||
offset.y = offsety;
|
offset.y = offsety;
|
||||||
|
offset.width = right_out_offset;
|
||||||
|
offset.height = bottom_out_offset;
|
||||||
|
|
||||||
if ((clip_box->width < 0 || clip_box->height < 0) &&
|
if ((clip_box->width < 0 || clip_box->height < 0) &&
|
||||||
(ISTILED(c) || c->animation.tagouting || c->animation.tagining)) {
|
(ISTILED(c) || c->animation.tagouting || c->animation.tagining)) {
|
||||||
@@ -1247,6 +1252,7 @@ void client_apply_clip(Client *c) {
|
|||||||
struct wlr_box clip_box;
|
struct wlr_box clip_box;
|
||||||
struct ivec2 offset;
|
struct ivec2 offset;
|
||||||
animationScale scale_data;
|
animationScale scale_data;
|
||||||
|
int bw = (int)c->bw;
|
||||||
|
|
||||||
if (!animations) {
|
if (!animations) {
|
||||||
c->animation.running = false;
|
c->animation.running = false;
|
||||||
@@ -1291,8 +1297,8 @@ void client_apply_clip(Client *c) {
|
|||||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
||||||
|
|
||||||
scale_data.should_scale = true;
|
scale_data.should_scale = true;
|
||||||
scale_data.width = clip_box.width - c->bw;
|
scale_data.width = clip_box.width - GEZERO(bw - offset.width);
|
||||||
scale_data.height = clip_box.height - c->bw;
|
scale_data.height = clip_box.height - GEZERO(bw - offset.height);
|
||||||
scale_data.width_scale =
|
scale_data.width_scale =
|
||||||
(float)scale_data.width / (geometry.width - offset.x);
|
(float)scale_data.width / (geometry.width - offset.x);
|
||||||
scale_data.height_scale =
|
scale_data.height_scale =
|
||||||
|
|||||||
Reference in New Issue
Block a user