Changeset View
Changeset View
Standalone View
Standalone View
effects/blur/blurshader.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 36 | public: | |||
---|---|---|---|---|---|
42 | bool isValid() const { | 42 | bool isValid() const { | ||
43 | return mValid; | 43 | return mValid; | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | virtual void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) = 0; | 46 | virtual void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) = 0; | ||
47 | virtual void setOffset(float offset) = 0; | 47 | virtual void setOffset(float offset) = 0; | ||
48 | virtual void setTargetSize(QSize renderTextureSize) = 0; | 48 | virtual void setTargetSize(QSize renderTextureSize) = 0; | ||
49 | virtual void setBlurRect(QRect blurRect, QSize screenSize) = 0; | 49 | virtual void setBlurRect(QRect blurRect, QSize screenSize) = 0; | ||
50 | virtual void setNoiseTextureRatio(float ratio) = 0; | ||||
50 | 51 | | |||
51 | enum SampleType { | 52 | enum SampleType { | ||
52 | DownSampleType, | 53 | DownSampleType, | ||
53 | UpSampleType, | 54 | UpSampleType, | ||
54 | CopySampleType | 55 | CopySampleType, | ||
56 | NoiseSampleType | ||||
55 | }; | 57 | }; | ||
56 | 58 | | |||
57 | virtual void bind(SampleType sampleType) = 0; | 59 | virtual void bind(SampleType sampleType) = 0; | ||
58 | virtual void unbind() = 0; | 60 | virtual void unbind() = 0; | ||
59 | 61 | | |||
60 | protected: | 62 | protected: | ||
61 | void setIsValid(bool value) { | 63 | void setIsValid(bool value) { | ||
62 | mValid = value; | 64 | mValid = value; | ||
Show All 17 Lines | 80 | public: | |||
80 | ~GLSLBlurShader(); | 82 | ~GLSLBlurShader(); | ||
81 | 83 | | |||
82 | void bind(SampleType sampleType) override final; | 84 | void bind(SampleType sampleType) override final; | ||
83 | void unbind() override final; | 85 | void unbind() override final; | ||
84 | void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) override final; | 86 | void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) override final; | ||
85 | void setOffset(float offset) override final; | 87 | void setOffset(float offset) override final; | ||
86 | void setTargetSize(QSize renderTextureSize) override final; | 88 | void setTargetSize(QSize renderTextureSize) override final; | ||
87 | void setBlurRect(QRect blurRect, QSize screenSize) override final; | 89 | void setBlurRect(QRect blurRect, QSize screenSize) override final; | ||
90 | void setNoiseTextureRatio(float ratio) override final; | ||||
88 | 91 | | |||
89 | protected: | 92 | protected: | ||
90 | void init() override final; | 93 | void init() override final; | ||
91 | void reset() override final; | 94 | void reset() override final; | ||
92 | 95 | | |||
93 | private: | 96 | private: | ||
94 | GLShader *m_shaderDownsample = nullptr; | 97 | GLShader *m_shaderDownsample = nullptr; | ||
95 | GLShader *m_shaderUpsample = nullptr; | 98 | GLShader *m_shaderUpsample = nullptr; | ||
96 | GLShader *m_shaderCopysample = nullptr; | 99 | GLShader *m_shaderCopysample = nullptr; | ||
100 | GLShader *m_shaderNoisesample = nullptr; | ||||
97 | 101 | | |||
98 | int m_mvpMatrixLocationDownsample; | 102 | int m_mvpMatrixLocationDownsample; | ||
99 | int m_offsetLocationDownsample; | 103 | int m_offsetLocationDownsample; | ||
100 | int m_renderTextureSizeLocationDownsample; | 104 | int m_renderTextureSizeLocationDownsample; | ||
101 | int m_halfpixelLocationDownsample; | 105 | int m_halfpixelLocationDownsample; | ||
102 | 106 | | |||
103 | int m_mvpMatrixLocationUpsample; | 107 | int m_mvpMatrixLocationUpsample; | ||
104 | int m_offsetLocationUpsample; | 108 | int m_offsetLocationUpsample; | ||
105 | int m_renderTextureSizeLocationUpsample; | 109 | int m_renderTextureSizeLocationUpsample; | ||
106 | int m_halfpixelLocationUpsample; | 110 | int m_halfpixelLocationUpsample; | ||
107 | 111 | | |||
108 | int m_mvpMatrixLocationCopysample; | 112 | int m_mvpMatrixLocationCopysample; | ||
109 | int m_renderTextureSizeLocationCopysample; | 113 | int m_renderTextureSizeLocationCopysample; | ||
110 | int m_blurRectLocationCopysample; | 114 | int m_blurRectLocationCopysample; | ||
111 | 115 | | |||
116 | int m_mvpMatrixLocationNoisesample; | ||||
117 | int m_renderTextureSizeLocationNoisesample; | ||||
118 | int m_noiseTexRatioLocationNoisesample; | ||||
119 | | ||||
112 | 120 | | |||
113 | //Caching uniform values to aviod unnecessary setUniform calls | 121 | //Caching uniform values to aviod unnecessary setUniform calls | ||
114 | int m_activeSampleType; | 122 | int m_activeSampleType; | ||
115 | 123 | | |||
116 | float m_offsetDownsample; | 124 | float m_offsetDownsample; | ||
117 | QMatrix4x4 m_matrixDownsample; | 125 | QMatrix4x4 m_matrixDownsample; | ||
118 | QSize m_renderTextureSizeDownsample; | 126 | QSize m_renderTextureSizeDownsample; | ||
119 | 127 | | |||
120 | float m_offsetUpsample; | 128 | float m_offsetUpsample; | ||
121 | QMatrix4x4 m_matrixUpsample; | 129 | QMatrix4x4 m_matrixUpsample; | ||
122 | QSize m_renderTextureSizeUpsample; | 130 | QSize m_renderTextureSizeUpsample; | ||
123 | 131 | | |||
124 | QMatrix4x4 m_matrixCopysample; | 132 | QMatrix4x4 m_matrixCopysample; | ||
125 | QSize m_renderTextureSizeCopysample; | 133 | QSize m_renderTextureSizeCopysample; | ||
126 | QRect m_blurRectCopysample; | 134 | QRect m_blurRectCopysample; | ||
127 | 135 | | |||
136 | QMatrix4x4 m_matrixNoisesample; | ||||
137 | QSize m_renderTextureSizeNoisesample; | ||||
138 | float m_noiseTexRatioNoisesample; | ||||
139 | | ||||
128 | }; | 140 | }; | ||
129 | 141 | | |||
130 | } // namespace KWin | 142 | } // namespace KWin | ||
131 | 143 | | |||
132 | #endif | 144 | #endif |