mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Added color shift support to VideoComponent.
This commit is contained in:
parent
46a1e28aa2
commit
6037e80bf1
|
@ -275,6 +275,9 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"gameselector", STRING},
|
{"gameselector", STRING},
|
||||||
{"audio", BOOLEAN},
|
{"audio", BOOLEAN},
|
||||||
{"interpolation", STRING},
|
{"interpolation", STRING},
|
||||||
|
{"color", COLOR},
|
||||||
|
{"colorEnd", COLOR},
|
||||||
|
{"gradientType", STRING},
|
||||||
{"pillarboxes", BOOLEAN},
|
{"pillarboxes", BOOLEAN},
|
||||||
{"pillarboxThreshold", NORMALIZED_PAIR},
|
{"pillarboxThreshold", NORMALIZED_PAIR},
|
||||||
{"scanlines", BOOLEAN},
|
{"scanlines", BOOLEAN},
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
VideoComponent::VideoComponent()
|
VideoComponent::VideoComponent()
|
||||||
: mVideoWidth {0}
|
: mVideoWidth {0}
|
||||||
, mVideoHeight {0}
|
, mVideoHeight {0}
|
||||||
|
, mColorShift {0xFFFFFFFF}
|
||||||
|
, mColorShiftEnd {0xFFFFFFFF}
|
||||||
|
, mColorGradientHorizontal {true}
|
||||||
, mTargetSize {0.0f, 0.0f}
|
, mTargetSize {0.0f, 0.0f}
|
||||||
, mVideoAreaPos {0.0f, 0.0f}
|
, mVideoAreaPos {0.0f, 0.0f}
|
||||||
, mVideoAreaSize {0.0f, 0.0f}
|
, mVideoAreaSize {0.0f, 0.0f}
|
||||||
|
@ -254,6 +257,29 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("color")) {
|
||||||
|
mColorShift = elem->get<unsigned int>("color");
|
||||||
|
mColorShiftEnd = mColorShift;
|
||||||
|
}
|
||||||
|
if (elem->has("colorEnd"))
|
||||||
|
mColorShiftEnd = elem->get<unsigned int>("colorEnd");
|
||||||
|
|
||||||
|
if (elem->has("gradientType")) {
|
||||||
|
const std::string& gradientType {elem->get<std::string>("gradientType")};
|
||||||
|
if (gradientType == "horizontal") {
|
||||||
|
mColorGradientHorizontal = true;
|
||||||
|
}
|
||||||
|
else if (gradientType == "vertical") {
|
||||||
|
mColorGradientHorizontal = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mColorGradientHorizontal = true;
|
||||||
|
LOG(LogWarning) << "VideoComponent: Invalid theme configuration, property "
|
||||||
|
"\"gradientType\" for element \""
|
||||||
|
<< element.substr(6) << "\" defined as \"" << gradientType << "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("pillarboxes"))
|
if (elem->has("pillarboxes"))
|
||||||
mDrawPillarboxes = elem->get<bool>("pillarboxes");
|
mDrawPillarboxes = elem->get<bool>("pillarboxes");
|
||||||
|
|
||||||
|
@ -355,6 +381,12 @@ void VideoComponent::renderSnapshot(const glm::mat4& parentTrans)
|
||||||
if (mStaticImagePath != "") {
|
if (mStaticImagePath != "") {
|
||||||
mStaticImage.setOpacity(mOpacity * mThemeOpacity);
|
mStaticImage.setOpacity(mOpacity * mThemeOpacity);
|
||||||
mStaticImage.setSaturation(mSaturation * mThemeSaturation);
|
mStaticImage.setSaturation(mSaturation * mThemeSaturation);
|
||||||
|
if (mColorShift != 0xFFFFFFFF)
|
||||||
|
mStaticImage.setColorShift(mColorShift);
|
||||||
|
if (mColorShift != mColorShiftEnd)
|
||||||
|
mStaticImage.setColorShiftEnd(mColorShiftEnd);
|
||||||
|
if (!mColorGradientHorizontal)
|
||||||
|
mStaticImage.setColorGradientHorizontal(mColorGradientHorizontal);
|
||||||
mStaticImage.setDimming(mDimming);
|
mStaticImage.setDimming(mDimming);
|
||||||
mStaticImage.render(parentTrans);
|
mStaticImage.render(parentTrans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,9 @@ protected:
|
||||||
|
|
||||||
unsigned mVideoWidth;
|
unsigned mVideoWidth;
|
||||||
unsigned mVideoHeight;
|
unsigned mVideoHeight;
|
||||||
|
unsigned int mColorShift;
|
||||||
|
unsigned int mColorShiftEnd;
|
||||||
|
bool mColorGradientHorizontal;
|
||||||
glm::vec2 mTargetSize;
|
glm::vec2 mTargetSize;
|
||||||
glm::vec2 mVideoAreaPos;
|
glm::vec2 mVideoAreaPos;
|
||||||
glm::vec2 mVideoAreaSize;
|
glm::vec2 mVideoAreaSize;
|
||||||
|
|
|
@ -164,6 +164,11 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
vertices[3] = {{mSize.x + mRectangleOffset.x, mSize.y + + mRectangleOffset.y}, {1.0f, 1.0f}, 0xFFFFFFFF};
|
vertices[3] = {{mSize.x + mRectangleOffset.x, mSize.y + + mRectangleOffset.y}, {1.0f, 1.0f}, 0xFFFFFFFF};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
vertices[0].color = mColorShift;
|
||||||
|
vertices[1].color = mColorGradientHorizontal ? mColorShift : mColorShiftEnd;
|
||||||
|
vertices[2].color = mColorGradientHorizontal ? mColorShiftEnd : mColorShift;
|
||||||
|
vertices[3].color = mColorShiftEnd;
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].position = glm::round(vertices[i].position);
|
vertices[i].position = glm::round(vertices[i].position);
|
||||||
|
|
|
@ -30,10 +30,13 @@ precision mediump float;
|
||||||
uniform mat4 MVPMatrix;
|
uniform mat4 MVPMatrix;
|
||||||
in vec2 positionVertex;
|
in vec2 positionVertex;
|
||||||
in vec2 texCoordVertex;
|
in vec2 texCoordVertex;
|
||||||
|
in vec4 colorVertex;
|
||||||
uniform vec2 textureSize;
|
uniform vec2 textureSize;
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
out vec2 onex;
|
out vec2 onex;
|
||||||
out vec2 oney;
|
out vec2 oney;
|
||||||
|
out vec4 colorShift;
|
||||||
|
|
||||||
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
||||||
|
|
||||||
|
@ -43,6 +46,7 @@ void main()
|
||||||
texCoord = texCoordVertex;
|
texCoord = texCoordVertex;
|
||||||
onex = vec2(SourceSize.z, 0.0);
|
onex = vec2(SourceSize.z, 0.0);
|
||||||
oney = vec2(0.0, SourceSize.w);
|
oney = vec2(0.0, SourceSize.w);
|
||||||
|
colorShift.abgr = colorVertex.rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fragment section of code:
|
// Fragment section of code:
|
||||||
|
@ -59,6 +63,7 @@ uniform sampler2D textureSampler;
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
in vec2 onex;
|
in vec2 onex;
|
||||||
in vec2 oney;
|
in vec2 oney;
|
||||||
|
in vec4 colorShift;
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
||||||
|
@ -158,6 +163,10 @@ void main()
|
||||||
colorTemp = vec4(blendedColor, colorTemp.a);
|
colorTemp = vec4(blendedColor, colorTemp.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Color shift.
|
||||||
|
colorTemp.rgb *= colorShift.rgb;
|
||||||
|
colorTemp.a *= colorShift.a;
|
||||||
|
|
||||||
FragColor = vec4(colorTemp.rgb, colorTemp.a * opacity);
|
FragColor = vec4(colorTemp.rgb, colorTemp.a * opacity);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue