/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
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 <https://www.gnu.org/licenses/>.
*/
-#include "surface.h"
-
#include <math.h>
#include <algorithm>
#include "osd.h"
#include "teletxt/txtfont.h"
#include "staticartwork.h"
+#include "surface.h"
+
Surface* Surface::screen = NULL;
#ifndef GRADIENT_DRAWING
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<float>(charsizey) * static_cast<float>(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<int>(ceil(fposy)), 9);
+ interpol_lowline[py] = std::max(static_cast<int>(floor(fposy)), 0);
for (int px = 0; px < charsizex; px++)
{
- float fposx = ((float)(ttcharsizex)) / ((float)(charsizex)) * ((float)px);
+ float fposx = ttcharsizex / static_cast<float>(charsizex) * static_cast<float>(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<int>(ceil(fposx)), 11));
+ interpol_lowbit[px] = (std::max(static_cast<int>(floor(fposx)), 0));
+
+ interpol_table_fac1[px][py] = static_cast<unsigned int>(xweight * yweight * 256);
+ interpol_table_fac2[px][py] = static_cast<unsigned int>(xinvweight * yweight * 256);
+ interpol_table_fac3[px][py] = static_cast<unsigned int>(xweight * yinvweight * 256);
+ interpol_table_fac4[px][py] = static_cast<unsigned int>(xinvweight * yinvweight * 256);
}
}
}
{
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)
{
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)
{
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;
}
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);
{
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];
(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 ) );
}
}
-
endFastDraw();
-
-
}
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)