vfs: check userland buffers before reading them.
[haiku.git] / headers / libs / agg / agg_conv_concat.h
blob745d349c6f71cd21a54375dd83f6333b4d86e63b
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 #ifndef AGG_CONV_CONCAT_INCLUDED
17 #define AGG_CONV_CONCAT_INCLUDED
19 #include "agg_basics.h"
21 namespace agg
23 //=============================================================conv_concat
24 // Concatenation of two paths. Usually used to combine lines or curves
25 // with markers such as arrowheads
26 template<class VS1, class VS2> class conv_concat
28 public:
29 conv_concat(VS1& source1, VS2& source2) :
30 m_source1(&source1), m_source2(&source2), m_status(2) {}
31 void attach1(VS1& source) { m_source1 = &source; }
32 void attach2(VS2& source) { m_source2 = &source; }
35 void rewind(unsigned path_id)
37 m_source1->rewind(path_id);
38 m_source2->rewind(0);
39 m_status = 0;
42 unsigned vertex(double* x, double* y)
44 unsigned cmd;
45 if(m_status == 0)
47 cmd = m_source1->vertex(x, y);
48 if(!is_stop(cmd)) return cmd;
49 m_status = 1;
51 if(m_status == 1)
53 cmd = m_source2->vertex(x, y);
54 if(!is_stop(cmd)) return cmd;
55 m_status = 2;
57 return path_cmd_stop;
60 private:
61 conv_concat(const conv_concat<VS1, VS2>&);
62 const conv_concat<VS1, VS2>&
63 operator = (const conv_concat<VS1, VS2>&);
65 VS1* m_source1;
66 VS2* m_source2;
67 int m_status;
73 #endif