diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-06 13:30:03 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-07 08:56:28 +0000 |
commit | 0acab3c1ade23ac7b8dd16f87c2578a8cff0c505 (patch) | |
tree | 36802a7fcc218344613d65f2850f902ee0457057 /src/gui/rhi/qrhi_p_p.h | |
parent | f116221ab92a6273eb9cb589877a7177eafa2f1f (diff) |
rhi: Correct another scissor/viewport clamping problem
When x or y are >= the width or height of the render target, then the
width or height of the scissor/viewport rect is zero, no further logic
is needed.
This is different from the case of x or y being negative, because then
there is still a chance that there is an in-bounds area (if width or
height are large enough).
It is important to make this check based on the original value of x
and y, not the clamped ones. Otherwise we end up with a 1 pixel wide
region even when the expected result is a width or height of 0.
Previously the incorrect subtraction of 1 in the final clamping of w and h
masked this, but once that is fixed, the issue fixed here becomes visible
in the cubemap_scissor manual test.
Change-Id: I3d4b0a163a16aa1116b1e838fa95c0faf7b56a3d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi_p_p.h')
-rw-r--r-- | src/gui/rhi/qrhi_p_p.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 729b85c4d5..cf725632f4 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -260,11 +260,11 @@ bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T, const T widthOffset = *x < 0 ? -*x : 0; const T heightOffset = *y < 0 ? -*y : 0; + *w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0; + *h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0; *x = qBound<T>(0, *x, outputWidth - 1); *y = qBound<T>(0, *y, outputHeight - 1); - *w = qMax<T>(0, inputWidth - widthOffset); - *h = qMax<T>(0, inputHeight - heightOffset); if (*x + *w > outputWidth) *w = qMax<T>(0, outputWidth - *x); |