aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/render/OpenGL.hpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-12-04 03:52:54 +0000
committerVaxry <[email protected]>2023-12-04 03:52:54 +0000
commit68783d904d850df65887adb1bab7eff59943c1ac (patch)
tree8c79712bf5213c1236b3a20f5874854459303f08 /src/render/OpenGL.hpp
parent5d100bdcbbd87bac74935eae6b7d7aed25620323 (diff)
downloadHyprland-68783d904d850df65887adb1bab7eff59943c1ac.tar.gz
Hyprland-68783d904d850df65887adb1bab7eff59943c1ac.zip
screencopy: use buffer format for glReadPixels
fixes #4029
Diffstat (limited to 'src/render/OpenGL.hpp')
-rw-r--r--src/render/OpenGL.hpp95
1 files changed, 52 insertions, 43 deletions
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index c3726575..efccaad4 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -41,6 +41,14 @@ struct SRenderModifData {
float scale = 1.f;
};
+struct SGLPixelFormat {
+ uint32_t drmFormat = DRM_FORMAT_INVALID;
+ GLint glInternalFormat = 0;
+ GLint glFormat = 0;
+ GLint glType = 0;
+ bool withAlpha = false;
+};
+
struct SMonitorRenderData {
CFramebuffer offloadFB;
CFramebuffer mirrorFB; // these are used for some effects,
@@ -108,66 +116,67 @@ class CHyprOpenGLImpl {
public:
CHyprOpenGLImpl();
- void begin(CMonitor*, CRegion*, CFramebuffer* fb = nullptr /* if provided, it's not a real frame */);
- void end();
+ void begin(CMonitor*, CRegion*, CFramebuffer* fb = nullptr /* if provided, it's not a real frame */);
+ void end();
- void renderRect(CBox*, const CColor&, int round = 0);
- void renderRectWithBlur(CBox*, const CColor&, int round = 0, float blurA = 1.f);
- void renderRectWithDamage(CBox*, const CColor&, CRegion* damage, int round = 0);
- void renderTexture(wlr_texture*, CBox*, float a, int round = 0, bool allowCustomUV = false);
- void renderTexture(const CTexture&, CBox*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
- void renderTextureWithBlur(const CTexture&, CBox*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false, float blurA = 1.f);
- void renderRoundedShadow(CBox*, int round, int range, const CColor& color, float a = 1.0);
- void renderBorder(CBox*, const CGradientValueData&, int round, int borderSize, float a = 1.0, int outerRound = -1 /* use round */);
- void renderTextureMatte(const CTexture& tex, CBox* pBox, CFramebuffer& matte);
+ void renderRect(CBox*, const CColor&, int round = 0);
+ void renderRectWithBlur(CBox*, const CColor&, int round = 0, float blurA = 1.f);
+ void renderRectWithDamage(CBox*, const CColor&, CRegion* damage, int round = 0);
+ void renderTexture(wlr_texture*, CBox*, float a, int round = 0, bool allowCustomUV = false);
+ void renderTexture(const CTexture&, CBox*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
+ void renderTextureWithBlur(const CTexture&, CBox*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false, float blurA = 1.f);
+ void renderRoundedShadow(CBox*, int round, int range, const CColor& color, float a = 1.0);
+ void renderBorder(CBox*, const CGradientValueData&, int round, int borderSize, float a = 1.0, int outerRound = -1 /* use round */);
+ void renderTextureMatte(const CTexture& tex, CBox* pBox, CFramebuffer& matte);
- void setMonitorTransformEnabled(bool enabled);
+ void setMonitorTransformEnabled(bool enabled);
- void saveMatrix();
- void setMatrixScaleTranslate(const Vector2D& translate, const float& scale);
- void restoreMatrix();
+ void saveMatrix();
+ void setMatrixScaleTranslate(const Vector2D& translate, const float& scale);
+ void restoreMatrix();
- void blend(bool enabled);
+ void blend(bool enabled);
- void makeWindowSnapshot(CWindow*);
- void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
- void makeLayerSnapshot(SLayerSurface*);
- void renderSnapshot(CWindow**);
- void renderSnapshot(SLayerSurface**);
+ void makeWindowSnapshot(CWindow*);
+ void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
+ void makeLayerSnapshot(SLayerSurface*);
+ void renderSnapshot(CWindow**);
+ void renderSnapshot(SLayerSurface**);
- void clear(const CColor&);
- void clearWithTex();
- void scissor(const CBox*, bool transform = true);
- void scissor(const pixman_box32*, bool transform = true);
- void scissor(const int x, const int y, const int w, const int h, bool transform = true);
+ void clear(const CColor&);
+ void clearWithTex();
+ void scissor(const CBox*, bool transform = true);
+ void scissor(const pixman_box32*, bool transform = true);
+ void scissor(const int x, const int y, const int w, const int h, bool transform = true);
- void destroyMonitorResources(CMonitor*);
+ void destroyMonitorResources(CMonitor*);
- void markBlurDirtyForMonitor(CMonitor*);
+ void markBlurDirtyForMonitor(CMonitor*);
- void preWindowPass();
- bool preBlurQueued();
- void preRender(CMonitor*);
+ void preWindowPass();
+ bool preBlurQueued();
+ void preRender(CMonitor*);
- void saveBufferForMirror();
- void renderMirrored();
+ void saveBufferForMirror();
+ void renderMirrored();
- void applyScreenShader(const std::string& path);
+ void applyScreenShader(const std::string& path);
- void bindOffMain();
- void renderOffToMain(CFramebuffer* off);
- void bindBackOnMain();
+ void bindOffMain();
+ void renderOffToMain(CFramebuffer* off);
+ void bindBackOnMain();
- uint32_t getPreferredReadFormat(CMonitor* pMonitor);
+ uint32_t getPreferredReadFormat(CMonitor* pMonitor);
+ const SGLPixelFormat* getPixelFormatFromDRM(uint32_t drmFormat);
- SCurrentRenderData m_RenderData;
+ SCurrentRenderData m_RenderData;
- GLint m_iCurrentOutputFb = 0;
+ GLint m_iCurrentOutputFb = 0;
- bool m_bReloadScreenShader = true; // at launch it can be set
+ bool m_bReloadScreenShader = true; // at launch it can be set
- CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window
- SLayerSurface* m_pCurrentLayer = nullptr; // hack to get the current rendered layer
+ CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window
+ SLayerSurface* m_pCurrentLayer = nullptr; // hack to get the current rendered layer
std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;