Debian Codegraph @

src/filter/timeout/timeout.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2010-2011 Simon Andreas Eugster ([email protected])
3 * This file is not a Frei0r plugin but a collection of ideas.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/
21 #include <iostream>
22
23 //#define DEBUG
24
25 typedef unsigned char ucharcxx . . $ uchar#;
26 struct ABGRcxx . . $ ABGR# {
27 ucharcxx . . $ uchar# rcxx . . $ ABGR#r.;
28 ucharcxx . . $ uchar# gcxx . . $ ABGR#g.;
29 ucharcxx . . $ uchar# bcxx . . $ ABGR#b.;
30 ucharcxx . . $ uchar# acxx . . $ ABGR#a.;
31
32 ABGRcxx . . $ ABGR# blendcxx . . $ ABGR#blend(6f959f9a9f2184db).(const ABGRcxx . . $ ABGR# &other, const float opacity)
33 {
34 #ifdef DEBUG
35 if (opacity < 0 || opacity > 1) {
36 std::cerr << "Timeout indicator: Opacity must be within 0 and 1!" << std::endl;
37 }
38 #endif
39 const float o1 = opacity;
40 const float o2= 1-opacity;
41 ABGRcxx . . $ ABGR# ret;
42 ret.rcxx . . $ ABGR#r. = o1*rcxx . . $ ABGR#r. + o2*other.rcxx . . $ ABGR#r.;
43 ret.gcxx . . $ ABGR#g. = o1*gcxx . . $ ABGR#g. + o2*other.gcxx . . $ ABGR#g.;
44 ret.bcxx . . $ ABGR#b. = o1*bcxx . . $ ABGR#b. + o2*other.bcxx . . $ ABGR#b.;
45 ret.acxx . . $ ABGR#a. = other.acxx . . $ ABGR#a.;
46 return ret;
47 }
48 };
49
50 class Timeoutcxx . . $ Timeout# : public frei0rcxx . . $ frei0r/::filtercxx . . $ frei0r/filter#
51 {
52
53 public:
54
55 Timeoutcxx . . $ Timeout#Timeout(b4d55b1286ff73e8).(unsigned int width, unsigned int height)
56
57 {
58 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(m_timecxx . . $ Timeout#m_time., "time"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Current time"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
59 register_paramcxx . . $ frei0r/fx#register_param(82eda48613cf5a7a).(m_colorcxx . . $ Timeout#m_color., "color"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Indicator colour"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
60 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(m_transparencycxx . . $ Timeout#m_transparency., "transparency"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., "Indicator transparency"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
61
62 Wcxx . . $ Timeout#W. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(width, height) / 20;
63 Hcxx . . $ Timeout#H. = Wcxx . . $ Timeout#W.;
64
65 x0cxx . . $ Timeout#x0. = width-2*Wcxx . . $ Timeout#W.;
66 y0cxx . . $ Timeout#y0. = height-Hcxx . . $ Timeout#H.;
67 }
68
69 ~cxx . . $ Timeout#`~Timeout`(49f6e7a06ebc5aa8).Timeoutcxx . . $ Timeout#()
70 {
71 // Delete member variables if necessary.
72 }
73
74 virtual void updatecxx . . $ Timeout#update(da7b4a17ceb4e697).(double time,
75 uint32_t* out,
76 const uint32_t* in)
77 {
78 stdcxx . . $ std/::copycxx . . $ std/copy(88304b602929f6f4).(in, in + widthcxx . . $ frei0r/fx#width.*heightcxx . . $ frei0r/fx#height., out);
79
80
81 ABGRcxx . . $ ABGR# col;
82 col.rcxx . . $ ABGR#r. = 255*m_colorcxx . . $ Timeout#m_color..r;
83 col.gcxx . . $ ABGR#g. = 255*m_colorcxx . . $ Timeout#m_color..g;
84 col.bcxx . . $ ABGR#b. = 255*m_colorcxx . . $ Timeout#m_color..b;
85 col.acxx . . $ ABGR#a. = 255;
86
87 float yt = y0cxx . . $ Timeout#y0. - (1-m_timecxx . . $ Timeout#m_time.)*Hcxx . . $ Timeout#H.;
88 ABGRcxx . . $ ABGR# *outAsABGR = (ABGRcxx . . $ ABGR#*) out;
89
90 #ifdef DEBUG
91 #define printcol(x) std::cout << #x ": [ " << (int) x.r << " | " << (int) x.g << " | " << (int) x.b << " ]" << std::endl;
92
93 std::cout << "r = " << m_color.r << ", g = " << m_color.g << std::endl;
94 ABGR blended = col.blend(outAsABGR[0], .5);
95 printcol(col);
96 printcol(outAsABGR[0]);
97 printcol(blended);
98 #undef printcol
99 #endif
100
101
102 for (int y = y0cxx . . $ Timeout#y0.; y > int(yt); y--) {
103
104 float factor = 1-m_transparencycxx . . $ Timeout#m_transparency.;
105 if (y == int(yt)) {
106 factor *= 1 - (yt-int(yt));
107 }
108
109 for (int x = x0cxx . . $ Timeout#x0.; x < x0cxx . . $ Timeout#x0.+Wcxx . . $ Timeout#W.; x++) {
110
111 outAsABGR[widthcxx . . $ frei0r/fx#width.*y + x] =cxx . . $ ABGR#`operator=`(2d469c351404b121). col.blendcxx . . $ ABGR#blend(6f959f9a9f2184db).(outAsABGR[widthcxx . . $ frei0r/fx#width.*y + x], factor);
112 }
113 }
114
115 }
116
117 private:
118 // The various f0r_params are adjustable parameters.
119 double m_timecxx . . $ Timeout#m_time. = 0.0;
120 f0r_param_color m_colorcxx . . $ Timeout#m_color. = {0.0, 0.0, 0.0};
121 double m_transparencycxx . . $ Timeout#m_transparency. = 0.0;
122
123 unsigned int x0cxx . . $ Timeout#x0., y0cxx . . $ Timeout#y0.;
124 unsigned int Wcxx . . $ Timeout#W. , Hcxx . . $ Timeout#H. ;
125
126 };
127
128
129
130 frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<Timeoutcxx . . $ Timeout#> plugincxx . . $ plugin.("Timeout indicator"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
131 "Timeout indicators e.g. for slides."cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
132 "Simon A. Eugster"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
133 0,2,
134 F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!);