From 2052a6db5336429c47f7c715f8a3bf1316b62f01 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 8 Dec 2019 18:27:26 +0100 Subject: [PATCH] Simplify code slightly --- .../polyrenderer/drawers/screen_triangle.cpp | 87 ++++++++++--------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/src/rendering/polyrenderer/drawers/screen_triangle.cpp b/src/rendering/polyrenderer/drawers/screen_triangle.cpp index a28c5175c..53c54954e 100644 --- a/src/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/src/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -923,52 +923,57 @@ static void BlendColorRevSub_Src_One(int y, int x0, int x1, PolyTriangleThreadDa static void SelectWriteColorFunc(PolyTriangleThreadData* thread) { - void(*writecolorfunc)(int y, int x0, int x1, PolyTriangleThreadData * thread); - FRenderStyle style = thread->RenderStyle; - if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_One && style.DestAlpha == STYLEALPHA_Zero) + if (style.BlendOp == STYLEOP_Add) { - writecolorfunc = &BlendColorOpaque; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_InvSrc) - { - writecolorfunc = &BlendColorAdd_Src_InvSrc; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_SrcCol && style.DestAlpha == STYLEALPHA_InvSrcCol) - { - writecolorfunc = &BlendColorAdd_SrcCol_InvSrcCol; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_One) - { - writecolorfunc = &BlendColorAdd_Src_One; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_SrcCol && style.DestAlpha == STYLEALPHA_One) - { - writecolorfunc = &BlendColorAdd_SrcCol_One; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_DstCol && style.DestAlpha == STYLEALPHA_Zero) - { - writecolorfunc = &BlendColorAdd_DstCol_Zero; - } - else if (style.BlendOp == STYLEOP_Add && style.SrcAlpha == STYLEALPHA_InvDstCol && style.DestAlpha == STYLEALPHA_Zero) - { - writecolorfunc = &BlendColorAdd_InvDstCol_Zero; - } - else if (style.BlendOp == STYLEOP_RevSub && style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_One) - { - writecolorfunc = &BlendColorRevSub_Src_One; - } - else - { - switch (style.BlendOp) + if (style.SrcAlpha == STYLEALPHA_One && style.DestAlpha == STYLEALPHA_Zero) { - default: - case STYLEOP_Add: writecolorfunc = &BlendColor; break; - case STYLEOP_Sub: writecolorfunc = &BlendColor; break; - case STYLEOP_RevSub: writecolorfunc = &BlendColor; break; + thread->WriteColorFunc = &BlendColorOpaque; + } + else if (style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_InvSrc) + { + thread->WriteColorFunc = &BlendColorAdd_Src_InvSrc; + } + else if (style.SrcAlpha == STYLEALPHA_SrcCol && style.DestAlpha == STYLEALPHA_InvSrcCol) + { + thread->WriteColorFunc = &BlendColorAdd_SrcCol_InvSrcCol; + } + else if (style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_One) + { + thread->WriteColorFunc = &BlendColorAdd_Src_One; + } + else if (style.SrcAlpha == STYLEALPHA_SrcCol && style.DestAlpha == STYLEALPHA_One) + { + thread->WriteColorFunc = &BlendColorAdd_SrcCol_One; + } + else if (style.SrcAlpha == STYLEALPHA_DstCol && style.DestAlpha == STYLEALPHA_Zero) + { + thread->WriteColorFunc = &BlendColorAdd_DstCol_Zero; + } + else if (style.SrcAlpha == STYLEALPHA_InvDstCol && style.DestAlpha == STYLEALPHA_Zero) + { + thread->WriteColorFunc = &BlendColorAdd_InvDstCol_Zero; + } + else + { + thread->WriteColorFunc = &BlendColor; + } + } + else if (style.BlendOp == STYLEOP_Sub) + { + thread->WriteColorFunc = &BlendColor; + } + else // if (style.BlendOp == STYLEOP_RevSub) + { + if (style.SrcAlpha == STYLEALPHA_Src && style.DestAlpha == STYLEALPHA_One) + { + thread->WriteColorFunc = &BlendColorRevSub_Src_One; + } + else + { + thread->WriteColorFunc = &BlendColor; } } - thread->WriteColorFunc = writecolorfunc; } static void WriteDepth(int y, int x0, int x1, PolyTriangleThreadData* thread)