marked stable
[synfig.git] / synfig-core / tags / stable / src / modules / lyr_std / warp.h
1 /*! ========================================================================
2 ** Sinfg
3 ** Template Header File
4 ** $Id: warp.h,v 1.2 2005/01/24 05:00:18 darco Exp $
5 **
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
7 **
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
11 **
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
16 **
17 ** === N O T E S ===========================================================
18 **
19 ** ========================================================================= */
20
21 /* === S T A R T =========================================================== */
22
23 #ifndef __SINFG_WARP_H
24 #define __SINFG_WARP_H
25
26 /* === H E A D E R S ======================================================= */
27
28 #include <sinfg/vector.h>
29 #include <sinfg/angle.h>
30 #include <sinfg/layer.h>
31 #include <sinfg/rect.h>
32
33 /* === M A C R O S ========================================================= */
34
35 /* === T Y P E D E F S ===================================================== */
36
37 /* === C L A S S E S & S T R U C T S ======================================= */
38
39 using namespace sinfg;
40 using namespace std;
41 using namespace etl;
42 class Warp_Trans;
43
44 class Warp : public Layer
45 {
46         SINFG_LAYER_MODULE_EXT
47         friend class Warp_Trans;
48 private:
49
50         Point src_tl,src_br,dest_tl,dest_tr,dest_bl,dest_br;
51
52         Real horizon;
53
54         Real cache_a,cache_b,cache_c,cache_d,cache_e,cache_f,cache_i,cache_j;
55
56         Real matrix[3][3];
57         Real inv_matrix[3][3];
58
59         Point transform_forward(const Point& p)const;
60         Point transform_backward(const Point& p)const;
61
62         Real transform_forward_z(const Point& p)const;
63         Real transform_backward_z(const Point& p)const;
64
65         bool clip;
66
67 public:
68         void sync();
69         
70         Warp();
71         ~Warp();
72         
73         virtual sinfg::Rect get_full_bounding_rect(sinfg::Context context)const;
74         virtual sinfg::Rect get_bounding_rect()const;
75         
76         virtual bool set_param(const sinfg::String & param, const sinfg::ValueBase &value);
77         virtual ValueBase get_param(const sinfg::String & param)const;
78         virtual Color get_color(Context context, const Point &pos)const;
79         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
80         sinfg::Layer::Handle hit_check(sinfg::Context context, const sinfg::Point &point)const; 
81         virtual Vocab get_param_vocab()const;   
82         virtual etl::handle<sinfg::Transform> get_transform()const;
83 };
84
85 /* === E N D =============================================================== */
86
87 #endif