Skip to content

Commit

Permalink
Enable Fastscale for vdr 2.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim König authored and Joachim König committed Jan 25, 2024
1 parent f3e5a14 commit 7e387fa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
38 changes: 24 additions & 14 deletions openglosd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,10 @@ bool cOglCmdDrawImage::Execute(void) {
pthread_mutex_unlock(&OSDMutex);
#endif

GLfloat x1 = x; // left
GLfloat y1 = y; // top
GLfloat x2 = x + width; // right
GLfloat y2 = y + height; // bottom
GLfloat x1 = x; // left
GLfloat y1 = y; // top
GLfloat x2 = x + width * scaleX; // right
GLfloat y2 = y + height * scaleY; // bottom

GLfloat quadVertices[] = {
x1, y2, 0.0, 1.0, // left bottom
Expand Down Expand Up @@ -1324,19 +1324,21 @@ bool cOglCmdDrawImage::Execute(void) {
}

//------------------ cOglCmdDrawTexture --------------------
cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y) : cOglCmd(fb) {
cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX, double scaleY) : cOglCmd(fb) {
this->imageRef = imageRef;
this->x = x;
this->y = y;
this->scaleX = scaleX;
this->scaleY = scaleY;
}

bool cOglCmdDrawTexture::Execute(void) {
if (imageRef->width <= 0 || imageRef->height <= 0)
return false;
GLfloat x1 = x; // top
GLfloat y1 = y; // left
GLfloat x2 = x + imageRef->width; // right
GLfloat y2 = y + imageRef->height; // bottom
GLfloat x1 = x; // top
GLfloat y1 = y; // left
GLfloat x2 = x + imageRef->width * scaleX; // right
GLfloat y2 = y + imageRef->height * scaleY; // bottom

GLfloat quadVertices[] = {
// Pos // TexCoords
Expand Down Expand Up @@ -1830,6 +1832,10 @@ void cOglPixmap::Fill(tColor Color) {
}

void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
DrawScaledImage(Point, Image);
}

void cOglPixmap::DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) {
if (!oglThread->Active())
return;
tColor *argb = MALLOC(tColor, Image.Width() * Image.Height());
Expand All @@ -1838,28 +1844,32 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) {
return;
memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height());

oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y()));
oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y(), true, FactorX, FactorY));
SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size()));
MarkDrawPortDirty(cRect(Point, cSize(Image.Width() * FactorX, Image.Height() * FactorY)).Intersected(DrawPort().Size()));
}

void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) {
DrawScaledImage(Point, ImageHandle);
}

void cOglPixmap::DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) {
if (!oglThread->Active())
return;

if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) {
sOglImage *img = oglThread->GetImageRef(ImageHandle);

oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y()));
oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y(), FactorX, FactorY));
SetDirty();
MarkDrawPortDirty(cRect(Point, cSize(img->width * FactorX, img->height * FactorY)).Intersected(DrawPort().Size()));
}
/*
Fallback to VDR implementation, needs to separate cSoftOsdProvider from
softhddevice.cpp else { if (cSoftOsdProvider::GetImageData(ImageHandle))
DrawImage(Point, *cSoftOsdProvider::GetImageData(ImageHandle));
}
*/
SetDirty();
MarkDrawPortDirty(DrawPort());
}

void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) {
Expand Down
5 changes: 4 additions & 1 deletion openglosd.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,10 @@ class cOglCmdDrawTexture : public cOglCmd {
private:
sOglImage *imageRef;
GLint x, y;
GLfloat scaleX, scaleY;

public:
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y);
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX = 1.0f, double scaleY = 1.0f);
virtual ~cOglCmdDrawTexture(void){};
virtual const char *Description(void) { return "Draw Texture"; }
virtual bool Execute(void);
Expand Down Expand Up @@ -501,6 +502,8 @@ class cOglPixmap : public cPixmap {
virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint &Point, const cImage &Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle);
virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false);
virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false);
virtual void DrawPixel(const cPoint &Point, tColor Color);
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0,
bool Overlay = false);
Expand Down
16 changes: 15 additions & 1 deletion softhdcuvid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extern void ToggleLUT();
/// vdr-plugin version number.
/// Makefile extracts the version number for generating the file name
/// for the distribution archive.
static const char *const VERSION = "3.15"
static const char *const VERSION = "3.16"
#ifdef GIT_REV
"-GIT" GIT_REV
#endif
Expand Down Expand Up @@ -658,6 +658,20 @@ class cDummyPixmap : public cPixmap {
(void)Point;
(void)ImageHandle;
}
virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) {
(void)Point;
(void)Image;
(void)FactorX;
(void)FactorY;
(void)AntiAlias;
}
virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) {
(void)Point;
(void)ImageHandle;
(void)FactorX;
(void)FactorY;
(void)AntiAlias;
}
virtual void DrawPixel(const cPoint &Point, tColor Color) {
(void)Point;
(void)Color;
Expand Down

0 comments on commit 7e387fa

Please sign in to comment.