From 0246ca8da096bac291612d636985878985e350b7 Mon Sep 17 00:00:00 2001 From: Eric Culp Date: Wed, 27 Jun 2012 12:59:53 -0400 Subject: GRAPHICS: Change Edge filter to use shared interpolation functions --- graphics/scaler/intern.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h index 4a832801ea..b1219fb909 100644 --- a/graphics/scaler/intern.h +++ b/graphics/scaler/intern.h @@ -225,6 +225,33 @@ inline uint32 interpolate32_14_1_1 >(uint32 p1, uint32 assert(0); } +/** + * Interpolate three 32 bit pixels with weights 1, 1, and 1, i.e., (p1+p2+p3)/3. + */ + +template +uint32 interpolate32_1_1_1(uint32 pixel1, uint32 pixel2, uint32 pixel3) +{ + uint32 rsum, gsum, bsum; + + rsum = (pixel1 & ColorMask::kRedMask); + rsum += (pixel2 & ColorMask::kRedMask); + rsum += (pixel3 & ColorMask::kRedMask); + rsum /= 3; + + gsum = (pixel1 & ColorMask::kGreenMask); + gsum += (pixel2 & ColorMask::kGreenMask); + gsum += (pixel3 & ColorMask::kGreenMask); + gsum /= 3; + + bsum = (pixel1 & ColorMask::kBlueMask); + bsum += (pixel2 & ColorMask::kBlueMask); + bsum += (pixel3 & ColorMask::kBlueMask); + bsum /= 3; + + return (rsum & ColorMask::kRedMask) | (gsum & ColorMask::kGreenMask) | (bsum & ColorMask::kBlueMask); +} + /** * Interpolate four 32 bit pixels with weights 1, 1, 1, and 1, i.e., (p1+p2+p3+p4)/4. * @@ -360,6 +387,33 @@ static inline unsigned interpolate16_14_1_1(unsigned p1, unsigned p2, unsigned p return ((rb&(ColorMask::kRedBlueMask<<4)) | (g&(ColorMask::kGreenMask<<4))) >> 4; } +/** + * Interpolate three 16 bit pixels with weights 1, 1, and 1, i.e., (p1+p2+p3)/3. + */ +template +uint16 interpolate16_1_1_1(uint16 pixel1, uint16 pixel2, uint16 pixel3) +{ + uint32 rsum; + uint16 gsum, bsum; + + rsum = (pixel1 & ColorMask::kRedMask); + rsum += (pixel2 & ColorMask::kRedMask); + rsum += (pixel3 & ColorMask::kRedMask); + rsum /= 3; + + gsum = (pixel1 & ColorMask::kGreenMask); + gsum += (pixel2 & ColorMask::kGreenMask); + gsum += (pixel3 & ColorMask::kGreenMask); + gsum /= 3; + + bsum = (pixel1 & ColorMask::kBlueMask); + bsum += (pixel2 & ColorMask::kBlueMask); + bsum += (pixel3 & ColorMask::kBlueMask); + bsum /= 3; + + return (rsum & ColorMask::kRedMask) | (gsum & ColorMask::kGreenMask) | (bsum & ColorMask::kBlueMask); +} + /** * Interpolate four 16 bit pixels with weights 1, 1, 1, and 1, i.e., (p1+p2+p3+p4)/4. */ -- cgit v1.2.3