mirror of
https://github.com/yshui/picom.git
synced 2024-11-18 13:55:36 -05:00
render: avoid left shifting negative values
It's undefined behavior. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
79f1d4e79d
commit
06c58d0b8e
2 changed files with 21 additions and 21 deletions
|
@ -16,4 +16,4 @@ AnalyzeTemporaryDtors: false
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: readability-magic-numbers.IgnoredIntegerValues
|
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||||
value: 4;8;16;24;32;1;2;3;4096
|
value: 4;8;16;24;32;1;2;3;4096;65536
|
||||||
|
|
40
src/render.c
40
src/render.c
|
@ -192,40 +192,40 @@ make_circle(int cx, int cy, int radius, uint32_t max_ntraps, xcb_render_trapezoi
|
||||||
double w;
|
double w;
|
||||||
while (k < max_ntraps) {
|
while (k < max_ntraps) {
|
||||||
y1 = (int)(-radius * cos(M_PI * k / max_ntraps));
|
y1 = (int)(-radius * cos(M_PI * k / max_ntraps));
|
||||||
traps[n].top = (cy + y1) << 16;
|
traps[n].top = (cy + y1) * 65536;
|
||||||
traps[n].left.p1.y = (cy + y1) << 16;
|
traps[n].left.p1.y = (cy + y1) * 65536;
|
||||||
traps[n].right.p1.y = (cy + y1) << 16;
|
traps[n].right.p1.y = (cy + y1) * 65536;
|
||||||
w = sqrt(radius * radius - y1 * y1) * 65536;
|
w = sqrt(radius * radius - y1 * y1) * 65536;
|
||||||
traps[n].left.p1.x = (int)((cx << 16) - w);
|
traps[n].left.p1.x = (int)((cx * 65536) - w);
|
||||||
traps[n].right.p1.x = (int)((cx << 16) + w);
|
traps[n].right.p1.x = (int)((cx * 65536) + w);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
k++;
|
k++;
|
||||||
y2 = (int)(-radius * cos(M_PI * k / max_ntraps));
|
y2 = (int)(-radius * cos(M_PI * k / max_ntraps));
|
||||||
} while (y1 == y2);
|
} while (y1 == y2);
|
||||||
|
|
||||||
traps[n].bottom = (cy + y2) << 16;
|
traps[n].bottom = (cy + y2) * 65536;
|
||||||
traps[n].left.p2.y = (cy + y2) << 16;
|
traps[n].left.p2.y = (cy + y2) * 65536;
|
||||||
traps[n].right.p2.y = (cy + y2) << 16;
|
traps[n].right.p2.y = (cy + y2) * 65536;
|
||||||
w = sqrt(radius * radius - y2 * y2) * 65536;
|
w = sqrt(radius * radius - y2 * y2) * 65536;
|
||||||
traps[n].left.p2.x = (int)((cx << 16) - w);
|
traps[n].left.p2.x = (int)((cx * 65536) - w);
|
||||||
traps[n].right.p2.x = (int)((cx << 16) + w);
|
traps[n].right.p2.x = (int)((cx * 65536) + w);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t make_rectangle(int x, int y, int wid, int hei, xcb_render_trapezoid_t traps[]) {
|
uint32_t make_rectangle(int x, int y, int wid, int hei, xcb_render_trapezoid_t traps[]) {
|
||||||
traps[0].top = y << 16;
|
traps[0].top = y * 65536;
|
||||||
traps[0].left.p1.y = y << 16;
|
traps[0].left.p1.y = y * 65536;
|
||||||
traps[0].left.p1.x = x << 16;
|
traps[0].left.p1.x = x * 65536;
|
||||||
traps[0].left.p2.y = (y + hei) << 16;
|
traps[0].left.p2.y = (y + hei) * 65536;
|
||||||
traps[0].left.p2.x = x << 16;
|
traps[0].left.p2.x = x * 65536;
|
||||||
traps[0].bottom = (y + hei) << 16;
|
traps[0].bottom = (y + hei) * 65536;
|
||||||
traps[0].right.p1.x = (x + wid) << 16;
|
traps[0].right.p1.x = (x + wid) * 65536;
|
||||||
traps[0].right.p1.y = y << 16;
|
traps[0].right.p1.y = y * 65536;
|
||||||
traps[0].right.p2.x = (x + wid) << 16;
|
traps[0].right.p2.x = (x + wid) * 65536;
|
||||||
traps[0].right.p2.y = (y + hei) << 16;
|
traps[0].right.p2.y = (y + hei) * 65536;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue