|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <bitstd.h> |
|
17 #include <bitdev.h> |
|
18 #include "BITPANIC.H" |
|
19 #include <bitdraw.h> |
|
20 #include <graphics/fbsrasterizer.h> |
|
21 #include "bitgcextradata.h" |
|
22 |
|
23 |
|
24 /** Draws a straight line between two points. |
|
25 |
|
26 The function provides a concrete implementation of the pure virtual |
|
27 function CGraphicsContext::DrawLine(). The function |
|
28 behaviour is the same as documented in that class. */ |
|
29 EXPORT_C void CFbsBitGc::DrawLine(const TPoint& aPt1,const TPoint& aPt2) |
|
30 { |
|
31 CheckDevice(); |
|
32 |
|
33 TRect lineBoundingRect(aPt1,aPt2); |
|
34 lineBoundingRect.Normalize(); |
|
35 lineBoundingRect.Move(iOrigin); |
|
36 lineBoundingRect.Grow((iPenSize.iWidth >> 1) + 1,(iPenSize.iHeight >> 1) + 1); |
|
37 if(!lineBoundingRect.Intersects(iUserClipRect)) |
|
38 { |
|
39 iLinePosition = aPt2;// if DrawLine returns due to aPt2 being outside of the clipping rect then subsequent line are drawn from correct point. |
|
40 return; |
|
41 } |
|
42 |
|
43 SetupDevice(); |
|
44 iDevice->DrawingBegin(); |
|
45 DoDrawLine(aPt1,aPt2,ETrue); |
|
46 iDevice->DrawingEnd(); |
|
47 } |
|
48 |
|
49 /** Draws a straight line from the current drawing point to a specified |
|
50 point. |
|
51 |
|
52 The function provides a concrete implementation of the pure virtual |
|
53 function CGraphicsContext::DrawLineTo(). The function |
|
54 behaviour is the same as documented in that class. */ |
|
55 EXPORT_C void CFbsBitGc::DrawLineTo(const TPoint& aPoint) |
|
56 { |
|
57 DrawLine(iLinePosition,aPoint); |
|
58 } |
|
59 |
|
60 |
|
61 /** Draws a straight line relative to the current drawing point, using a |
|
62 vector. |
|
63 |
|
64 The function provides a concrete implementation of the pure virtual |
|
65 function CGraphicsContext::DrawLineBy(). The function |
|
66 behaviour is the same as documented in that class. */ |
|
67 EXPORT_C void CFbsBitGc::DrawLineBy(const TPoint& aVector) |
|
68 { |
|
69 DrawLine(iLinePosition,iLinePosition + aVector); |
|
70 } |
|
71 |
|
72 /** Draws a polyline from a set of points specified in a list. |
|
73 |
|
74 The functions provides a concrete implementation of the pure virtual |
|
75 functions CGraphicsContext::DrawPolyLine(). The function |
|
76 behaviour is the same as documented in that class. */ |
|
77 EXPORT_C void CFbsBitGc::DrawPolyLine(const CArrayFix<TPoint>* aPointList) |
|
78 { |
|
79 if(!aPointList || iPenSize.iWidth < 1 || iPenSize.iHeight < 1) |
|
80 return; |
|
81 |
|
82 const TInt vertexes = aPointList->Count()-1; |
|
83 |
|
84 for (TInt count = 0; count < vertexes; count++) |
|
85 DrawLine((*aPointList)[count],(*aPointList)[count + 1]); |
|
86 |
|
87 if (iPenStyle == CGraphicsContext::ESolidPen && vertexes >= 0) |
|
88 Plot((*aPointList)[vertexes]); |
|
89 } |
|
90 |
|
91 /** Draws a polyline from a set of points specified in an array, but does not draw |
|
92 the final point of the last line. |
|
93 |
|
94 @param aPointList An array containing the points on the polyline. */ |
|
95 EXPORT_C void CFbsBitGc::DrawPolyLineNoEndPoint(const CArrayFix<TPoint>* aPointList) |
|
96 { |
|
97 if(!aPointList || iPenSize.iWidth < 1 || iPenSize.iHeight < 1) |
|
98 return; |
|
99 |
|
100 const TInt vertexes = aPointList->Count() - 1; |
|
101 |
|
102 for (TInt count = 0; count < vertexes; count++) |
|
103 DrawLine((*aPointList)[count],(*aPointList)[count + 1]); |
|
104 } |
|
105 |
|
106 /** Draws a polyline from a set of points specified in a list. |
|
107 |
|
108 The functions provides a concrete implementation of the pure virtual |
|
109 functions CGraphicsContext::DrawPolyLine(). The function |
|
110 behaviour is the same as documented in that class. */ |
|
111 EXPORT_C void CFbsBitGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints) |
|
112 { |
|
113 DrawPolyLineNoEndPoint(aPointList,aNumPoints); |
|
114 |
|
115 if (iPenStyle == CGraphicsContext::ESolidPen) |
|
116 Plot(aPointList[aNumPoints - 1]); |
|
117 } |
|
118 |
|
119 /** Draws a polyline from a set of points specified in a list, but does not |
|
120 draw the final point of the last line. |
|
121 |
|
122 @param aPointList Pointer to a set of points on the polyline. |
|
123 @param aNumPoints Number of points in the list. */ |
|
124 EXPORT_C void CFbsBitGc::DrawPolyLineNoEndPoint(const TPoint* aPointList,TInt aNumPoints) |
|
125 { |
|
126 if (!aPointList || iPenSize.iWidth < 1 || iPenSize.iHeight < 1) |
|
127 return; |
|
128 |
|
129 const TInt vertexes = aNumPoints - 1; |
|
130 |
|
131 for (TInt count = 0; count < vertexes; count++) |
|
132 DrawLine(aPointList[count],aPointList[count + 1]); |
|
133 } |
|
134 |
|
135 /** Draws and fills a polygon defined using a list of points. |
|
136 |
|
137 The function provides a concrete implementation of the pure virtual |
|
138 function CGraphicsContext::DrawPolygon(). The function |
|
139 behaviour is the same as documented in that class. */ |
|
140 EXPORT_C TInt CFbsBitGc::DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule) |
|
141 { |
|
142 CheckDevice(); |
|
143 |
|
144 if (!aPointList) |
|
145 return KErrArgument; |
|
146 |
|
147 const TInt numpoints = aPointList->Count(); |
|
148 |
|
149 if (numpoints == 0) |
|
150 return KErrNone; // Nothing to do! |
|
151 |
|
152 SetupDevice(); |
|
153 iDevice->DrawingBegin(&iBrushBitmap); |
|
154 CFbsRasterizer* brushRasterizer = PrepareRasterizerForExtendedBitmap(iBrushBitmap); |
|
155 |
|
156 if (iBrushStyle != ENullBrush) |
|
157 { |
|
158 TRect pointrect(0,0,0,0); |
|
159 TRect truncrect(0,0,0,0); |
|
160 TBool largepolygon = EFalse; |
|
161 |
|
162 for (TInt count = 0; count < numpoints; count++) |
|
163 { |
|
164 pointrect.iTl = (*aPointList)[count] + iOrigin; |
|
165 truncrect.iTl = pointrect.iTl; |
|
166 iDevice->TruncateRect(truncrect); |
|
167 |
|
168 if (pointrect.iTl != truncrect.iTl) |
|
169 { |
|
170 largepolygon = ETrue; |
|
171 break; |
|
172 } |
|
173 } |
|
174 |
|
175 if (largepolygon) |
|
176 PolyFillLarge(aPointList,aFillRule); |
|
177 else |
|
178 PolyFill(aPointList,aFillRule); |
|
179 } |
|
180 |
|
181 if (iPenStyle != ENullPen) |
|
182 if (iPenSize.iWidth > 0 && iPenSize.iHeight > 0) |
|
183 PolyOutline(aPointList); |
|
184 |
|
185 if (brushRasterizer) |
|
186 { |
|
187 brushRasterizer->EndBitmap(iBrushBitmap.SerialNumber()); |
|
188 } |
|
189 iDevice->DrawingEnd(&iBrushBitmap); |
|
190 |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 |
|
195 /** Draws and fills a polygon defined using a list of points. |
|
196 |
|
197 The function provides a concrete implementation of the pure virtual |
|
198 function CGraphicsContext::DrawPolygon(). The function |
|
199 behaviour is the same as documented in that class. */ |
|
200 EXPORT_C TInt CFbsBitGc::DrawPolygon(const TPoint* aPointList, |
|
201 TInt aNumPoints, |
|
202 CGraphicsContext::TFillRule aFillRule) |
|
203 { |
|
204 CheckDevice(); |
|
205 |
|
206 if (!aPointList || aNumPoints < 0) |
|
207 return KErrArgument; |
|
208 |
|
209 if (aNumPoints == 0) |
|
210 return KErrNone; // Nothing to do! |
|
211 |
|
212 SetupDevice(); |
|
213 iDevice->DrawingBegin(&iBrushBitmap); |
|
214 CFbsRasterizer* brushRasterizer = PrepareRasterizerForExtendedBitmap(iBrushBitmap); |
|
215 |
|
216 if (iBrushStyle != ENullBrush) |
|
217 { |
|
218 TRect pointrect(0,0,0,0); |
|
219 TRect truncrect(0,0,0,0); |
|
220 TBool largepolygon = EFalse; |
|
221 |
|
222 for (TInt count = 0; count < aNumPoints; count++) |
|
223 { |
|
224 pointrect.iTl = aPointList[count] + iOrigin; |
|
225 truncrect.iTl = pointrect.iTl; |
|
226 iDevice->TruncateRect(truncrect); |
|
227 |
|
228 if (pointrect.iTl != truncrect.iTl) |
|
229 { |
|
230 largepolygon = ETrue; |
|
231 break; |
|
232 } |
|
233 } |
|
234 |
|
235 if (largepolygon) |
|
236 PolyFillLarge(aPointList,aNumPoints,aFillRule); |
|
237 else |
|
238 PolyFill(aPointList,aNumPoints,aFillRule); |
|
239 } |
|
240 |
|
241 if (iPenStyle != ENullPen && iPenSize.iWidth > 0 && iPenSize.iHeight > 0) |
|
242 PolyOutline(aPointList,aNumPoints); |
|
243 |
|
244 if (brushRasterizer) |
|
245 { |
|
246 brushRasterizer->EndBitmap(iBrushBitmap.SerialNumber()); |
|
247 } |
|
248 iDevice->DrawingEnd(&iBrushBitmap); |
|
249 |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 void CFbsBitGc::DoDrawLine(TPoint aPt1,TPoint aPt2,TBool aDrawStartPoint) |
|
254 { |
|
255 iLinePosition = aPt2; |
|
256 |
|
257 if (aPt1 == aPt2 || iPenStyle == ENullPen || !iPenSize.iWidth || !iPenSize.iHeight) |
|
258 return; |
|
259 |
|
260 aPt1 += iOrigin; |
|
261 aPt2 += iOrigin; |
|
262 |
|
263 TRect temp(aPt1,aPt2); |
|
264 temp.Normalize(); |
|
265 temp.Grow(iPenSize.iWidth,iPenSize.iHeight); |
|
266 AddRect(temp); |
|
267 if (UserClipRect(temp)) |
|
268 return; |
|
269 |
|
270 CFbsDrawDevice* drawDevice = iDevice->iDrawDevice; |
|
271 |
|
272 TRect screenRect; |
|
273 drawDevice->GetDrawRect(screenRect); |
|
274 screenRect.Grow(iPenSize.iWidth,iPenSize.iHeight); |
|
275 |
|
276 const TInt dotParam = iDotParam; |
|
277 TPoint plotpt(0,0); |
|
278 |
|
279 for (TInt count = 0; count < iDefaultRegionPtr->Count(); count++) |
|
280 { |
|
281 iDotParam = dotParam; |
|
282 iClipRect = (*iDefaultRegionPtr)[count]; |
|
283 |
|
284 if (!iClipRect.Intersects(temp)) |
|
285 { |
|
286 TLinearDDA line; |
|
287 line.Construct(aPt1,aPt2); |
|
288 line.JumpToRect(screenRect); |
|
289 if (iPenStyle != ESolidPen) |
|
290 while (!line.SingleStep(plotpt)) |
|
291 iDotParam += iDotDirection; |
|
292 continue; |
|
293 } |
|
294 |
|
295 iClipRect.Intersection(temp); |
|
296 |
|
297 if ((iPenSize.iWidth > 1 || iPenSize.iHeight > 1) && iPenStyle == ESolidPen) // wide solid line |
|
298 DoDrawSolidWideLine(aPt1,aPt2,aDrawStartPoint,screenRect); |
|
299 else if (iPenSize.iWidth > 1 || iPenSize.iHeight > 1) // dotted line |
|
300 DoDrawDottedWideLine(aPt1,aPt2,aDrawStartPoint,screenRect); |
|
301 else if (iPenStyle != ESolidPen) // single pixel dotted line |
|
302 { |
|
303 TLinearDDA line; |
|
304 line.Construct(aPt1,aPt2); |
|
305 line.JumpToRect(screenRect); |
|
306 |
|
307 iDotParam = dotParam; |
|
308 if (!aDrawStartPoint) |
|
309 { |
|
310 line.SingleStep(plotpt); |
|
311 iDotParam += iDotDirection; |
|
312 } |
|
313 |
|
314 while (!line.SingleStep(plotpt)) |
|
315 { |
|
316 PenDrawClipped(plotpt); |
|
317 iDotParam += iDotDirection; |
|
318 } |
|
319 } |
|
320 else if (aPt1.iY == aPt2.iY && |
|
321 (aPt1.iY >= iClipRect.iTl.iY && aPt1.iY < iClipRect.iBr.iY)) |
|
322 { // single pixel solid horizontal line |
|
323 TInt start = Min(aPt1.iX,aPt2.iX + 1); |
|
324 TInt length = Abs(aPt2.iX - aPt1.iX); |
|
325 |
|
326 if (!aDrawStartPoint) |
|
327 if (aPt1.iX < aPt2.iX) |
|
328 start++; |
|
329 else |
|
330 length--; |
|
331 if (start < iClipRect.iTl.iX) |
|
332 { |
|
333 length += start - iClipRect.iTl.iX; |
|
334 start = iClipRect.iTl.iX; |
|
335 } |
|
336 if (start + length > iClipRect.iBr.iX) |
|
337 length = iClipRect.iBr.iX - start; |
|
338 |
|
339 if (length > 0) |
|
340 { |
|
341 BG_ASSERT_DEBUG(start >= iUserClipRect.iTl.iX,EBitgdiPanicOutOfBounds); |
|
342 BG_ASSERT_DEBUG(aPt1.iY >= iUserClipRect.iTl.iY,EBitgdiPanicOutOfBounds); |
|
343 BG_ASSERT_DEBUG(start + length <= iUserClipRect.iBr.iX,EBitgdiPanicOutOfBounds); |
|
344 BG_ASSERT_DEBUG(aPt1.iY < iUserClipRect.iBr.iY,EBitgdiPanicOutOfBounds); |
|
345 |
|
346 drawDevice->WriteRgbMulti(start,aPt1.iY,length,1,iPenColor,iDrawMode); |
|
347 } |
|
348 } |
|
349 else if (aPt1.iX == aPt2.iX && (aPt1.iX >= iClipRect.iTl.iX && aPt1.iX < iClipRect.iBr.iX)) |
|
350 { // single pixel solid vertical line |
|
351 TInt start = Min(aPt1.iY,aPt2.iY + 1); |
|
352 TInt length = Abs(aPt2.iY - aPt1.iY); |
|
353 |
|
354 if (!aDrawStartPoint) |
|
355 if (aPt1.iY < aPt2.iY) |
|
356 start++; |
|
357 else |
|
358 length--; |
|
359 |
|
360 if (start < iClipRect.iTl.iY) |
|
361 { |
|
362 length += start - iClipRect.iTl.iY; |
|
363 start = iClipRect.iTl.iY; |
|
364 } |
|
365 if (start + length > iClipRect.iBr.iY) |
|
366 length = iClipRect.iBr.iY - start; |
|
367 |
|
368 if (length > 0) |
|
369 { |
|
370 BG_ASSERT_DEBUG(aPt1.iX >= iUserClipRect.iTl.iX,EBitgdiPanicOutOfBounds); |
|
371 BG_ASSERT_DEBUG(start >= iUserClipRect.iTl.iY,EBitgdiPanicOutOfBounds); |
|
372 BG_ASSERT_DEBUG(aPt1.iX < iUserClipRect.iBr.iX,EBitgdiPanicOutOfBounds); |
|
373 BG_ASSERT_DEBUG(start + length <= iUserClipRect.iBr.iY,EBitgdiPanicOutOfBounds); |
|
374 |
|
375 drawDevice->WriteRgbMulti(aPt1.iX,start,1,length,iPenColor,iDrawMode); |
|
376 } |
|
377 } |
|
378 else |
|
379 { // single pixel solid diagonal line |
|
380 TLinearDDA line; |
|
381 line.Construct(aPt1,aPt2); |
|
382 |
|
383 line.JumpToRect(screenRect); |
|
384 |
|
385 if (!aDrawStartPoint) |
|
386 line.SingleStep(plotpt); |
|
387 |
|
388 while (!line.SingleStep(plotpt)) |
|
389 { |
|
390 if (iClipRect.Contains(plotpt)) |
|
391 { |
|
392 BG_ASSERT_DEBUG(plotpt.iX >= iUserClipRect.iTl.iX,EBitgdiPanicOutOfBounds); |
|
393 BG_ASSERT_DEBUG(plotpt.iY >= iUserClipRect.iTl.iY,EBitgdiPanicOutOfBounds); |
|
394 BG_ASSERT_DEBUG(plotpt.iX < iUserClipRect.iBr.iX,EBitgdiPanicOutOfBounds); |
|
395 BG_ASSERT_DEBUG(plotpt.iY < iUserClipRect.iBr.iY,EBitgdiPanicOutOfBounds); |
|
396 |
|
397 drawDevice->WriteRgb(plotpt.iX,plotpt.iY,iPenColor,iDrawMode); |
|
398 } |
|
399 } |
|
400 } |
|
401 |
|
402 drawDevice->UpdateRegion(iClipRect); |
|
403 } |
|
404 } |
|
405 |
|
406 void CFbsBitGc::DoDrawSolidWideLine(const TPoint& aPt1, |
|
407 const TPoint& aPt2, |
|
408 TBool aDrawStartPoint, |
|
409 const TRect& aScreenRect) |
|
410 { |
|
411 CFbsDrawDevice* drawDevice = iDevice->iDrawDevice; |
|
412 |
|
413 TLinearDDA line; |
|
414 line.Construct(aPt1,aPt2); |
|
415 |
|
416 TPoint plotpt(aPt1); |
|
417 line.JumpToRect(aScreenRect); |
|
418 if (!aScreenRect.Contains(plotpt) || !aDrawStartPoint) |
|
419 line.SingleStep(plotpt); |
|
420 |
|
421 TInt* deferred = NULL; |
|
422 const TInt doubleheight = iPenSize.iHeight << 1; |
|
423 |
|
424 if (iFbsBitGcExtraData->PenArray()) |
|
425 deferred = new TInt[doubleheight]; |
|
426 |
|
427 if (!iFbsBitGcExtraData->PenArray() || !deferred) |
|
428 { |
|
429 while (!line.SingleStep(plotpt)) |
|
430 PenDrawClipped(plotpt); |
|
431 } |
|
432 else |
|
433 { |
|
434 const TBool down = (aPt2.iY >= aPt1.iY); |
|
435 |
|
436 for (TInt fillcount = 0; fillcount < doubleheight; ) |
|
437 { |
|
438 deferred[fillcount++] = KMaxTInt; |
|
439 deferred[fillcount++] = KMinTInt; |
|
440 } |
|
441 |
|
442 TInt nextline = 0; |
|
443 TInt nexty = plotpt.iY; |
|
444 if (down) |
|
445 nexty -= ((iPenSize.iHeight - 1) >> 1); |
|
446 else |
|
447 nexty += (iPenSize.iHeight >> 1); |
|
448 |
|
449 TInt lasty = plotpt.iY; |
|
450 |
|
451 while (!line.SingleStep(plotpt)) |
|
452 { |
|
453 if (plotpt.iY != lasty) |
|
454 { |
|
455 if (nexty >= iClipRect.iTl.iY && nexty < iClipRect.iBr.iY) |
|
456 { |
|
457 TInt left = deferred[nextline]; |
|
458 TInt right = deferred[nextline + 1]; |
|
459 if (left < iClipRect.iTl.iX) |
|
460 left = iClipRect.iTl.iX; |
|
461 if (right >= iClipRect.iBr.iX) |
|
462 right = iClipRect.iBr.iX - 1; |
|
463 |
|
464 if (left <= right) |
|
465 drawDevice->WriteRgbMulti(left,nexty,right - left + 1,1,iPenColor,CGraphicsContext::EDrawModePEN); |
|
466 } |
|
467 |
|
468 if (down) |
|
469 nexty++; |
|
470 else |
|
471 nexty--; |
|
472 lasty = plotpt.iY; |
|
473 deferred[nextline++] = KMaxTInt; |
|
474 deferred[nextline++] = KMinTInt; |
|
475 if (nextline == doubleheight) |
|
476 nextline = 0; |
|
477 } |
|
478 |
|
479 PenDrawDeferred(plotpt,deferred,nextline); |
|
480 } |
|
481 |
|
482 for (TInt restofline = 0; restofline < doubleheight; restofline += 2,nextline += 2) |
|
483 { |
|
484 if (nextline == doubleheight) |
|
485 nextline = 0; |
|
486 |
|
487 if (nexty >= iClipRect.iTl.iY && nexty < iClipRect.iBr.iY) |
|
488 { |
|
489 TInt left = deferred[nextline]; |
|
490 TInt right = deferred[nextline+1]; |
|
491 if (left < iClipRect.iTl.iX) |
|
492 left = iClipRect.iTl.iX; |
|
493 if (right >= iClipRect.iBr.iX) |
|
494 right = iClipRect.iBr.iX-1; |
|
495 |
|
496 if (left <= right) |
|
497 drawDevice->WriteRgbMulti(left,nexty,right - left + 1,1,iPenColor,CGraphicsContext::EDrawModePEN); |
|
498 } |
|
499 |
|
500 if (down) |
|
501 nexty++; |
|
502 else |
|
503 nexty--; |
|
504 } |
|
505 |
|
506 delete[] deferred; |
|
507 } |
|
508 } |
|
509 |
|
510 |
|
511 void CFbsBitGc::DoDrawDottedWideLine(const TPoint& aPt1, |
|
512 const TPoint& aPt2, |
|
513 TBool aDrawStartPoint, |
|
514 const TRect& aScreenRect) |
|
515 { |
|
516 TLinearDDA line; |
|
517 line.Construct(aPt1,aPt2); |
|
518 |
|
519 TPoint plotpt(aPt1); |
|
520 line.JumpToRect(aScreenRect); |
|
521 if (!aDrawStartPoint) |
|
522 { |
|
523 line.SingleStep(plotpt); |
|
524 iDotParam += iDotDirection; |
|
525 } |
|
526 |
|
527 const TInt maxdim = Max(iPenSize.iWidth,iPenSize.iHeight); |
|
528 |
|
529 TBool done = EFalse; |
|
530 while (!done) |
|
531 { |
|
532 while (!done && !(iDotMask & (1 << ((iDotParam / maxdim) % iDotLength)))) |
|
533 { |
|
534 done = line.SingleStep(plotpt); |
|
535 iDotParam += iDotDirection; |
|
536 } |
|
537 |
|
538 TPoint startdash(plotpt); |
|
539 TPoint enddash(plotpt); |
|
540 |
|
541 while (!done && (iDotMask & (1 << ((iDotParam / maxdim) % iDotLength)))) |
|
542 { |
|
543 enddash = plotpt; |
|
544 done = line.SingleStep(plotpt); |
|
545 iDotParam += iDotDirection; |
|
546 } |
|
547 |
|
548 DoDrawSolidWideLine(startdash,enddash,ETrue,aScreenRect); |
|
549 } |
|
550 } |
|
551 |
|
552 // if iBrushBitmap is an extended bitmap, PrepareRasterizerForExtendedBitmap() must have been called before this method |
|
553 void CFbsBitGc::PolyFill(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule) |
|
554 { |
|
555 TBool exists; |
|
556 TInt scanline; |
|
557 TInt pixelRunStart; |
|
558 TInt pixelRunEnd; |
|
559 |
|
560 const TInt limit = iDefaultRegionPtr->Count(); |
|
561 for (TInt count = 0; count < limit; count++) |
|
562 { |
|
563 iClipRect = (*iDefaultRegionPtr)[count]; |
|
564 AddRect(iClipRect); |
|
565 if (UserClipRect(iClipRect)) |
|
566 continue; |
|
567 |
|
568 CPolygonFiller polyfill; |
|
569 polyfill.Construct(aPointList,aFillRule); |
|
570 |
|
571 for(polyfill.GetNextPixelRun(exists,scanline,pixelRunStart,pixelRunEnd);exists; |
|
572 polyfill.GetNextPixelRun(exists,scanline,pixelRunStart,pixelRunEnd)) |
|
573 { |
|
574 TPoint start(pixelRunStart,scanline),end(pixelRunEnd,scanline); |
|
575 start += iOrigin; |
|
576 end += iOrigin; |
|
577 ClipFillLine(start,end); |
|
578 } |
|
579 |
|
580 polyfill.Reset(); |
|
581 iDevice->iDrawDevice->UpdateRegion(iClipRect); |
|
582 } |
|
583 } |
|
584 |
|
585 // if iBrushBitmap is an extended bitmap, PrepareRasterizerForExtendedBitmap() must have been called before this method |
|
586 void CFbsBitGc::PolyFillLarge(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule) |
|
587 { |
|
588 TBool exists; |
|
589 TInt pixelRunStart; |
|
590 TInt pixelRunEnd; |
|
591 |
|
592 const TInt limit = iDefaultRegionPtr->Count(); |
|
593 for (TInt count = 0; count < limit; count++) |
|
594 { |
|
595 iClipRect = (*iDefaultRegionPtr)[count]; |
|
596 AddRect(iClipRect); |
|
597 if (UserClipRect(iClipRect)) |
|
598 continue; |
|
599 |
|
600 CPolygonFiller polyfill; |
|
601 polyfill.Construct(aPointList,aFillRule,CPolygonFiller::EGetPixelRunsSequentiallyForSpecifiedScanLines); |
|
602 TInt clipRectOffsetStart = iClipRect.iTl.iY - iOrigin.iY; |
|
603 TInt clipRectOffsetEnd = iClipRect.iBr.iY - iOrigin.iY; |
|
604 |
|
605 for (TInt scanline = clipRectOffsetStart; scanline < clipRectOffsetEnd; scanline++) |
|
606 { |
|
607 polyfill.GetNextPixelRunOnSpecifiedScanLine(exists,scanline,pixelRunStart,pixelRunEnd); |
|
608 while (exists) |
|
609 { |
|
610 TPoint start(pixelRunStart,scanline),end(pixelRunEnd,scanline); |
|
611 start += iOrigin; |
|
612 end += iOrigin; |
|
613 ClipFillLine(start,end); |
|
614 polyfill.GetNextPixelRunOnSpecifiedScanLine(exists,scanline,pixelRunStart,pixelRunEnd); |
|
615 } |
|
616 } |
|
617 |
|
618 polyfill.Reset(); |
|
619 iDevice->iDrawDevice->UpdateRegion(iClipRect); |
|
620 } |
|
621 } |
|
622 |
|
623 void CFbsBitGc::PolyOutline(const CArrayFix<TPoint>* aPointList) |
|
624 { |
|
625 const TInt vertexes = aPointList->Count(); |
|
626 |
|
627 for (TInt count = 0; count < vertexes; count++) |
|
628 { |
|
629 TPoint point1((*aPointList)[count]); |
|
630 TPoint point2((*aPointList)[(count + 1) % vertexes]); |
|
631 |
|
632 if (point1.iY < point2.iY) |
|
633 DoDrawLine(point1,point2,ETrue); |
|
634 else |
|
635 { |
|
636 iDotDirection = -1; |
|
637 iDotParam += Max(Abs(point2.iX - point1.iX),Abs(point2.iY - point1.iY)); |
|
638 const TInt dotParam = iDotParam; |
|
639 DoDrawLine(point2,point1,EFalse); |
|
640 |
|
641 if (Abs(point2.iX - point1.iX) > Abs(point2.iY - point1.iY)) |
|
642 { |
|
643 if (iPenStyle == CGraphicsContext::ESolidPen || (iDotMask & (1 << ((iDotParam / iPenSize.iWidth) % iDotLength)))) |
|
644 DoPlot((*aPointList)[count]); |
|
645 } |
|
646 else |
|
647 { |
|
648 if (iPenStyle == CGraphicsContext::ESolidPen || (iDotMask & (1 << ((iDotParam / iPenSize.iHeight) % iDotLength)))) |
|
649 DoPlot((*aPointList)[count]); |
|
650 } |
|
651 |
|
652 iDotDirection = 1; |
|
653 iDotParam = dotParam; |
|
654 } |
|
655 } |
|
656 } |
|
657 |
|
658 // if iBrushBitmap is an extended bitmap, PrepareRasterizerForExtendedBitmap() must have been called before this method |
|
659 void CFbsBitGc::PolyFill(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule) |
|
660 { |
|
661 TBool exists; |
|
662 TInt scanline; |
|
663 TInt pixelRunStart; |
|
664 TInt pixelRunEnd; |
|
665 |
|
666 const TInt limit = iDefaultRegionPtr->Count(); |
|
667 for (TInt count = 0; count < limit; count++) |
|
668 { |
|
669 iClipRect = (*iDefaultRegionPtr)[count]; |
|
670 AddRect(iClipRect); |
|
671 if (UserClipRect(iClipRect)) |
|
672 continue; |
|
673 |
|
674 CPolygonFiller polyfill; |
|
675 polyfill.Construct(aPointList,aNumPoints,aFillRule); |
|
676 |
|
677 for (polyfill.GetNextPixelRun(exists,scanline,pixelRunStart,pixelRunEnd);exists; |
|
678 polyfill.GetNextPixelRun(exists,scanline,pixelRunStart,pixelRunEnd)) |
|
679 { |
|
680 TPoint start(pixelRunStart,scanline),end(pixelRunEnd,scanline); |
|
681 start += iOrigin; |
|
682 end += iOrigin; |
|
683 ClipFillLine(start,end); |
|
684 } |
|
685 |
|
686 polyfill.Reset(); |
|
687 iDevice->iDrawDevice->UpdateRegion(iClipRect); |
|
688 } |
|
689 } |
|
690 |
|
691 // if iBrushBitmap is an extended bitmap, PrepareRasterizerForExtendedBitmap() must have been called before this method |
|
692 void CFbsBitGc::PolyFillLarge(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule) |
|
693 { |
|
694 TBool exists; |
|
695 TInt pixelRunStart; |
|
696 TInt pixelRunEnd; |
|
697 |
|
698 const TInt limit = iDefaultRegionPtr->Count(); |
|
699 for (TInt count = 0; count < limit; count++) |
|
700 { |
|
701 iClipRect = (*iDefaultRegionPtr)[count]; |
|
702 AddRect(iClipRect); |
|
703 if (UserClipRect(iClipRect)) |
|
704 continue; |
|
705 |
|
706 CPolygonFiller polyfill; |
|
707 polyfill.Construct(aPointList,aNumPoints,aFillRule,CPolygonFiller::EGetPixelRunsSequentiallyForSpecifiedScanLines); |
|
708 TInt clipRectOffsetStart = iClipRect.iTl.iY - iOrigin.iY; |
|
709 TInt clipRectOffsetEnd = iClipRect.iBr.iY - iOrigin.iY; |
|
710 |
|
711 for (TInt scanline = clipRectOffsetStart; scanline < clipRectOffsetEnd; scanline++) |
|
712 { |
|
713 polyfill.GetNextPixelRunOnSpecifiedScanLine(exists,scanline,pixelRunStart,pixelRunEnd); |
|
714 while (exists) |
|
715 { |
|
716 TPoint start(pixelRunStart,scanline),end(pixelRunEnd,scanline); |
|
717 start += iOrigin; |
|
718 end += iOrigin; |
|
719 ClipFillLine(start,end); |
|
720 |
|
721 polyfill.GetNextPixelRunOnSpecifiedScanLine(exists,scanline,pixelRunStart,pixelRunEnd); |
|
722 } |
|
723 } |
|
724 |
|
725 polyfill.Reset(); |
|
726 iDevice->iDrawDevice->UpdateRegion(iClipRect); |
|
727 } |
|
728 } |
|
729 |
|
730 void CFbsBitGc::PolyOutline(const TPoint* aPointList,TInt aNumPoints) |
|
731 { |
|
732 for (TInt count = 0; count < aNumPoints; count++) |
|
733 { |
|
734 TPoint point1(aPointList[count]); |
|
735 TPoint point2(aPointList[(count + 1) % aNumPoints]); |
|
736 |
|
737 if (point1.iY < point2.iY) |
|
738 DoDrawLine(point1,point2,ETrue); |
|
739 else |
|
740 { |
|
741 iDotDirection = -1; |
|
742 iDotParam += Max(Abs(point2.iX - point1.iX),Abs(point2.iY - point1.iY)); |
|
743 const TInt dotParam = iDotParam; |
|
744 |
|
745 DoDrawLine(point2,point1,EFalse); |
|
746 |
|
747 if (Abs(point2.iX - point1.iX) > Abs(point2.iY - point1.iY)) |
|
748 { |
|
749 if (iPenStyle == CGraphicsContext::ESolidPen || (iDotMask & (1 << ((iDotParam / iPenSize.iWidth) % iDotLength)))) |
|
750 DoPlot(aPointList[count]); |
|
751 } |
|
752 else |
|
753 { |
|
754 if (iPenStyle == CGraphicsContext::ESolidPen || (iDotMask & (1 << ((iDotParam / iPenSize.iHeight) % iDotLength)))) |
|
755 DoPlot(aPointList[count]); |
|
756 } |
|
757 |
|
758 iDotDirection = 1; |
|
759 iDotParam = dotParam; |
|
760 } |
|
761 } |
|
762 } |
|
763 |