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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/*
*
* Compiz magnifier plugin
*
* mag.h
*
* Copyright : (C) 2008 by Dennis Kasprzyk
* E-mail : onestone@opencompositing.org
*
*
* 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.
*
*/
#include <cmath>
#include <core/core.h>
#include <composite/composite.h>
#include <opengl/opengl.h>
#include <mousepoll/mousepoll.h>
#include "mag_options.h"
#define MAG_SCREEN(s) \
MagScreen *ms = MagScreen::get (s)
class MagScreen :
public PluginClassHandler <MagScreen, CompScreen>,
public MagOptions,
public ScreenInterface,
public CompositeScreenInterface,
public GLScreenInterface
{
public:
MagScreen (CompScreen *screen);
~MagScreen ();
CompositeScreen *cScreen;
GLScreen *gScreen;
int posX;
int posY;
bool adjust;
GLfloat zVelocity;
GLfloat zTarget;
GLfloat zoom;
enum MagOptions::Mode mode;
GLuint texture;
GLenum target;
int width;
int height;
GLTexture::List overlay;
GLTexture::List mask;
CompSize overlaySize, maskSize;
GLuint program;
MousePoller poller;
void
preparePaint (int ms);
bool
glPaintOutput (const GLScreenPaintAttrib &attrib,
const GLMatrix &transform,
const CompRegion ®ion,
CompOutput *output,
unsigned int mask);
void
donePaint ();
void
cleanup ();
bool
loadFragmentProgram ();
bool
loadImages ();
void
optionChanged (CompOption *opt,
MagOptions::Options num);
void
damageRegion ();
void
positionUpdate (const CompPoint &pos);
int
adjustZoom (float chunk);
void
paintSimple ();
void
paintImage ();
void
paintFisheye ();
bool
terminate (CompAction *action,
CompAction::State state,
CompOption::Vector options);
bool
initiate (CompAction *action,
CompAction::State state,
CompOption::Vector options);
bool
zoomIn (CompAction *action,
CompAction::State state,
CompOption::Vector options);
bool
zoomOut (CompAction *action,
CompAction::State state,
CompOption::Vector options);
};
class MagPluginVTable :
public CompPlugin::VTableForScreen <MagScreen>
{
public:
bool init ();
};
static const char *fisheyeFpString =
"!!ARBfp1.0"
"PARAM p0 = program.env[0];"
"PARAM p1 = program.env[1];"
"PARAM p2 = program.env[2];"
"TEMP t0, t1, t2, t3;"
"SUB t1, p0.xyww, fragment.texcoord[0];"
"DP3 t2, t1, t1;"
"RSQ t2, t2.x;"
"SUB t0, t2, p0;"
"RCP t3, t2.x;"
"MAD t3, t3, p1.z, p2.z;"
"COS t3, t3.x;"
"MUL t3, t3, p1.w;"
"MUL t1, t2, t1;"
"MAD t1, t1, t3, fragment.texcoord[0];"
"CMP t1, t0.z, fragment.texcoord[0], t1;"
"MAD t1, t1, p1, p2;"
"TEX result.color, t1, texture[0], %s;"
"END";
|