mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35: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},
|
||||
{"audio", BOOLEAN},
|
||||
{"interpolation", STRING},
|
||||
{"color", COLOR},
|
||||
{"colorEnd", COLOR},
|
||||
{"gradientType", STRING},
|
||||
{"pillarboxes", BOOLEAN},
|
||||
{"pillarboxThreshold", NORMALIZED_PAIR},
|
||||
{"scanlines", BOOLEAN},
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
VideoComponent::VideoComponent()
|
||||
: mVideoWidth {0}
|
||||
, mVideoHeight {0}
|
||||
, mColorShift {0xFFFFFFFF}
|
||||
, mColorShiftEnd {0xFFFFFFFF}
|
||||
, mColorGradientHorizontal {true}
|
||||
, mTargetSize {0.0f, 0.0f}
|
||||
, mVideoAreaPos {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"))
|
||||
mDrawPillarboxes = elem->get<bool>("pillarboxes");
|
||||
|
||||
|
@ -355,6 +381,12 @@ void VideoComponent::renderSnapshot(const glm::mat4& parentTrans)
|
|||
if (mStaticImagePath != "") {
|
||||
mStaticImage.setOpacity(mOpacity * mThemeOpacity);
|
||||
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.render(parentTrans);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,9 @@ protected:
|
|||
|
||||
unsigned mVideoWidth;
|
||||
unsigned mVideoHeight;
|
||||
unsigned int mColorShift;
|
||||
unsigned int mColorShiftEnd;
|
||||
bool mColorGradientHorizontal;
|
||||
glm::vec2 mTargetSize;
|
||||
glm::vec2 mVideoAreaPos;
|
||||
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};
|
||||
// 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.
|
||||
for (int i = 0; i < 4; ++i)
|
||||
vertices[i].position = glm::round(vertices[i].position);
|
||||
|
|
|
@ -30,10 +30,13 @@ precision mediump float;
|
|||
uniform mat4 MVPMatrix;
|
||||
in vec2 positionVertex;
|
||||
in vec2 texCoordVertex;
|
||||
in vec4 colorVertex;
|
||||
uniform vec2 textureSize;
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec2 onex;
|
||||
out vec2 oney;
|
||||
out vec4 colorShift;
|
||||
|
||||
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
||||
|
||||
|
@ -43,6 +46,7 @@ void main()
|
|||
texCoord = texCoordVertex;
|
||||
onex = vec2(SourceSize.z, 0.0);
|
||||
oney = vec2(0.0, SourceSize.w);
|
||||
colorShift.abgr = colorVertex.rgba;
|
||||
}
|
||||
|
||||
// Fragment section of code:
|
||||
|
@ -59,6 +63,7 @@ uniform sampler2D textureSampler;
|
|||
in vec2 texCoord;
|
||||
in vec2 onex;
|
||||
in vec2 oney;
|
||||
in vec4 colorShift;
|
||||
out vec4 FragColor;
|
||||
|
||||
#define SourceSize vec4(textureSize, 1.0 / textureSize)
|
||||
|
@ -158,6 +163,10 @@ void main()
|
|||
colorTemp = vec4(blendedColor, colorTemp.a);
|
||||
}
|
||||
|
||||
// Color shift.
|
||||
colorTemp.rgb *= colorShift.rgb;
|
||||
colorTemp.a *= colorShift.a;
|
||||
|
||||
FragColor = vec4(colorTemp.rgb, colorTemp.a * opacity);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue