-
Notifications
You must be signed in to change notification settings - Fork 2
/
lightlyshaders.h
87 lines (70 loc) · 3.26 KB
/
lightlyshaders.h
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
80
81
82
83
84
85
86
/*
* Copyright © 2015 Robert Metsäranta <therealestrob@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef LIGHTLYSHADERS_H
#define LIGHTLYSHADERS_H
#include <kwineffects.h>
namespace KWin {
class GLTexture;
class Q_DECL_EXPORT LightlyShadersEffect : public Effect
{
Q_OBJECT
public:
LightlyShadersEffect();
~LightlyShadersEffect();
static bool supported();
static bool enabledByDefault();
void setRoundness(const int r);
void reconfigure(ReconfigureFlags flags) override;
void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
virtual int requestedEffectChainPosition() const override { return 99; }
enum { RoundedCorners = 0, SquircledCorners };
protected Q_SLOTS:
void windowAdded(EffectWindow *window);
void windowDeleted(EffectWindow *window);
void windowMaximizedStateChanged(EffectWindow *window, bool horizontal, bool vertical);
private:
void genMasks();
void genRect();
bool isValidWindow(EffectWindow *w);
void fillRegion(const QRegion ®, const QColor &c);
GLTexture copyTexSubImage(const QRect &geo, const QRect &rect, qreal xTranslation=0.0, qreal yTranslation=0.0);
QList<GLTexture> getTexRegions(EffectWindow *w, const QRect* rect, const QRect &geo, int nTex, qreal xTranslation=0.0, qreal yTranslation=0.0, bool force=false);
void drawSquircle(QPainter *p, float size, int translate);
QImage genMaskImg(int size, bool mask, bool outer_rect);
void getShadowDiffs(EffectWindow *w, const QRect* rect, QList<GLTexture> &empty_corners_tex, qreal xTranslation=0.0, qreal yTranslation=0.0, bool out_of_screen=false);
QRect scale(const QRect rect);
enum { TopLeft = 0, TopRight, BottomRight, BottomLeft, NTex };
enum { Top = 0, Bottom, NShad };
GLTexture *m_tex[NTex];
GLTexture *m_rect[NTex];
GLTexture *m_dark_rect[NTex];
int m_size, m_size_scaled, m_alpha, m_corners_type, m_squircle_ratio, m_roundness, m_shadow_offset;
bool m_outline, m_dark_theme, m_disabled_for_maximized;
QSize m_corner;
QMap<EffectWindow *, QRegion> m_clip;
QMap<EffectWindow *, bool> m_diff_update;
QMap<EffectWindow *, QList<GLTexture>> m_diff;
GLShader *m_shader, *m_diff_shader;
QList<EffectWindow *> m_managed, m_skipEffect;
qreal m_scale=1.0;
};
} // namespace KWin
#endif //LIGHTLYSHADERS_H