From b7312a11d4e73ca86846a7caacd81da535707abc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 22 Dec 2020 10:46:51 +0900 Subject: [PATCH] sw_engine raster: fix incorrect condition check. These values won't be less than zero since they are unsigned types. --- src/lib/sw_engine/tvgSwRaster.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index 5518c49a..c65a2cb6 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -154,7 +154,7 @@ static bool _rasterTranslucentImageRle(SwSurface* surface, SwRleData* rle, uint3 for (uint32_t x = 0; x < span->len; ++x, ++dst) { auto rX = static_cast(roundf((span->x + x) * invTransform->e11 + ey1)); auto rY = static_cast(roundf((span->x + x) * invTransform->e21 + ey2)); - if (rX < 0 || rX >= w || rY < 0 || rY >= h) continue; + if (rX >= w || rY >= h) continue; auto alpha = ALPHA_MULTIPLY(span->coverage, opacity); auto src = ALPHA_BLEND(img[rY * w + rX], alpha); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->comp.alpha(src)); @@ -176,7 +176,7 @@ static bool _rasterImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, u for (uint32_t x = 0; x < span->len; ++x, ++dst) { auto rX = static_cast(roundf((span->x + x) * invTransform->e11 + ey1)); auto rY = static_cast(roundf((span->x + x) * invTransform->e21 + ey2)); - if (rX < 0 || rX >= w || rY < 0 || rY >= h) continue; + if (rX >= w || rY >= h) continue; auto src = ALPHA_BLEND(img[rY * w + rX], span->coverage); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->comp.alpha(src)); } @@ -195,7 +195,7 @@ static bool _rasterTranslucentImage(SwSurface* surface, uint32_t *img, uint32_t for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { auto rX = static_cast(roundf(x * invTransform->e11 + ey1)); auto rY = static_cast(roundf(x * invTransform->e21 + ey2)); - if (rX < 0 || rX >= w || rY < 0 || rY >= h) continue; + if (rX >= w || rY >= h) continue; auto src = ALPHA_BLEND(img[rX + (rY * w)], opacity); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->comp.alpha(src)); } @@ -226,7 +226,7 @@ static bool _rasterImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { auto rX = static_cast(roundf(x * invTransform->e11 + ey1)); auto rY = static_cast(roundf(x * invTransform->e21 + ey2)); - if (rX < 0 || rX >= w || rY < 0 || rY >= h) continue; + if (rX >= w || rY >= h) continue; auto src = img[rX + (rY * w)]; //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->comp.alpha(src)); }