vdpau: fix -Wabsolute-value warning
vdpau specifies that top-left is x0/y0, bottom-right is x1/y1 and that x0/y0 are inclusive while x1/y1 are exclusive. This commit remove the abs() usage and instead verifies that the VdpRects passed by the user matche the documentation. When they don't they're treated as empty rectangles. Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7846>
This commit is contained in:

committed by
Marge Bot

parent
c5973ede01
commit
cd1ac36ddd
@@ -334,8 +334,11 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
|
||||
res_tmpl.format = index_format;
|
||||
|
||||
if (destination_rect) {
|
||||
res_tmpl.width0 = abs(destination_rect->x0-destination_rect->x1);
|
||||
res_tmpl.height0 = abs(destination_rect->y0-destination_rect->y1);
|
||||
if (destination_rect->x1 > destination_rect->x0 &&
|
||||
destination_rect->y1 > destination_rect->y0) {
|
||||
res_tmpl.width0 = destination_rect->x1 - destination_rect->x0;
|
||||
res_tmpl.height0 = destination_rect->y1 - destination_rect->y0;
|
||||
}
|
||||
} else {
|
||||
res_tmpl.width0 = vlsurface->surface->texture->width0;
|
||||
res_tmpl.height0 = vlsurface->surface->texture->height0;
|
||||
@@ -467,8 +470,11 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
|
||||
vtmpl.buffer_format = format;
|
||||
|
||||
if (destination_rect) {
|
||||
vtmpl.width = abs(destination_rect->x0-destination_rect->x1);
|
||||
vtmpl.height = abs(destination_rect->y0-destination_rect->y1);
|
||||
if (destination_rect->x1 > destination_rect->x0 &&
|
||||
destination_rect->y1 > destination_rect->y0) {
|
||||
vtmpl.width = destination_rect->x1 - destination_rect->x0;
|
||||
vtmpl.height = destination_rect->y1 - destination_rect->y0;
|
||||
}
|
||||
} else {
|
||||
vtmpl.width = vlsurface->surface->texture->width0;
|
||||
vtmpl.height = vlsurface->surface->texture->height0;
|
||||
|
@@ -349,10 +349,16 @@ RectToPipeBox(const VdpRect *rect, struct pipe_resource *res)
|
||||
box.depth = 1;
|
||||
|
||||
if (rect) {
|
||||
box.x = MIN2(rect->x0, rect->x1);
|
||||
box.y = MIN2(rect->y0, rect->y1);
|
||||
box.width = abs(rect->x1 - rect->x0);
|
||||
box.height = abs(rect->y1 - rect->y0);
|
||||
if (rect->x1 > rect->x0 &&
|
||||
rect->y1 > rect->y0) {
|
||||
box.x = rect->x0;
|
||||
box.y = rect->y0;
|
||||
box.width = rect->x1 - box.x;
|
||||
box.height = rect->y1 - box.y;
|
||||
} else {
|
||||
box.width = 0;
|
||||
box.height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return box;
|
||||
|
Reference in New Issue
Block a user