~ubuntu-branches/ubuntu/trusty/compiz-fusion-plugins-main/trusty

« back to all changes in this revision

Viewing changes to mag/src/mag.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-10-19 12:07:20 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20101019120720-c3wffrxv7khh2ll8
Tags: 0.9.2.1-0ubuntu1
* New upstream release
* debian/control, debian/rules:
  - convert to cmake, remove autoconf, and convert to debhelper7
* debian/control:
  - bump compiz build-dep and deps to 0.9,
  - reintroduce coreabiversion trick to dep on the good package
* debian/install:
  - removed, seems we shipped all files anyway. Now install in the package
    directly
* debian/docs:
  - adapt to latest upstream shipped file
* debian/source:
  - switch to quilt format
* debian/patches/01-animation-defaults.patch,
  debian/patches/03_default_options.patch,
  debian/patches/06_bug326995.patch,
  debian/patches/08_disable_desktop_vpswitch.patch:
  - adapt to latest version
* debian/patches/02_fix_edges.patch:
  - removed for now: the plugin has been rewritten and have a different
    behavior
* debian/control:
  - remove compiz-fusion-bcop as a build-dep, now built in the core itself
* debian/rules:
  - add some switch to build in package mode, not in debug one

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Compiz magnifier plugin
 
4
 *
 
5
 * mag.h
 
6
 *
 
7
 * Copyright : (C) 2008 by Dennis Kasprzyk
 
8
 * E-mail    : onestone@opencompositing.org
 
9
 *
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU General Public License
 
13
 * as published by the Free Software Foundation; either version 2
 
14
 * of the License, or (at your option) any later version.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 */
 
22
 
 
23
#include <cmath>
 
24
 
 
25
#include <core/core.h>
 
26
#include <composite/composite.h>
 
27
#include <opengl/opengl.h>
 
28
#include <mousepoll/mousepoll.h>
 
29
#include <core/serialization.h>
 
30
 
 
31
#include "mag_options.h"
 
32
 
 
33
#define MAG_SCREEN(s)                                                      \
 
34
    MagScreen *ms = MagScreen::get (s)
 
35
 
 
36
class MagScreen :
 
37
    public PluginClassHandler <MagScreen, CompScreen>,
 
38
    public PluginStateWriter <MagScreen>,
 
39
    public MagOptions,
 
40
    public ScreenInterface,
 
41
    public CompositeScreenInterface,
 
42
    public GLScreenInterface
 
43
{
 
44
    public:
 
45
        MagScreen (CompScreen *screen);
 
46
        ~MagScreen ();
 
47
 
 
48
        CompositeScreen *cScreen;
 
49
        GLScreen            *gScreen;
 
50
 
 
51
        int posX;
 
52
        int posY;
 
53
 
 
54
        bool adjust;
 
55
 
 
56
        GLfloat zVelocity;
 
57
        GLfloat zTarget;
 
58
        GLfloat zoom;
 
59
 
 
60
        enum MagOptions::Mode mode;
 
61
 
 
62
        GLuint texture;
 
63
        GLenum target;
 
64
 
 
65
        int width;
 
66
        int height;
 
67
 
 
68
        GLTexture::List overlay;
 
69
        GLTexture::List mask;
 
70
        CompSize        overlaySize, maskSize;
 
71
 
 
72
        GLuint program;
 
73
 
 
74
        MousePoller poller;
 
75
        
 
76
        template <class Archive>
 
77
        void serialize (Archive &ar, const unsigned int version)
 
78
        {
 
79
            ar & zVelocity;
 
80
            ar & zTarget;
 
81
            ar & zoom;
 
82
            ar & adjust;
 
83
        }
 
84
        
 
85
        void
 
86
        postLoad ();
 
87
        
 
88
        bool
 
89
        checkStateTimeout ();
 
90
 
 
91
        void
 
92
        preparePaint (int ms);
 
93
 
 
94
        bool
 
95
        glPaintOutput (const GLScreenPaintAttrib &attrib,
 
96
                       const GLMatrix            &transform,
 
97
                       const CompRegion          &region,
 
98
                       CompOutput                *output,
 
99
                       unsigned int              mask);
 
100
 
 
101
        void
 
102
        donePaint ();
 
103
 
 
104
        void
 
105
        cleanup ();
 
106
 
 
107
        bool
 
108
        loadFragmentProgram ();
 
109
 
 
110
        bool
 
111
        loadImages ();
 
112
 
 
113
        void
 
114
        optionChanged (CompOption             *opt,
 
115
                                  MagOptions::Options num);
 
116
 
 
117
        void
 
118
        damageRegion ();
 
119
 
 
120
        void
 
121
        positionUpdate (const CompPoint &pos);
 
122
 
 
123
        int
 
124
        adjustZoom (float chunk);
 
125
 
 
126
        void
 
127
        paintSimple ();
 
128
 
 
129
        void
 
130
        paintImage ();
 
131
 
 
132
        void
 
133
        paintFisheye ();
 
134
 
 
135
        bool
 
136
        terminate (CompAction     *action,
 
137
                      CompAction::State   state,
 
138
                      CompOption::Vector options);
 
139
 
 
140
        bool
 
141
        initiate (CompAction      *action,
 
142
                  CompAction::State   state,
 
143
                  CompOption::Vector options);
 
144
 
 
145
        bool
 
146
        zoomIn (CompAction        *action,
 
147
                CompAction::State   state,
 
148
                CompOption::Vector options);
 
149
 
 
150
        bool
 
151
        zoomOut (CompAction       *action,
 
152
                 CompAction::State   state,
 
153
                 CompOption::Vector options);
 
154
 
 
155
};
 
156
 
 
157
class MagPluginVTable :
 
158
    public CompPlugin::VTableForScreen <MagScreen>
 
159
{
 
160
    public:
 
161
        bool init ();
 
162
};
 
163
 
 
164
static const char *fisheyeFpString =
 
165
    "!!ARBfp1.0"
 
166
 
 
167
    "PARAM p0 = program.env[0];"
 
168
    "PARAM p1 = program.env[1];"
 
169
    "PARAM p2 = program.env[2];"
 
170
 
 
171
    "TEMP t0, t1, t2, t3;"
 
172
 
 
173
    "SUB t1, p0.xyww, fragment.texcoord[0];"
 
174
    "DP3 t2, t1, t1;"
 
175
    "RSQ t2, t2.x;"
 
176
    "SUB t0, t2, p0;"
 
177
 
 
178
    "RCP t3, t2.x;"
 
179
    "MAD t3, t3, p1.z, p2.z;"
 
180
    "COS t3, t3.x;"
 
181
 
 
182
    "MUL t3, t3, p1.w;"
 
183
 
 
184
    "MUL t1, t2, t1;"
 
185
    "MAD t1, t1, t3, fragment.texcoord[0];"
 
186
 
 
187
    "CMP t1, t0.z, fragment.texcoord[0], t1;"
 
188
                
 
189
    "MAD t1, t1, p1, p2;"
 
190
    "TEX result.color, t1, texture[0], %s;"
 
191
 
 
192
    "END";