diff options
author | Eric Culp | 2012-06-27 12:59:53 -0400 |
---|---|---|
committer | Filippos Karapetis | 2019-04-01 00:29:23 +0300 |
commit | 0246ca8da096bac291612d636985878985e350b7 (patch) | |
tree | 3e3b4c15a231f866ef85ae5fd5fd24931afa3ddf | |
parent | 3d57c13af02dcd054c625f2adbd4347e20516814 (diff) | |
download | scummvm-rg350-0246ca8da096bac291612d636985878985e350b7.tar.gz scummvm-rg350-0246ca8da096bac291612d636985878985e350b7.tar.bz2 scummvm-rg350-0246ca8da096bac291612d636985878985e350b7.zip |
GRAPHICS: Change Edge filter to use shared interpolation functions
-rw-r--r-- | graphics/scaler/intern.h | 54 |
1 files changed, 54 insertions, 0 deletions
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 @@ -226,6 +226,33 @@ inline uint32 interpolate32_14_1_1<Graphics::ColorMasks<565> >(uint32 p1, uint32 } /** + * Interpolate three 32 bit pixels with weights 1, 1, and 1, i.e., (p1+p2+p3)/3. + */ + +template<typename ColorMask> +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. * * @see interpolate32_3_1 for similar method @@ -361,6 +388,33 @@ static inline unsigned interpolate16_14_1_1(unsigned p1, unsigned p2, unsigned p } /** + * Interpolate three 16 bit pixels with weights 1, 1, and 1, i.e., (p1+p2+p3)/3. + */ +template<typename ColorMask> +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. */ template<typename ColorMask> |