# HG changeset patch # User Benjamin Golinvaux # Date 1563526443 -7200 # Node ID 4d1f57773b5be15414885de20d9ada99c0392052 # Parent 2b4b6b86520a9042fae3cff08c69bc122ff2e489 Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/FloatTextureSceneLayer.cpp --- a/Framework/Scene2D/FloatTextureSceneLayer.cpp Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/FloatTextureSceneLayer.cpp Fri Jul 19 10:54:03 2019 +0200 @@ -93,7 +93,6 @@ IncrementRevision(); } - void FloatTextureSceneLayer::FitRange() { float minValue, maxValue; diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/GrayscaleStyleConfigurator.cpp --- a/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Fri Jul 19 10:54:03 2019 +0200 @@ -41,6 +41,13 @@ customWindowWidth_ = windowWidth; } + + void GrayscaleStyleConfigurator::SetInverted(bool inverted) + { + inverted_ = inverted; + revision_++; + } + void GrayscaleStyleConfigurator::SetLinearInterpolation(bool enabled) { linearInterpolation_ = enabled; @@ -87,5 +94,6 @@ l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); } } + l.SetInverted(inverted_); } } diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/GrayscaleStyleConfigurator.h --- a/Framework/Scene2D/GrayscaleStyleConfigurator.h Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.h Fri Jul 19 10:54:03 2019 +0200 @@ -38,7 +38,7 @@ ImageWindowing windowing_; float customWindowWidth_; float customWindowCenter_; - // TODO - Add custom windowing + bool inverted_; public: GrayscaleStyleConfigurator() : @@ -46,7 +46,8 @@ linearInterpolation_(false), hasWindowing_(false), customWindowWidth_(0), - customWindowCenter_(0) + customWindowCenter_(0), + inverted_(false) { } @@ -54,6 +55,8 @@ void SetCustomWindowing(float windowWidth, float windowCenter); + void SetInverted(bool inverted); + void SetLinearInterpolation(bool enabled); bool IsLinearInterpolation() const diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp --- a/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.cpp Fri Jul 19 10:54:03 2019 +0200 @@ -33,6 +33,7 @@ "uniform float u_slope; \n" "uniform float u_windowCenter; \n" "uniform float u_windowWidth; \n" + "uniform bool u_invert; \n" "uniform sampler2D u_texture; \n" "varying vec2 v_texcoord; \n" "void main() \n" @@ -50,6 +51,8 @@ " if (v >= 1.0) \n" " v = 1.0; \n" " } \n" + " if (u_invert) \n" + " v = 1.0 - v; \n" " gl_FragColor = vec4(v, v, v, 1); \n" "}"; @@ -133,7 +136,8 @@ void OpenGLFloatTextureProgram::Apply(Data& data, const AffineTransform2D& transform, float windowCenter, - float windowWidth) + float windowWidth, + bool invert) { OpenGLTextureProgram::Execution execution(program_, data.GetTexture(), transform); @@ -141,6 +145,7 @@ glUniform1f(execution.GetUniformLocation("u_offset"), data.GetOffset()); glUniform1f(execution.GetUniformLocation("u_windowCenter"), windowCenter); glUniform1f(execution.GetUniformLocation("u_windowWidth"), windowWidth); + glUniform1f(execution.GetUniformLocation("u_invert"), invert); execution.DrawTriangles(); } diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h --- a/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureProgram.h Fri Jul 19 10:54:03 2019 +0200 @@ -66,7 +66,8 @@ void Apply(Data& data, const AffineTransform2D& transform, float windowCenter, - float windowWidth); + float windowWidth, + bool invert); }; } } diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp --- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Fri Jul 19 10:54:03 2019 +0200 @@ -36,6 +36,7 @@ layerTransform_ = layer.GetTransform(); layer.GetWindowing(windowCenter_, windowWidth_); + invert_ = layer.IsInverted(); } @@ -56,7 +57,7 @@ if (texture_.get() != NULL) { program_.Apply(*texture_, AffineTransform2D::Combine(transform, layerTransform_), - windowCenter_, windowWidth_); + windowCenter_, windowWidth_, invert_); } } diff -r 2b4b6b86520a -r 4d1f57773b5b Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h --- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Fri Jul 19 10:30:40 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Fri Jul 19 10:54:03 2019 +0200 @@ -38,6 +38,7 @@ AffineTransform2D layerTransform_; float windowCenter_; float windowWidth_; + bool invert_; void UpdateInternal(const FloatTextureSceneLayer& layer, bool loadTexture);