summaryrefslogtreecommitdiff
path: root/src/render/OpenGL.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/OpenGL.hpp')
-rw-r--r--src/render/OpenGL.hpp138
1 files changed, 72 insertions, 66 deletions
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 82b34119..c9008447 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -20,6 +20,7 @@
#include "Texture.hpp"
#include "Framebuffer.hpp"
#include "Renderbuffer.hpp"
+#include "desktop/DesktopTypes.hpp"
#include "pass/Pass.hpp"
#include <EGL/egl.h>
@@ -32,9 +33,14 @@
#include "../debug/TracyDefines.hpp"
#include "../protocols/core/Compositor.hpp"
#include "render/ShaderLoader.hpp"
+#include "render/gl/GLFramebuffer.hpp"
+#include "render/gl/GLRenderbuffer.hpp"
+#include "render/gl/GLTexture.hpp"
+
+#define GLFB(ifb) dc<CGLFramebuffer*>(ifb.get())
struct gbm_device;
-class CHyprRenderer;
+class IHyprRenderer;
struct SVertex {
float x, y; // position
@@ -108,17 +114,17 @@ struct SPreparedShaders {
};
struct SMonitorRenderData {
- CFramebuffer offloadFB;
- CFramebuffer mirrorFB; // these are used for some effects,
- CFramebuffer mirrorSwapFB; // etc
- CFramebuffer offMainFB;
- CFramebuffer monitorMirrorFB; // used for mirroring outputs / screencopy, does not contain artifacts like offloadFB and is in sRGB
- CFramebuffer blurFB;
+ SP<IFramebuffer> offloadFB;
+ SP<IFramebuffer> mirrorFB; // these are used for some effects,
+ SP<IFramebuffer> mirrorSwapFB; // etc
+ SP<IFramebuffer> offMainFB;
+ SP<IFramebuffer> monitorMirrorFB; // used for mirroring outputs, does not contain artifacts like offloadFB
+ SP<IFramebuffer> blurFB;
- SP<CTexture> stencilTex = makeShared<CTexture>();
+ SP<ITexture> stencilTex = makeShared<CGLTexture>();
- bool blurFBDirty = true;
- bool blurFBShouldRender = false;
+ bool blurFBDirty = true;
+ bool blurFBShouldRender = false;
};
struct SCurrentRenderData {
@@ -129,9 +135,9 @@ struct SCurrentRenderData {
// FIXME: raw pointer galore!
SMonitorRenderData* pCurrentMonData = nullptr;
- CFramebuffer* currentFB = nullptr; // current rendering to
- CFramebuffer* mainFB = nullptr; // main to render to
- CFramebuffer* outFB = nullptr; // out to render to (if offloaded, etc)
+ SP<IFramebuffer> currentFB = nullptr; // current rendering to
+ SP<IFramebuffer> mainFB = nullptr; // main to render to
+ SP<IFramebuffer> outFB = nullptr; // out to render to (if offloaded, etc)
CRegion damage;
CRegion finalDamage; // damage used for funal off -> main
@@ -213,7 +219,7 @@ class CHyprOpenGLImpl {
bool noCM = false;
bool finalMonitorCM = false;
SP<CMonitor> cmBackToSRGBSource;
- SP<CTexture> blurredBG;
+ SP<ITexture> blurredBG;
};
struct SBorderRenderData {
@@ -224,17 +230,17 @@ class CHyprOpenGLImpl {
int outerRound = -1; /* use round */
};
- void begin(PHLMONITOR, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {});
- void beginSimple(PHLMONITOR, const CRegion& damage, SP<CRenderbuffer> rb = nullptr, CFramebuffer* fb = nullptr);
+ void begin(PHLMONITOR, const CRegion& damage, SP<IFramebuffer> fb = nullptr, std::optional<CRegion> finalDamage = {});
+ void beginSimple(PHLMONITOR, const CRegion& damage, SP<IRenderbuffer> rb = nullptr, SP<IFramebuffer> fb = nullptr);
void end();
void renderRect(const CBox&, const CHyprColor&, SRectRenderData data);
- void renderTexture(SP<CTexture>, const CBox&, STextureRenderData data);
+ void renderTexture(SP<ITexture>, const CBox&, STextureRenderData data);
void renderRoundedShadow(const CBox&, int round, float roundingPower, int range, const CHyprColor& color, float a = 1.0);
void renderBorder(const CBox&, const CGradientValueData&, SBorderRenderData data);
void renderBorder(const CBox&, const CGradientValueData&, const CGradientValueData&, float lerp, SBorderRenderData data);
- void renderTextureMatte(SP<CTexture> tex, const CBox& pBox, CFramebuffer& matte);
- void renderTexturePrimitive(SP<CTexture> tex, const CBox& box);
+ void renderTextureMatte(SP<ITexture> tex, const CBox& pBox, SP<IFramebuffer> matte);
+ void renderTexturePrimitive(SP<ITexture> tex, const CBox& box);
void pushMonitorTransformEnabled(bool enabled);
void popMonitorTransformEnabled();
@@ -271,49 +277,49 @@ class CHyprOpenGLImpl {
void applyScreenShader(const std::string& path);
void bindOffMain();
- void renderOffToMain(CFramebuffer* off);
+ void renderOffToMain(CGLFramebuffer* off);
void bindBackOnMain();
bool needsACopyFB(PHLMONITOR mon);
std::string resolveAssetPath(const std::string& file);
- SP<CTexture> loadAsset(const std::string& file);
- SP<CTexture> texFromCairo(cairo_surface_t* cairo);
- SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0, int weight = 400);
+ SP<ITexture> loadAsset(const std::string& file);
+ SP<ITexture> texFromCairo(cairo_surface_t* cairo);
+ SP<ITexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0, int weight = 400);
void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {});
DRMFormat getPreferredReadFormat(PHLMONITOR pMonitor);
- std::vector<SDRMFormat> getDRMFormats();
- std::vector<uint64_t> getDRMFormatModifiers(DRMFormat format);
- EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs);
+ std::vector<SDRMFormat> getDRMFormats();
+ std::vector<uint64_t> getDRMFormatModifiers(DRMFormat format);
+ EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs);
- bool initShaders(const std::string& path = "");
+ bool initShaders(const std::string& path = "");
- WP<CShader> useShader(WP<CShader> prog);
+ WP<CShader> useShader(WP<CShader> prog);
- bool explicitSyncSupported();
- WP<CShader> getShaderVariant(Render::ePreparedFragmentShader frag, Render::ShaderFeatureFlags features = 0);
+ bool explicitSyncSupported();
+ WP<CShader> getShaderVariant(Render::ePreparedFragmentShader frag, Render::ShaderFeatureFlags features = 0);
- bool m_shadersInitialized = false;
- SP<SPreparedShaders> m_shaders;
+ bool m_shadersInitialized = false;
+ SP<SPreparedShaders> m_shaders;
- SCurrentRenderData m_renderData;
+ SCurrentRenderData m_renderData;
- Hyprutils::OS::CFileDescriptor m_gbmFD;
- gbm_device* m_gbmDevice = nullptr;
- EGLContext m_eglContext = nullptr;
- EGLDisplay m_eglDisplay = nullptr;
- EGLDeviceEXT m_eglDevice = nullptr;
- uint m_failedAssetsNo = 0;
+ Hyprutils::OS::CFileDescriptor m_gbmFD;
+ gbm_device* m_gbmDevice = nullptr;
+ EGLContext m_eglContext = nullptr;
+ EGLDisplay m_eglDisplay = nullptr;
+ EGLDeviceEXT m_eglDevice = nullptr;
+ uint m_failedAssetsNo = 0;
- bool m_reloadScreenShader = true; // at launch it can be set
+ bool m_reloadScreenShader = true; // at launch it can be set
- std::map<PHLWINDOWREF, CFramebuffer> m_windowFramebuffers;
- std::map<PHLLSREF, CFramebuffer> m_layerFramebuffers;
- std::map<WP<Desktop::View::CPopup>, CFramebuffer> m_popupFramebuffers;
- std::map<PHLMONITORREF, SMonitorRenderData> m_monitorRenderResources;
- std::map<PHLMONITORREF, CFramebuffer> m_monitorBGFBs;
+ std::map<PHLWINDOWREF, SP<IFramebuffer>> m_windowFramebuffers;
+ std::map<PHLLSREF, SP<IFramebuffer>> m_layerFramebuffers;
+ std::map<WP<Desktop::View::CPopup>, SP<IFramebuffer>> m_popupFramebuffers;
+ std::map<PHLMONITORREF, SMonitorRenderData> m_monitorRenderResources;
+ std::map<PHLMONITORREF, SP<IFramebuffer>> m_monitorBGFBs;
struct {
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES = nullptr;
@@ -344,7 +350,7 @@ class CHyprOpenGLImpl {
bool EGL_ANDROID_native_fence_sync_ext = false;
} m_exts;
- SP<CTexture> m_screencopyDeniedTexture;
+ SP<ITexture> m_screencopyDeniedTexture;
enum eEGLContextVersion : uint8_t {
EGL_CONTEXT_GLES_2_0 = 0,
@@ -385,10 +391,10 @@ class CHyprOpenGLImpl {
bool m_monitorTransformEnabled = false; // do not modify directly
std::stack<bool> m_monitorTransformStack;
- SP<CTexture> m_missingAssetTexture;
- SP<CTexture> m_lockDeadTexture;
- SP<CTexture> m_lockDead2Texture;
- SP<CTexture> m_lockTtyTextTexture;
+ SP<ITexture> m_missingAssetTexture;
+ SP<ITexture> m_lockDeadTexture;
+ SP<ITexture> m_lockDead2Texture;
+ SP<ITexture> m_lockTtyTextTexture;
SP<CShader> m_finalScreenShader;
CTimer m_globalTimer;
GLuint m_currentProgram;
@@ -414,22 +420,22 @@ class CHyprOpenGLImpl {
std::optional<std::vector<uint64_t>> getModsForFormat(EGLint format);
// returns the out FB, can be either Mirror or MirrorSwap
- CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage);
- CFramebuffer* blurFramebufferWithDamage(float a, CRegion* damage, CFramebuffer& source);
-
- void passCMUniforms(WP<CShader>, const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription,
- bool modifySDR = false, float sdrMinLuminance = -1.0f, int sdrMaxLuminance = -1);
- void passCMUniforms(WP<CShader>, const NColorManagement::PImageDescription imageDescription);
- void renderSplash(cairo_t* const, cairo_surface_t* const, double offset, const Vector2D& size);
- void renderRectInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
- void renderRectWithBlurInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
- void renderRectWithDamageInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
- WP<CShader> renderToOutputInternal();
- WP<CShader> renderToFBInternal(const STextureRenderData& data, eTextureType texType, const CBox& newBox);
- void renderTextureInternal(SP<CTexture>, const CBox&, const STextureRenderData& data);
- void renderTextureWithBlurInternal(SP<CTexture>, const CBox&, const STextureRenderData& data);
-
- void preBlurForCurrentMonitor();
+ SP<IFramebuffer> blurMainFramebufferWithDamage(float a, CRegion* damage);
+ SP<IFramebuffer> blurFramebufferWithDamage(float a, CRegion* damage, CGLFramebuffer& source);
+
+ void passCMUniforms(WP<CShader>, const NColorManagement::PImageDescription imageDescription, const NColorManagement::PImageDescription targetImageDescription,
+ bool modifySDR = false, float sdrMinLuminance = -1.0f, int sdrMaxLuminance = -1);
+ void passCMUniforms(WP<CShader>, const NColorManagement::PImageDescription imageDescription);
+ void renderSplash(cairo_t* const, cairo_surface_t* const, double offset, const Vector2D& size);
+ void renderRectInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
+ void renderRectWithBlurInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
+ void renderRectWithDamageInternal(const CBox&, const CHyprColor&, const SRectRenderData& data);
+ WP<CShader> renderToOutputInternal();
+ WP<CShader> renderToFBInternal(const STextureRenderData& data, eTextureType texType, const CBox& newBox);
+ void renderTextureInternal(SP<ITexture>, const CBox&, const STextureRenderData& data);
+ void renderTextureWithBlurInternal(SP<ITexture>, const CBox&, const STextureRenderData& data);
+
+ void preBlurForCurrentMonitor();
friend class CHyprRenderer;
friend class CTexPassElement;