1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
From: Leonardo Zide <leozide@users.noreply.github.com>
Date: Thu, 3 Oct 2024 18:11:56 -0700
Subject: Clear background alpha consistently for solid and gradient
backgrounds.
Transparent for offscreen and opaque for widgets.
Bug-Debian: https://bugs.debian.org/1033440
Origin: upstream, https://github.com/leozide/leocad/commit/a27b69c9fdb14de0092167151a18988ebdcf0692
Forwarded: not-needed
---
common/lc_context.h | 5 +++++
common/lc_view.cpp | 12 ++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/common/lc_context.h b/common/lc_context.h
index ef8e115..6af31c7 100644
--- a/common/lc_context.h
+++ b/common/lc_context.h
@@ -132,6 +132,11 @@ public:
void SetGLContext(QOpenGLContext* GLContext, QOpenGLWidget* Widget);
void SetOffscreenContext();
+ bool IsOffscreen() const
+ {
+ return mWidget != nullptr;
+ }
+
void ClearColorAndDepth(const lcVector4& ClearColor);
void ClearDepth();
diff --git a/common/lc_view.cpp b/common/lc_view.cpp
index 71d6c93..762f612 100644
--- a/common/lc_view.cpp
+++ b/common/lc_view.cpp
@@ -995,10 +995,11 @@ void lcView::DrawBackground(int CurrentTileRow, int TotalTileRows, int CurrentTi
}
const lcPreferences& Preferences = lcGetPreferences();
+ float Alpha = mContext->IsOffscreen() ? 0.0f : 1.0f;
if (!Preferences.mBackgroundGradient)
{
- lcVector4 BackgroundColor(lcVector3FromColor(Preferences.mBackgroundSolidColor), 0.0f);
+ lcVector4 BackgroundColor(lcVector3FromColor(Preferences.mBackgroundSolidColor), Alpha);
mContext->ClearColorAndDepth(BackgroundColor);
return;
}
@@ -1027,28 +1028,23 @@ void lcView::DrawBackground(int CurrentTileRow, int TotalTileRows, int CurrentTi
double TopRed = LC_RGBA_RED(ColorTop);
double TopGreen = LC_RGBA_GREEN(ColorTop);
double TopBlue = LC_RGBA_BLUE(ColorTop);
- double TopAlpha = LC_RGBA_ALPHA(ColorTop);
double BottomRed = LC_RGBA_RED(ColorBottom);
double BottomGreen = LC_RGBA_GREEN(ColorBottom);
double BottomBlue = LC_RGBA_BLUE(ColorBottom);
- double BottomAlpha = LC_RGBA_ALPHA(ColorBottom);
const double DeltaRed = BottomRed - TopRed;
const double DeltaGreen = BottomGreen - TopGreen;
const double DeltaBlue = BottomBlue - TopBlue;
- const double DeltaAlpha = BottomAlpha - TopAlpha;
BottomRed = TopRed + DeltaRed * t2;
BottomGreen = TopGreen + DeltaGreen * t2;
BottomBlue = TopBlue + DeltaBlue * t2;
- BottomAlpha = TopAlpha + DeltaAlpha * t2;
TopRed = TopRed + DeltaRed * t1;
TopGreen = TopGreen + DeltaGreen * t1;
TopBlue = TopBlue + DeltaBlue * t1;
- TopAlpha = TopAlpha + DeltaAlpha * t1;
- const quint32 Color1 = LC_RGBA(TopRed, TopGreen, TopBlue, TopAlpha);
- const quint32 Color2 = LC_RGBA(BottomRed, BottomGreen, BottomBlue, BottomAlpha);
+ const quint32 Color1 = LC_RGBA(TopRed, TopGreen, TopBlue, Alpha);
+ const quint32 Color2 = LC_RGBA(BottomRed, BottomGreen, BottomBlue, Alpha);
struct lcBackgroundVertex
{
|