|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Graphics Extension Library source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "GfxEllipseIteratorP.h" |
|
20 #include "GfxEllipse2D.h" |
|
21 |
|
22 |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // Constructor |
|
26 // --------------------------------------------------------------------------- |
|
27 // -------------------------------------------------------------------------- |
|
28 // CGfxEllipseIteratorP::CGfxEllipseIteratorP( TGfxEllipse2D* aEllipse, |
|
29 // --------------------------------------------------------------------------- |
|
30 CGfxEllipseIteratorP::CGfxEllipseIteratorP( TGfxEllipse2D* aEllipse, |
|
31 TGfxAffineTransform* aTransform ) |
|
32 { |
|
33 TFloatFixPt KZero; |
|
34 if ( aEllipse->iWidth < KZero ) |
|
35 aEllipse->iWidth = KZero; |
|
36 |
|
37 if ( aEllipse->iHeight < KZero ) |
|
38 aEllipse->iHeight = KZero; |
|
39 |
|
40 iEllipse = aEllipse; |
|
41 iTransform = aTransform; |
|
42 } |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // TGfxSegType CGfxEllipseIteratorP::CurrentSegment( TFloatFixPt* aCoords ) |
|
46 // --------------------------------------------------------------------------- |
|
47 TGfxSegType CGfxEllipseIteratorP::CurrentSegment( TFloatFixPt* aCoords ) |
|
48 { |
|
49 TGfxSegType segtype; |
|
50 |
|
51 TInt32 pts = 3; |
|
52 |
|
53 TFloatFixPt px[12], py[12]; |
|
54 |
|
55 #ifdef SVG_FLOAT_BUILD |
|
56 TFloatFixPt cx = iEllipse->iX + (iEllipse->iWidth * TFloatFixPt(.5f)); |
|
57 TFloatFixPt cy = iEllipse->iY + (iEllipse->iHeight * TFloatFixPt(.5f)); |
|
58 TFloatFixPt offx = iEllipse->iWidth * TFloatFixPt(.257f); |
|
59 TFloatFixPt offy = iEllipse->iHeight * TFloatFixPt(.257f); |
|
60 #else |
|
61 TFloatFixPt cx = iEllipse->iX + (iEllipse->iWidth >> 1); |
|
62 TFloatFixPt cy = iEllipse->iY + (iEllipse->iHeight >> 1); |
|
63 TFloatFixPt offx = TFloatFixPt( 0x41ca, ETrue ) * iEllipse->iWidth; |
|
64 TFloatFixPt offy = TFloatFixPt( 0x41ca, ETrue ) * iEllipse->iHeight; |
|
65 #endif |
|
66 |
|
67 px[0] = px[1] = px[11] = iEllipse->iX; |
|
68 px[2] = px[10] = cx - offx; |
|
69 px[3] = px[9] = cx; |
|
70 px[4] = px[8] = cx + offx; |
|
71 px[5] = px[6] = px[7] = iEllipse->iX + iEllipse->iWidth; |
|
72 |
|
73 py[2] = py[3] = py[4] = iEllipse->iY; |
|
74 py[1] = py[5] = cy - offy; |
|
75 py[0] = py[6] = cy; |
|
76 py[7] = py[11] = cy + offy; |
|
77 py[8] = py[9] = py[10] = iEllipse->iY + iEllipse->iHeight; |
|
78 |
|
79 TFloatFixPt* p = aCoords; |
|
80 switch ( iIdx ) |
|
81 { |
|
82 case 0: |
|
83 p[0] = px[0]; |
|
84 p[1] = py[0]; |
|
85 segtype = EGfxSegMoveTo; |
|
86 pts = 1; |
|
87 break; |
|
88 case 1: |
|
89 p[0] = px[1]; |
|
90 p[1] = py[1]; |
|
91 p[2] = px[2]; |
|
92 p[3] = py[2]; |
|
93 p[4] = px[3]; |
|
94 p[5] = py[3]; |
|
95 segtype = EGfxSegCubicTo; |
|
96 break; |
|
97 case 2: |
|
98 p[0] = px[4]; |
|
99 p[1] = py[4]; |
|
100 p[2] = px[5]; |
|
101 p[3] = py[5]; |
|
102 p[4] = px[6]; |
|
103 p[5] = py[6]; |
|
104 segtype = EGfxSegCubicTo; |
|
105 break; |
|
106 case 3: |
|
107 p[0] = px[7]; |
|
108 p[1] = py[7]; |
|
109 p[2] = px[8]; |
|
110 p[3] = py[8]; |
|
111 p[4] = px[9]; |
|
112 p[5] = py[9]; |
|
113 segtype = EGfxSegCubicTo; |
|
114 break; |
|
115 case 4: |
|
116 p[0] = px[10]; |
|
117 p[1] = py[10]; |
|
118 p[2] = px[11]; |
|
119 p[3] = py[11]; |
|
120 p[4] = px[0]; |
|
121 p[5] = py[0]; |
|
122 segtype = EGfxSegCubicTo; |
|
123 break; |
|
124 default: |
|
125 segtype = EGfxSegClose; |
|
126 pts = 0; |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 if ( !iTransform->IsIdentity() && pts > 0 ) |
|
132 { |
|
133 iTransform->Transform( aCoords, aCoords, pts ); |
|
134 } |
|
135 |
|
136 return segtype; |
|
137 } |
|
138 |
|
139 // -------------------------------------------------------------------------- |
|
140 // TBool CGfxEllipseIteratorP::IsDone() |
|
141 // --------------------------------------------------------------------------- |
|
142 TBool CGfxEllipseIteratorP::IsDone() |
|
143 { |
|
144 return ( iIdx > 4 ); |
|
145 } |
|
146 |
|
147 // -------------------------------------------------------------------------- |
|
148 // void CGfxEllipseIteratorP::NextL() |
|
149 // --------------------------------------------------------------------------- |
|
150 void CGfxEllipseIteratorP::NextL() |
|
151 { |
|
152 iIdx++; |
|
153 } |
|
154 |
|
155 |