author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 8 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtOpenGL module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QTRIANGULATINGSTROKER_P_H |
|
43 |
#define QTRIANGULATINGSTROKER_P_H |
|
44 |
||
45 |
#include <private/qdatabuffer_p.h> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
#include <qvarlengtharray.h> |
0 | 47 |
#include <private/qvectorpath_p.h> |
48 |
#include <private/qbezier_p.h> |
|
49 |
#include <private/qnumeric_p.h> |
|
50 |
#include <private/qmath_p.h> |
|
51 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
QT_BEGIN_NAMESPACE |
0 | 53 |
|
54 |
class QTriangulatingStroker |
|
55 |
{ |
|
56 |
public: |
|
57 |
void process(const QVectorPath &path, const QPen &pen); |
|
58 |
||
59 |
inline int vertexCount() const { return m_vertices.size(); } |
|
60 |
inline const float *vertices() const { return m_vertices.data(); } |
|
61 |
||
62 |
inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } |
|
63 |
||
64 |
private: |
|
65 |
inline void emitLineSegment(float x, float y, float nx, float ny); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
void moveTo(const qreal *pts); |
0 | 67 |
inline void lineTo(const qreal *pts); |
68 |
void cubicTo(const qreal *pts); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
void join(const qreal *pts); |
0 | 70 |
inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
void endCap(const qreal *pts); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray<float> &points); |
0 | 73 |
void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); |
74 |
||
75 |
||
76 |
QDataBuffer<float> m_vertices; |
|
77 |
||
78 |
float m_cx, m_cy; // current points |
|
79 |
float m_nvx, m_nvy; // normal vector... |
|
80 |
float m_width; |
|
81 |
qreal m_miter_limit; |
|
82 |
||
83 |
int m_roundness; // Number of line segments in a round join |
|
84 |
qreal m_sin_theta; // sin(m_roundness / 360); |
|
85 |
qreal m_cos_theta; // cos(m_roundness / 360); |
|
86 |
qreal m_inv_scale; |
|
87 |
float m_curvyness_mul; |
|
88 |
float m_curvyness_add; |
|
89 |
||
90 |
Qt::PenJoinStyle m_join_style; |
|
91 |
Qt::PenCapStyle m_cap_style; |
|
92 |
}; |
|
93 |
||
94 |
class QDashedStrokeProcessor |
|
95 |
{ |
|
96 |
public: |
|
97 |
QDashedStrokeProcessor(); |
|
98 |
||
99 |
void process(const QVectorPath &path, const QPen &pen); |
|
100 |
||
101 |
inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) { |
|
102 |
m_points.add(x); |
|
103 |
m_points.add(y); |
|
104 |
m_types.add(type); |
|
105 |
} |
|
106 |
||
107 |
inline int elementCount() const { return m_types.size(); } |
|
108 |
inline qreal *points() const { return m_points.data(); } |
|
109 |
inline QPainterPath::ElementType *elementTypes() const { return m_types.data(); } |
|
110 |
||
111 |
inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } |
|
112 |
||
113 |
private: |
|
114 |
QDataBuffer<qreal> m_points; |
|
115 |
QDataBuffer<QPainterPath::ElementType> m_types; |
|
116 |
QDashStroker m_dash_stroker; |
|
117 |
qreal m_inv_scale; |
|
118 |
}; |
|
119 |
||
120 |
inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, float y2, |
|
121 |
float *nx, float *ny) |
|
122 |
{ |
|
123 |
float dx = x2 - x1; |
|
124 |
float dy = y2 - y1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
float pw; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
if (dx == 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
pw = m_width / qAbs(dy); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
else if (dy == 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
pw = m_width / qAbs(dx); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
pw = m_width / sqrt(dx*dx + dy*dy); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
|
0 | 135 |
*nx = -dy * pw; |
136 |
*ny = dx * pw; |
|
137 |
} |
|
138 |
||
139 |
inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, float vy) |
|
140 |
{ |
|
141 |
m_vertices.add(x + vx); |
|
142 |
m_vertices.add(y + vy); |
|
143 |
m_vertices.add(x - vx); |
|
144 |
m_vertices.add(y - vy); |
|
145 |
} |
|
146 |
||
147 |
void QTriangulatingStroker::lineTo(const qreal *pts) |
|
148 |
{ |
|
149 |
emitLineSegment(pts[0], pts[1], m_nvx, m_nvy); |
|
150 |
m_cx = pts[0]; |
|
151 |
m_cy = pts[1]; |
|
152 |
} |
|
153 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
154 |
QT_END_NAMESPACE |
0 | 155 |
|
156 |
#endif |