OPENGL: Use premultiplied alpha for color-keyed cursors

This fixes colour fringing on keyed cursors when using filtering.

Fixes Trac#10594.
This commit is contained in:
Bastien Bouclet 2018-08-23 07:19:12 +02:00
parent 81f78d4ddf
commit 3376597abd
4 changed files with 100 additions and 42 deletions

View file

@ -37,6 +37,29 @@ public:
virtual ~Framebuffer() {};
public:
enum BlendMode {
/**
* Newly drawn pixels overwrite the existing contents of the framebuffer
* without mixing with them
*/
kBlendModeDisabled,
/**
* Newly drawn pixels mix with the framebuffer based on their alpha value
* for transparency.
*/
kBlendModeTraditionalTransparency,
/**
* Newly drawn pixels mix with the framebuffer based on their alpha value
* for transparency.
*
* Requires the image data being drawn to have its color values pre-multipled
* with the alpha value.
*/
kBlendModePremultipliedTransparency
};
/**
* Set the clear color of the framebuffer.
*/
@ -45,7 +68,7 @@ public:
/**
* Enable/disable GL_BLEND.
*/
void enableBlend(bool enable);
void enableBlend(BlendMode mode);
/**
* Enable/disable GL_SCISSOR_TEST.
@ -102,7 +125,7 @@ private:
GLfloat _clearColor[4];
void applyClearColor();
bool _blendState;
BlendMode _blendState;
void applyBlendState();
bool _scissorTestState;