~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to server/rect.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
3
 
// 
4
 
// This program is free software; you can redistribute it and/or modify
5
 
// it under the terms of the GNU General Public License as published by
6
 
// the Free Software Foundation; either version 3 of the License, or
7
 
// (at your option) any later version.
8
 
// 
9
 
// This program is distributed in the hope that it will be useful,
10
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
// GNU General Public License for more details.
13
 
// 
14
 
// You should have received a copy of the GNU General Public License
15
 
// along with this program; if not, write to the Free Software
16
 
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
 
 
18
 
/* $Id: rect.h,v 1.23 2008/01/21 20:55:51 rsavoye Exp $ */
19
 
 
20
 
#ifndef GNASH_RECT_H
21
 
#define GNASH_RECT_H
22
 
 
23
 
#ifdef HAVE_CONFIG_H
24
 
#include "gnashconfig.h"
25
 
#endif
26
 
 
27
 
#include "tu_config.h"
28
 
 
29
 
#include "Range2d.h"
30
 
#include "Point2d.h"
31
 
 
32
 
#include <cassert> // for inlines
33
 
#include <iostream> // for output operator
34
 
 
35
 
// Forward decl
36
 
namespace gnash {
37
 
        class matrix;
38
 
        class stream;
39
 
}
40
 
 
41
 
