From 9bab71d4882dceccd33fbddf415dae7760b8c6ef Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 21 May 2020 19:48:49 +0100 Subject: [PATCH] All Surface CWFs --- surface.cc | 64 +++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/surface.cc b/surface.cc index 94ece40..5782327 100644 --- a/surface.cc +++ b/surface.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2004-2020 Chris Tallon This file is part of VOMP. @@ -14,12 +14,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ -#include "surface.h" - #include #include #include "osd.h" @@ -29,6 +26,8 @@ #include "teletxt/txtfont.h" #include "staticartwork.h" +#include "surface.h" + Surface* Surface::screen = NULL; #ifndef GRADIENT_DRAWING @@ -64,29 +63,29 @@ void Surface::initpol_tables() charsizey = 18; } - int ttcharsizex = 12; - int ttcharsizey = 10; + float ttcharsizex = 12; + float ttcharsizey = 10; for (int py = 0; py < charsizey; py++) { - float fposy = ((float)(ttcharsizey)) / ((float)(charsizey)) * ((float)py); + float fposy = ttcharsizey / static_cast(charsizey) * static_cast(py); float yweight = fposy - floor(fposy); - float yinvweight = 1. - yweight; - interpol_upline[py] = std::min((int)(ceil(fposy)), 9); - interpol_lowline[py] = std::max((int)(floor(fposy)), 0); + float yinvweight = 1.0f - yweight; + interpol_upline[py] = std::min(static_cast(ceil(fposy)), 9); + interpol_lowline[py] = std::max(static_cast(floor(fposy)), 0); for (int px = 0; px < charsizex; px++) { - float fposx = ((float)(ttcharsizex)) / ((float)(charsizex)) * ((float)px); + float fposx = ttcharsizex / static_cast(charsizex) * static_cast(px); float xweight = fposx - floor(fposx); - float xinvweight = 1. - xweight; - interpol_upbit[px] = (std::min((int)ceil(fposx), 11)); - interpol_lowbit[px] = (std::max((int)floor(fposx), 0)); - - interpol_table_fac1[px][py] = (unsigned int)(xweight * yweight * 256.); - interpol_table_fac2[px][py] = (unsigned int)(xinvweight * yweight * 256.); - interpol_table_fac3[px][py] = (unsigned int)(xweight * yinvweight * 256.); - interpol_table_fac4[px][py] = (unsigned int)(xinvweight * yinvweight * 256.); + float xinvweight = 1.0f - xweight; + interpol_upbit[px] = (std::min(static_cast(ceil(fposx)), 11)); + interpol_lowbit[px] = (std::max(static_cast(floor(fposx)), 0)); + + interpol_table_fac1[px][py] = static_cast(xweight * yweight * 256); + interpol_table_fac2[px][py] = static_cast(xinvweight * yweight * 256); + interpol_table_fac3[px][py] = static_cast(xweight * yinvweight * 256); + interpol_table_fac4[px][py] = static_cast(xinvweight * yinvweight * 256); } } } @@ -95,6 +94,7 @@ int Surface::drawText(const char* text, int x, int y, const DrawStyle& c) { return drawText(text, x, y, 2000, c); } + #ifndef GRADIENT_DRAWING int Surface::drawText(const char* text, int x, int y, int width, const DrawStyle& c) { @@ -238,11 +238,9 @@ Colour Surface::enumTeletextColorToCoulour(enumTeletextColor ttcol) default: return Colour(0, 0, 0); - }; + } } - - //Next function inspired by osdteletext plugin void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) { @@ -252,12 +250,12 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) pol_table_inited = true; } - unsigned int buffer [10]; + unsigned int buffer[10]; unsigned int* charmap = GetFontChar(c, buffer); if (!charmap) //invalid char { - memset(&buffer, 0, 10); + memset(&buffer, 0, 10 * sizeof(unsigned int)); charmap = buffer; } @@ -288,7 +286,6 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) int screenposx = charsizex * x + ox; //12*40= 480 250 int screenposy = y * charsizey + oy; - // Log::getInstance()->log("Surface", Log::ERR, "TTpos %d %d %d %d %d %d",x,y,ox,oy,screenposx,screenposy); Colour fgcharcl = enumTeletextColorToCoulour(ttforegcolour); Colour bgcharcl = enumTeletextColorToCoulour(ttbackgcolour); @@ -304,10 +301,10 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) { int upperbit = interpol_upbit[px]; int lowerbit = interpol_lowbit[px]; - Colour uuc = ( upperbitline & (0x8000 >> upperbit)) ? fgcharcl : bgcharcl; - Colour ulc = ( upperbitline & (0x8000 >> lowerbit)) ? fgcharcl : bgcharcl; - Colour luc = ( lowerbitline & (0x8000 >> upperbit)) ? fgcharcl : bgcharcl; - Colour llc = ( lowerbitline & (0x8000 >> lowerbit)) ? fgcharcl : bgcharcl; + Colour uuc = (upperbitline & (0x8000 >> upperbit)) ? fgcharcl : bgcharcl; + Colour ulc = (upperbitline & (0x8000 >> lowerbit)) ? fgcharcl : bgcharcl; + Colour luc = (lowerbitline & (0x8000 >> upperbit)) ? fgcharcl : bgcharcl; + Colour llc = (lowerbitline & (0x8000 >> lowerbit)) ? fgcharcl : bgcharcl; unsigned int fac1, fac2, fac3, fac4; fac1 = interpol_table_fac1[px][py]; fac2 = interpol_table_fac2[px][py]; @@ -318,7 +315,7 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) (uuc.green * fac1 + ulc.green * fac2 + luc.green * fac3 + llc.green * fac4) / 256, (uuc.blue * fac1 + ulc.blue * fac2 + luc.blue * fac3 + llc.blue * fac4) / 256, (uuc.alpha * fac1 + ulc.alpha * fac2 + luc.alpha * fac3 + llc.alpha * fac4) / 256); //if this is too slow make a table - int newcolour = ( (res.alpha << 24) + int newcolour = ( (res.alpha << 24) | (res.red << 16) | (res.green << 8) | (res.blue ) ); @@ -326,10 +323,7 @@ void Surface::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c) } } - endFastDraw(); - - } void Surface::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, @@ -344,7 +338,7 @@ void Surface::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height, { for (x = 0; x < width; x++) { - bytesIn = (y * widthBytes) + (int) (x / 8); + bytesIn = (y * widthBytes) + (x / 8); bitsIn = x % 8; if ((base[bytesIn] >> (7 - bitsIn)) & 0x01) -- 2.39.5