namespace gnash {
42
 
 
43
 
/// \brief
44
 
/// Rectangle class, basically a wrapper around a
45
 
/// gnash::geometry::Range2d<float> with a few
46
 
/// additional methods for reading it from the
47
 
/// stream ..
48
 
//
49
 
/// used by render handler (?)
50
 
///
51
 
class DSOLOCAL rect
52
 
{
53
 
private:
54
 
 
55
 
        geometry::Range2d<float> _range;
56
 
 
57
 
public:
58
 
 
59
 
        /// Ouput operator
60
 
        friend std::ostream& operator<< (std::ostream& os, const rect& rect);
61
 
 
62
 
        /// Construct a NULL rectangle
63
 
        rect()
64
 
                :
65
 
                _range()
66
 
        {}
67
 
 
68
 
        /// Construct a rectangle with given coordinates
69
 
        rect(float xmin, float ymin, float xmax, float ymax)
70
 
                :
71
 
                _range(xmin, ymin, xmax, ymax)
72
 
        {
73
 
        }
74
 
 
75
 
        /// returns true if this is the NULL rectangle
76
 
        bool is_null() const
77
 
        {
78
 
                return _range.isNull();
79
 
        }
80
 
 
81
 
        /// returns true if this is the WORLD rectangle
82
 
        bool is_world() const
83
 
        {
84
 
                return _range.isWorld();
85
 
        }
86
 
 
87
 
        /// set the rectangle to the NULL value
88
 
        void set_null()
89
 
        {
90
 
                _range.setNull();
91
 
        }
92
 
 
93
 
        /// set the rectangle to the WORLD value
94
 
        void set_world()
95
 
        {
96
 
                _range.setWorld();
97
 
        }
98
 
 
99
 
        /// Read a bit-packed rectangle from an SWF stream
100
 
        //
101
 
        /// Format of the bit-packed rectangle is:
102
 
        ///
103
 
        ///     bits  | name  | description
104
 
        ///     ------+-------+-------------------------
105
 
        ///       5   | nbits | number of bits used in subsequent values
106
 
        ///     nbits | xmin  | minimum X value
107
 
        ///     nbits | xmax  | maximum X value
108
 
        ///     nbits | ymin  | minimum Y value
109
 
        ///     nbits | ymax  | maximum Y value
110
 
        ///
111
 
        /// If max values are less then min values the SWF is malformed;
112
 
        /// in this case this method will raise an swf_error and set the
113
 
        /// rectangle to the NULL rectangle. See is_null().
114
 
        ///     
115
 
        ///
116
 
        void    read(stream* in);
117
 
 
118
 
        void    print() const;
119
 
 
120
 
        /// Return true if the specified point is inside this rect.
121
 
        bool    point_test(float x, float y) const
122
 
        {
123
 
                return _range.contains(x, y);
124
 
        }
125
 
 
126
 
        /// Expand this rectangle to enclose the given point.
127
 
        void    expand_to_point(float x, float y)
128
 
        {
129
 
                _range.expandTo(x, y);
130
 
        }
131
 
        
132
 
        /// Expand this rectangle to enclose the given circle.
133
 
        void    expand_to_circle(float x, float y, float radius)
134
 
        {
135
 
                _range.expandToCircle(x, y, radius);
136
 
        }
137
 
 
138
 
        /// Set ourself to bound the given point
139
 
        void    enclose_point(float x, float y)
140
 
        {
141
 
                _range.setTo(x, y);
142
 
        }
143
 
 
144
 
        /// Return width this rectangle
145
 
        float   width() const
146
 
        {
147
 
                return _range.width();
148
 
        }
149
 
 
150
 
        /// Return height this rectangle
151
 
        float   height() const
152
 
        {
153
 
                return _range.height();
154
 
        }
155
 
 
156
 
        /// Shift this rectangle horizontally
157
 
        //
158
 
        /// A positive offset will shift to the right,
159
 
        /// A negative offset will shift to the left.
160
 
        ///
161
 
        void shift_x(float offset)
162
 
        {
163
 
                _range.shiftX(offset);
164
 
        }
165
 
 
166
 
        /// Shift this rectangle vertically
167
 
        //
168
 
        /// A positive offset will increment y values.
169
 
        /// A negative offset will decrement y values.
170
 
        ///
171
 
        /// TODO: document what the orientation is supposed     
172
 
        ///       to be (up/down) ?
173
 
        ///
174
 
        void shift_y(float offset)
175
 
        {
176
 
                _range.shiftY(offset);
177
 
        }
178
 
 
179
 
        /// Scale this rectangle horizontally
180
 
        //
181
 
        /// A positive factor will make the rectangle bigger.
182
 
        /// A negative factor will make the rectangle smaller.
183
 
        /// A factor of 1 will leave it unchanged.
184
 
        ///
185
 
        void scale_x(float factor)
186
 
        {
187
 
                _range.scaleX(factor);
188
 
        }
189
 
 
190
 
        /// Scale this rectangle vertically
191
 
        //
192
 
        /// A positive factor will make the rectangle bigger.
193
 
        /// A negative factor will make the rectangle smaller.
194
 
        /// A factor of 1 will leave it unchanged.
195
 
        ///
196
 
        void scale_y(float factor)
197
 
        {
198
 
                _range.scaleY(factor);
199
 
        }
200
 
 
201
 
        /// Get min X ordinate.
202
 
        //
203
 
        /// Don't call this against a null rectangle
204
 
        ///
205
 
        float   get_x_min() const
206
 
        {
207
 
                return _range.getMinX();
208
 
        }
209
 
 
210
 
        /// Get max X ordinate.
211
 
        //
212
 
        /// Don't call this against a null rectangle
213
 
        ///
214
 
        float   get_x_max() const
215
 
        {
216
 
                return _range.getMaxX();
217
 
        }
218
 
 
219
 
        /// Get min Y ordinate.
220
 
        //
221
 
        /// Don't call this against a null rectangle
222
 
        ///
223
 
        float   get_y_min() const
224
 
        {
225
 
                return _range.getMinY();
226
 
        }
227
 
 
228
 
        /// Get max Y ordinate.
229
 
        //
230
 
        /// Don't call this against a null rectangle
231
 
        ///
232
 
        float   get_y_max() const
233
 
        {
234
 
                return _range.getMaxY();
235
 
        }
236
 
 
237
 
        /// Get one of the rect verts.
238
 
        //
239
 
        /// Don't call on a NULL rect !
240
 
        ///
241
 
        /// TODO: deprecate this ?
242
 
        point   get_corner(int i) const;
243
 
 
244
 
        /// \brief
245
 
        /// Make sure that the given point falls
246
 
        /// in this rectangle, modifying it's coordinates
247
 
        /// if needed.
248
 
        ///
249
 
        /// Don't call against a NULL rectangle !
250
 
        ///
251
 
        void clamp(point& p) const;
252
 
 
253
 
        /// Set ourself to bound a rectangle that has been transformed
254
 
        /// by m.  This is an axial bound of an oriented (and/or
255
 
        /// sheared, scaled, etc) box.
256
 
        void    enclose_transformed_rect(const matrix& m, const rect& r);
257
 
        
258
 
        /// Same as enclose_transformed_rect but expanding the current rect instead
259
 
        /// of replacing it.
260
 
        DSOEXPORT void  expand_to_transformed_rect(const matrix& m, const rect& r);
261
 
        
262
 
        /// Makes union of the given and the current rect
263
 
        DSOEXPORT void  expand_to_rect(const rect& r);
264
 
 
265
 
        void    set_lerp(const rect& a, const rect& b, float t);
266
 
 
267
 
 
268
 
        /// \brief
269
 
        /// Returns a const reference to the underlying
270
 
        /// Range2d object.
271
 
        const geometry::Range2d<float> & getRange() const
272
 
        {
273
 
                return _range;
274
 
        }
275
 
 
276
 
        /// Return a string representation for this rectangle
277
 
        std::string toString() const;
278
 
};
279
 
 
280
 
inline std::ostream&
281
 
operator<< (std::ostream& os, const rect& rect)
282
 
{
283
 
        return os << rect._range;
284
 
}
285
 
 
286
 
}       // namespace gnash
287
 
 
288
 
#endif // GNASH_RECT_H
289
 
 
290
 
 
291
 
// Local Variables:
292
 
// mode: C++
293
 
// indent-tabs-mode: t
294
 
// End: