|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <graphicsaccelerator.h> |
|
20 #include <j2me/jdebug.h> |
|
21 |
|
22 #include "lcd32bpp.h" |
|
23 #include "lcdgdrvutil.h" |
|
24 #include "lcdtransform.h" |
|
25 #include "lcdbitblt.h" |
|
26 |
|
27 LOCAL_C void FillTriangle32Bpp32 |
|
28 ( |
|
29 const TAcceleratedBitmapInfo* aBitmap, |
|
30 const TPoint aPoints[], |
|
31 TUint32 aColor32Bpp, |
|
32 const TRect& aClipRect |
|
33 ) |
|
34 { |
|
35 TRect clipRect(aBitmap->iSize); |
|
36 clipRect.Intersection(aClipRect); |
|
37 const TInt clipX1 = clipRect.iTl.iX; |
|
38 const TInt clipY1 = clipRect.iTl.iY; |
|
39 const TInt clipX2 = clipRect.iBr.iX; |
|
40 const TInt clipY2 = clipRect.iBr.iY; |
|
41 |
|
42 TInt i; |
|
43 |
|
44 TInt ymin=0; |
|
45 TInt ymax=0; |
|
46 TInt xmin=0; |
|
47 TInt xmax=0; |
|
48 |
|
49 for (i=1; i<3; i++) |
|
50 { |
|
51 if (aPoints[i].iX < aPoints[xmin].iX) xmin = i; |
|
52 if (aPoints[i].iX > aPoints[xmax].iX) xmax = i; |
|
53 if (aPoints[i].iY < aPoints[ymin].iY) ymin = i; |
|
54 if (aPoints[i].iY > aPoints[ymax].iY) ymax = i; |
|
55 } |
|
56 const TInt ymid = 3 - (ymax + ymin); |
|
57 |
|
58 |
|
59 TEdge edges[3]; |
|
60 |
|
61 // |
|
62 // Long edge top to bottom. |
|
63 // |
|
64 edges[0].iDy = aPoints[ymax].iY - aPoints[ymin].iY; |
|
65 if (edges[0].iDy == 0) |
|
66 { |
|
67 return; |
|
68 } |
|
69 edges[0].iDx = aPoints[ymax].iX - aPoints[ymin].iX; |
|
70 edges[0].iX = aPoints[ymin].iX; |
|
71 edges[0].iF = 0; |
|
72 edges[0].iD = edges[0].iDy; |
|
73 edges[0].iDe = Sign(edges[0].iDx); |
|
74 Increment(edges[0].iIx, edges[0].iIf, edges[0].iDx, edges[0].iDy); |
|
75 ASSERT(edges[0].iDy >= 0); |
|
76 |
|
77 // |
|
78 // Short top edge, or flat top |
|
79 // |
|
80 edges[1].iDx = aPoints[ymid].iX - aPoints[ymin].iX; |
|
81 edges[1].iDy = aPoints[ymid].iY - aPoints[ymin].iY; |
|
82 edges[1].iX = aPoints[ymin].iX; |
|
83 edges[1].iF = 0; |
|
84 edges[1].iD = edges[1].iDy; |
|
85 edges[1].iDe = Sign(edges[1].iDx); |
|
86 ASSERT(edges[1].iDy >= 0); |
|
87 |
|
88 // |
|
89 // Short bottom edge or flat bottom |
|
90 // |
|
91 edges[2].iDx = aPoints[ymax].iX - aPoints[ymid].iX; |
|
92 edges[2].iDy = aPoints[ymax].iY - aPoints[ymid].iY; |
|
93 edges[2].iX = aPoints[ymid].iX; |
|
94 edges[2].iF = 0; |
|
95 edges[2].iD = edges[2].iDy; |
|
96 edges[2].iDe = Sign(edges[2].iDx); |
|
97 ASSERT(edges[2].iDy >= 0); |
|
98 |
|
99 const TBool flatTop = (edges[1].iDy == 0); |
|
100 const TBool flatBottom = (edges[2].iDy == 0); |
|
101 |
|
102 // |
|
103 // work out whether long edge is left most or right most. |
|
104 // |
|
105 // compare slopes of long edge and top edge. |
|
106 // |
|
107 TBool longEdgeRight; |
|
108 if (flatTop) |
|
109 { |
|
110 longEdgeRight = (aPoints[ymid].iX < aPoints[ymin].iX); |
|
111 } |
|
112 else |
|
113 { |
|
114 longEdgeRight = (edges[0].iDx*edges[1].iDy) > (edges[1].iDx*edges[0].iDy); |
|
115 } |
|
116 |
|
117 TInt y = aPoints[ymin].iY; |
|
118 TInt yEnd = Min(aPoints[ymid].iY, clipY2); |
|
119 TEdge* el = NULL; |
|
120 TEdge* er = NULL; |
|
121 TInt m; // number of lines to skip |
|
122 TInt x1; // start of clipped scan (inclusive) |
|
123 TInt x2; // end of clipped scan (exclusive), exclusive overrides inclusive |
|
124 |
|
125 TInt eliX; // Locals used to speed access to edge information in loops. |
|
126 TInt eliF; |
|
127 TInt eliD; |
|
128 TInt eriX; |
|
129 TInt eriF; |
|
130 TInt eriD; |
|
131 |
|
132 TUint8* base = aBitmap->iAddress; |
|
133 TUint8* line = NULL; |
|
134 TInt linePitch = aBitmap->iLinePitch; |
|
135 TUint32* dst; |
|
136 TUint32* end; |
|
137 TUint32 color32 = (TUint32)aColor32Bpp; |
|
138 |
|
139 // |
|
140 // render top half. |
|
141 // |
|
142 if (!flatTop) |
|
143 { |
|
144 Increment(edges[1].iIx, edges[1].iIf, edges[1].iDx, edges[1].iDy); |
|
145 if (longEdgeRight) |
|
146 { |
|
147 er = &edges[0]; |
|
148 el = &edges[1]; |
|
149 } |
|
150 else |
|
151 { |
|
152 er = &edges[1]; |
|
153 el = &edges[0]; |
|
154 } |
|
155 eliX = el->iX; |
|
156 eliF = el->iF; |
|
157 eliD = el->iD; |
|
158 eriX = er->iX; |
|
159 eriF = er->iF; |
|
160 eriD = er->iD; |
|
161 |
|
162 // |
|
163 // Clip to top of clip rect. |
|
164 // |
|
165 if (y < clipY1) |
|
166 { |
|
167 TInt yTop = Min(clipY1, yEnd); |
|
168 |
|
169 m = (yTop - y); |
|
170 |
|
171 eliX += m*el->iIx; |
|
172 eliF += m*el->iIf; |
|
173 while (eliF > 0) |
|
174 { |
|
175 eliX ++; |
|
176 eliF -= eliD; |
|
177 } |
|
178 |
|
179 eriX += m*er->iIx; |
|
180 eriF += m*er->iIf; |
|
181 while (eriF > 0) |
|
182 { |
|
183 eriX ++; |
|
184 eriF -= eriD; |
|
185 } |
|
186 |
|
187 y = yTop; |
|
188 } |
|
189 |
|
190 ASSERT(((1 - eriD) <= eriF) && (eriF <= 0)); |
|
191 ASSERT(((1 - eliD) <= eliF) && (eliF <= 0)); |
|
192 |
|
193 #ifdef PLOT_TOP_VERTEX |
|
194 // special case top vertex - can produce pimple so prob best avoided. |
|
195 if (aClipRect.Contains(aPoints[ymin])) |
|
196 { |
|
197 line = base + aPoints[ymin].iY*linePitch; |
|
198 ((TUint32*)line)[aPoints[ymin].iX] = color32; |
|
199 } |
|
200 #endif |
|
201 |
|
202 line = base + y*linePitch; |
|
203 for (; y<yEnd; y++) |
|
204 { |
|
205 ASSERT(eliX <= eriX); |
|
206 if ((eliX < clipX2) && (eriX > clipX1)) |
|
207 { |
|
208 x1 = Max(eliX, clipX1); // inclusive (ceil) |
|
209 x2 = Min(eriX, clipX2); // exclusive (floor) |
|
210 |
|
211 dst = (TUint32*)(line + x1*sizeof(TUint32)); |
|
212 end = (TUint32*)(line + x2*sizeof(TUint32)); |
|
213 while (dst < end) |
|
214 { |
|
215 *dst++ = color32; |
|
216 } |
|
217 } |
|
218 |
|
219 eliX += el->iIx; |
|
220 eliF += el->iIf; |
|
221 if (eliF > 0) |
|
222 { |
|
223 eliX ++; |
|
224 eliF -= eliD; |
|
225 } |
|
226 |
|
227 eriX += er->iIx; |
|
228 eriF += er->iIf; |
|
229 if (eriF > 0) |
|
230 { |
|
231 eriX ++; |
|
232 eriF -= eriD; |
|
233 } |
|
234 |
|
235 line += linePitch; |
|
236 } |
|
237 |
|
238 el->iX = eliX; |
|
239 el->iF = eliF; |
|
240 el->iD = eliD; |
|
241 er->iX = eriX; |
|
242 er->iF = eriF; |
|
243 er->iD = eriD; |
|
244 } |
|
245 |
|
246 if (!flatBottom) |
|
247 { |
|
248 Increment(edges[2].iIx, edges[2].iIf, edges[2].iDx, edges[2].iDy); |
|
249 if (longEdgeRight) |
|
250 { |
|
251 // initialize short left edge |
|
252 er = &edges[0]; |
|
253 el = &edges[2]; |
|
254 } |
|
255 else |
|
256 { |
|
257 // initialize short right edge |
|
258 er = &edges[2]; |
|
259 el = &edges[0]; |
|
260 } |
|
261 eliX = el->iX; |
|
262 eliF = el->iF; |
|
263 eliD = el->iD; |
|
264 eriX = er->iX; |
|
265 eriF = er->iF; |
|
266 eriD = er->iD; |
|
267 |
|
268 // |
|
269 // clip to top edge of clip rect. |
|
270 // |
|
271 // |
|
272 // Clip to top of clip rect. |
|
273 // |
|
274 if (y < clipY1) |
|
275 { |
|
276 m = (clipY1 - y); |
|
277 |
|
278 eliX += m*el->iIx; |
|
279 eliF += m*el->iIf; |
|
280 while (eliF > 0) |
|
281 { |
|
282 eliX ++; |
|
283 eliF -= eliD; |
|
284 } |
|
285 |
|
286 eriX += m*er->iIx; |
|
287 eriF += m*er->iIf; |
|
288 while (eriF > 0) |
|
289 { |
|
290 eriX ++; |
|
291 eriF -= eriD; |
|
292 } |
|
293 y = clipY1; |
|
294 } |
|
295 |
|
296 line = base + y*linePitch; |
|
297 yEnd = Min(aPoints[ymax].iY, clipY2); |
|
298 for (; y<yEnd; y++) // ignore last line - as pixel will be on bottom edge. |
|
299 { |
|
300 ASSERT(eliX <= eriX); |
|
301 if ((eliX < clipX2) && (eriX > clipX1)) |
|
302 { |
|
303 x1 = Max(eliX, clipX1); // inclusive (ceil) |
|
304 x2 = Min(eriX, clipX2); // exclusive (floor) |
|
305 |
|
306 dst = (TUint32*)(line + x1*sizeof(TUint32)); |
|
307 end = (TUint32*)(line + x2*sizeof(TUint32)); |
|
308 while (dst < end) |
|
309 { |
|
310 *dst++ = color32; |
|
311 } |
|
312 } |
|
313 |
|
314 eliX += el->iIx; |
|
315 eliF += el->iIf; |
|
316 if (eliF > 0) |
|
317 { |
|
318 eliX ++; |
|
319 eliF -= eliD; |
|
320 } |
|
321 |
|
322 eriX += er->iIx; |
|
323 eriF += er->iIf; |
|
324 if (eriF > 0) |
|
325 { |
|
326 eriX ++; |
|
327 eriF -= eriD; |
|
328 } |
|
329 |
|
330 line += linePitch; |
|
331 } |
|
332 |
|
333 el->iX = eliX; |
|
334 el->iF = eliF; |
|
335 el->iD = eliD; |
|
336 er->iX = eriX; |
|
337 er->iF = eriF; |
|
338 er->iD = eriD; |
|
339 } |
|
340 } |
|
341 |
|
342 LOCAL_C void FillTriangle32Bpp64 |
|
343 ( |
|
344 const TAcceleratedBitmapInfo* aBitmap, |
|
345 const TPoint aPoints[], |
|
346 TUint32 aColor32Bpp, |
|
347 const TRect& aClipRect |
|
348 ) |
|
349 { |
|
350 TRect clipRect(aBitmap->iSize); |
|
351 clipRect.Intersection(aClipRect); |
|
352 const TInt64 clipX1 = (TInt64)(clipRect.iTl.iX); |
|
353 const TInt64 clipY1 = (TInt64)(clipRect.iTl.iY); |
|
354 const TInt64 clipX2 = (TInt64)(clipRect.iBr.iX); |
|
355 const TInt64 clipY2 = (TInt64)(clipRect.iBr.iY); |
|
356 |
|
357 TInt i; |
|
358 |
|
359 TInt ymin=0; |
|
360 TInt ymax=0; |
|
361 TInt xmin=0; |
|
362 TInt xmax=0; |
|
363 |
|
364 for (i=1; i<3; i++) |
|
365 { |
|
366 if (aPoints[i].iX < aPoints[xmin].iX) xmin = i; |
|
367 if (aPoints[i].iX > aPoints[xmax].iX) xmax = i; |
|
368 if (aPoints[i].iY < aPoints[ymin].iY) ymin = i; |
|
369 if (aPoints[i].iY > aPoints[ymax].iY) ymax = i; |
|
370 } |
|
371 const TInt ymid = 3 - (ymax + ymin); |
|
372 |
|
373 // const TInt64 minX = aPoints[xmin].iX; |
|
374 // const TInt64 maxX = aPoints[xmax].iX; |
|
375 |
|
376 TEdge64 edges[3]; |
|
377 |
|
378 // |
|
379 // Long edge top to bottom. |
|
380 // |
|
381 edges[0].iDy = (TInt64)(aPoints[ymax].iY) - (TInt64)(aPoints[ymin].iY); |
|
382 if (edges[0].iDy == 0) |
|
383 { |
|
384 return; |
|
385 } |
|
386 edges[0].iDx = (TInt64)(aPoints[ymax].iX) - (TInt64)(aPoints[ymin].iX); |
|
387 edges[0].iX = (TInt64)(aPoints[ymin].iX); |
|
388 edges[0].iF = 0; |
|
389 edges[0].iD = edges[0].iDy; |
|
390 edges[0].iDe = Sign(edges[0].iDx); |
|
391 Increment(edges[0].iIx, edges[0].iIf, edges[0].iDx, edges[0].iDy); |
|
392 ASSERT(edges[0].iDy >= 0); |
|
393 |
|
394 // |
|
395 // Short top edge, or flat top |
|
396 // |
|
397 edges[1].iDx = (TInt64)(aPoints[ymid].iX) - (TInt64)(aPoints[ymin].iX); |
|
398 edges[1].iDy = (TInt64)(aPoints[ymid].iY) - (TInt64)(aPoints[ymin].iY); |
|
399 edges[1].iX = (TInt64)(aPoints[ymin].iX); |
|
400 edges[1].iF = 0; |
|
401 edges[1].iD = edges[1].iDy; |
|
402 edges[1].iDe = Sign(edges[1].iDx); |
|
403 ASSERT(edges[1].iDy >= 0); |
|
404 |
|
405 // |
|
406 // Short bottom edge or flat bottom |
|
407 // |
|
408 edges[2].iDx = (TInt64)(aPoints[ymax].iX) - (TInt64)(aPoints[ymid].iX); |
|
409 edges[2].iDy = (TInt64)(aPoints[ymax].iY) - (TInt64)(aPoints[ymid].iY); |
|
410 edges[2].iX = (TInt64)(aPoints[ymid].iX); |
|
411 edges[2].iF = 0; |
|
412 edges[2].iD = edges[2].iDy; |
|
413 edges[2].iDe = Sign(edges[2].iDx); |
|
414 ASSERT(edges[2].iDy >= 0); |
|
415 |
|
416 const TBool flatTop = (edges[1].iDy == 0); |
|
417 const TBool flatBottom = (edges[2].iDy == 0); |
|
418 |
|
419 // |
|
420 // work out whether long edge is left most or right most. |
|
421 // |
|
422 // compare slopes of long edge and top edge. |
|
423 // |
|
424 TBool longEdgeRight; |
|
425 if (flatTop) |
|
426 { |
|
427 longEdgeRight = (aPoints[ymid].iX < aPoints[ymin].iX); |
|
428 } |
|
429 else |
|
430 { |
|
431 longEdgeRight = (edges[0].iDx*edges[1].iDy) > (edges[1].iDx*edges[0].iDy); |
|
432 } |
|
433 |
|
434 TInt64 y = (TInt64)aPoints[ymin].iY; |
|
435 TInt64 yEnd = Min(aPoints[ymid].iY, clipY2); |
|
436 TEdge64* el = NULL; |
|
437 TEdge64* er = NULL; |
|
438 TInt64 m; // number of lines to skip |
|
439 TInt64 x1; // start of clipped scan (inclusive) |
|
440 TInt64 x2; // end of clipped scan (exclusive), exclusive overrides inclusive |
|
441 |
|
442 TInt64 eliX; // Locals used to speed access to edge information in loops. |
|
443 TInt64 eliF; |
|
444 TInt64 eliD; |
|
445 TInt64 eriX; |
|
446 TInt64 eriF; |
|
447 TInt64 eriD; |
|
448 |
|
449 TUint8* base = aBitmap->iAddress; |
|
450 TUint8* line = NULL; |
|
451 TInt linePitch = aBitmap->iLinePitch; |
|
452 TUint32* dst; |
|
453 TUint32* end; |
|
454 TUint32 color32 = (TUint32)aColor32Bpp; |
|
455 |
|
456 // |
|
457 // render top half. |
|
458 // |
|
459 if (!flatTop) |
|
460 { |
|
461 Increment(edges[1].iIx, edges[1].iIf, edges[1].iDx, edges[1].iDy); |
|
462 if (longEdgeRight) |
|
463 { |
|
464 er = &edges[0]; |
|
465 el = &edges[1]; |
|
466 } |
|
467 else |
|
468 { |
|
469 er = &edges[1]; |
|
470 el = &edges[0]; |
|
471 } |
|
472 eliX = el->iX; |
|
473 eliF = el->iF; |
|
474 eliD = el->iD; |
|
475 eriX = er->iX; |
|
476 eriF = er->iF; |
|
477 eriD = er->iD; |
|
478 |
|
479 // |
|
480 // Clip to top of clip rect. |
|
481 // |
|
482 if (y < clipY1) |
|
483 { |
|
484 TInt64 yTop = Min(clipY1, yEnd); |
|
485 |
|
486 m = (yTop - y); |
|
487 |
|
488 double leftSlope = (double)(el->iDx)/(double)(el->iDy); |
|
489 |
|
490 eliX += (leftSlope * ((double)m)); |
|
491 |
|
492 double rightSlope = (double)(er->iDx)/(double)(er->iDy); |
|
493 |
|
494 eriX += (rightSlope * ((double)m)); |
|
495 y = yTop; |
|
496 } |
|
497 |
|
498 ASSERT(((1 - eriD) <= eriF) && (eriF <= 0)); |
|
499 ASSERT(((1 - eliD) <= eliF) && (eliF <= 0)); |
|
500 |
|
501 #ifdef PLOT_TOP_VERTEX |
|
502 // special case top vertex - can produce pimple so prob best avoided. |
|
503 if (aClipRect.Contains(aPoints[ymin])) |
|
504 { |
|
505 line = base + aPoints[ymin].iY*linePitch; |
|
506 ((TUint32*)line)[aPoints[ymin].iX] = color32; |
|
507 } |
|
508 #endif |
|
509 |
|
510 line = base + y*linePitch; |
|
511 for (; y<yEnd; y++) |
|
512 { |
|
513 ASSERT(eliX <= eriX); |
|
514 if ((eliX < clipX2) && (eriX > clipX1)) |
|
515 { |
|
516 x1 = Max(eliX, clipX1); // inclusive (ceil) |
|
517 x2 = Min(eriX, clipX2); // exclusive (floor) |
|
518 |
|
519 dst = (TUint32*)(line + x1*sizeof(TUint32)); |
|
520 end = (TUint32*)(line + x2*sizeof(TUint32)); |
|
521 while (dst < end) |
|
522 { |
|
523 *dst++ = color32; |
|
524 } |
|
525 } |
|
526 eliX += el->iIx; |
|
527 eliF += el->iIf; |
|
528 if (eliF > 0) |
|
529 { |
|
530 eliX ++; |
|
531 eliF -= eliD; |
|
532 } |
|
533 |
|
534 eriX += er->iIx; |
|
535 eriF += er->iIf; |
|
536 if (eriF > 0) |
|
537 { |
|
538 eriX ++; |
|
539 eriF -= eriD; |
|
540 } |
|
541 |
|
542 line += linePitch; |
|
543 } |
|
544 |
|
545 el->iX = eliX; |
|
546 el->iF = eliF; |
|
547 el->iD = eliD; |
|
548 er->iX = eriX; |
|
549 er->iF = eriF; |
|
550 er->iD = eriD; |
|
551 } |
|
552 |
|
553 if (!flatBottom) |
|
554 { |
|
555 Increment(edges[2].iIx, edges[2].iIf, edges[2].iDx, edges[2].iDy); |
|
556 if (longEdgeRight) |
|
557 { |
|
558 // initialize short left edge |
|
559 er = &edges[0]; |
|
560 el = &edges[2]; |
|
561 } |
|
562 else |
|
563 { |
|
564 // initialize short right edge |
|
565 er = &edges[2]; |
|
566 el = &edges[0]; |
|
567 } |
|
568 eliX = el->iX; |
|
569 eliF = el->iF; |
|
570 eliD = el->iD; |
|
571 eriX = er->iX; |
|
572 eriF = er->iF; |
|
573 eriD = er->iD; |
|
574 |
|
575 // |
|
576 // clip to top edge of clip rect. |
|
577 // |
|
578 // |
|
579 // Clip to top of clip rect. |
|
580 // |
|
581 if (y < clipY1) |
|
582 { |
|
583 m = (clipY1 - y); |
|
584 |
|
585 double leftSlope = (double)(el->iDx)/(double)(el->iDy); |
|
586 |
|
587 eliX += (leftSlope * m); |
|
588 |
|
589 double rightSlope = (double)(er->iDx)/(double)(er->iDy); |
|
590 |
|
591 eriX += (rightSlope * m); |
|
592 |
|
593 y = clipY1; |
|
594 } |
|
595 |
|
596 line = base + y*linePitch; |
|
597 yEnd = Min(aPoints[ymax].iY, clipY2); |
|
598 for (; y<yEnd; y++) // ignore last line - as pixel will be on bottom edge. |
|
599 { |
|
600 ASSERT(eliX <= eriX); |
|
601 if ((eliX < clipX2) && (eriX > clipX1)) |
|
602 { |
|
603 x1 = Max(eliX, clipX1); // inclusive (ceil) |
|
604 x2 = Min(eriX, clipX2); // exclusive (floor) |
|
605 |
|
606 dst = (TUint32*)(line + x1*sizeof(TUint32)); |
|
607 end = (TUint32*)(line + x2*sizeof(TUint32)); |
|
608 while (dst < end) |
|
609 { |
|
610 *dst++ = color32; |
|
611 } |
|
612 } |
|
613 |
|
614 eliX += el->iIx; |
|
615 eliF += el->iIf; |
|
616 if (eliF > 0) |
|
617 { |
|
618 eliX ++; |
|
619 eliF -= eliD; |
|
620 } |
|
621 |
|
622 eriX += er->iIx; |
|
623 eriF += er->iIf; |
|
624 if (eriF > 0) |
|
625 { |
|
626 eriX ++; |
|
627 eriF -= eriD; |
|
628 } |
|
629 |
|
630 line += linePitch; |
|
631 } |
|
632 |
|
633 el->iX = eliX; |
|
634 el->iF = eliF; |
|
635 el->iD = eliD; |
|
636 er->iX = eriX; |
|
637 er->iF = eriF; |
|
638 er->iD = eriD; |
|
639 } |
|
640 } |
|
641 |
|
642 LOCAL_C TBool IsPathologicalTriangle(const TPoint aPoints[3]) |
|
643 { |
|
644 TInt minX = aPoints[0].iX; |
|
645 TInt maxX = aPoints[0].iX; |
|
646 TInt minY = aPoints[0].iY; |
|
647 TInt maxY = aPoints[0].iY; |
|
648 |
|
649 for (TInt i = 1; i <= 2; i++) |
|
650 { |
|
651 TInt x = aPoints[i].iX; |
|
652 TInt y = aPoints[i].iY; |
|
653 |
|
654 if (x < minX) |
|
655 { |
|
656 minX = x; |
|
657 } |
|
658 if (x > maxX) |
|
659 { |
|
660 maxX = x; |
|
661 } |
|
662 if (y < minY) |
|
663 { |
|
664 minY = y; |
|
665 } |
|
666 if (y > maxY) |
|
667 { |
|
668 maxY = y; |
|
669 } |
|
670 } |
|
671 if (minX < 0) |
|
672 { |
|
673 if (maxX >= (0x7FFFFFFF + minX)) |
|
674 { |
|
675 return ETrue; |
|
676 } |
|
677 if (-minX > 0xFFFFF) |
|
678 { |
|
679 return ETrue; |
|
680 } |
|
681 } |
|
682 if (maxX > 0) |
|
683 { |
|
684 if ((maxX == 0x7FFFFFFF) && (minX == 0)) |
|
685 { |
|
686 return ETrue; |
|
687 } |
|
688 if (maxX > 0xFFFFF) |
|
689 { |
|
690 return ETrue; |
|
691 } |
|
692 } |
|
693 if (minY < 0) |
|
694 { |
|
695 if (maxY >= (0x7FFFFFFF + minY)) |
|
696 { |
|
697 return ETrue; |
|
698 } |
|
699 if (-minY > 0xFFFFF) |
|
700 { |
|
701 return ETrue; |
|
702 } |
|
703 } |
|
704 if (minY > 0) |
|
705 { |
|
706 if ((maxY == 0x7FFFFFFF) && (minX == 0)) |
|
707 { |
|
708 return ETrue; |
|
709 } |
|
710 if (minY > 0xFFFFF) |
|
711 { |
|
712 return ETrue; |
|
713 } |
|
714 } |
|
715 return EFalse; |
|
716 } |
|
717 |
|
718 extern void FillTriangle32Bpp |
|
719 ( |
|
720 const TAcceleratedBitmapInfo* aBitmap, |
|
721 const TPoint aPoints[], |
|
722 TUint32 aColor32Bpp, |
|
723 const TRect& aClipRect |
|
724 ) |
|
725 { |
|
726 if (!IsPathologicalTriangle(aPoints)) |
|
727 { |
|
728 FillTriangle32Bpp32(aBitmap, aPoints, aColor32Bpp, aClipRect); |
|
729 } |
|
730 else |
|
731 { |
|
732 FillTriangle32Bpp64(aBitmap, aPoints, aColor32Bpp, aClipRect); |
|
733 } |
|
734 } |
|
735 |
|
736 LOCAL_C void BlitLineThirtyTwoBppSimple |
|
737 ( |
|
738 TUint8* aDstAddress, |
|
739 TInt aWidth, |
|
740 TUint8* aColorAddress, |
|
741 TInt DEBUG_ONLY(aColorPixelPitch) |
|
742 ) |
|
743 { |
|
744 ASSERT(aColorPixelPitch == sizeof(TUint32)); |
|
745 Mem::Move(aDstAddress, aColorAddress, aWidth * sizeof(TUint32)); |
|
746 } |
|
747 |
|
748 |
|
749 extern void BitBltThirtyTwoBppSimple |
|
750 ( |
|
751 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
752 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
753 const TRect& aDstRect, |
|
754 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
755 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
756 const TLcdTransform& aTransform |
|
757 ) |
|
758 { |
|
759 // |
|
760 // Translation or translation & vertical reflection case. |
|
761 // |
|
762 ASSERT(aTransform.iDuDx == 1); |
|
763 ASSERT(aTransform.iDuDy == 0); |
|
764 ASSERT(aTransform.iDvDx == 0); |
|
765 ASSERT(aTransform.iDvDy == 1 || aTransform.iDvDy == -1); |
|
766 |
|
767 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
768 BlitLineThirtyTwoBppSimple); |
|
769 } |
|
770 |
|
771 |
|
772 LOCAL_C void BlitLineThirtyTwoBpp |
|
773 ( |
|
774 TUint8* aDstAddress, |
|
775 TInt aWidth, |
|
776 TUint8* aColorAddress, |
|
777 TInt aColorPixelPitch |
|
778 ) |
|
779 { |
|
780 TUint32* dst = (TUint32*)aDstAddress; |
|
781 TUint32* end = dst + aWidth; |
|
782 |
|
783 TUint8* colorAddr = aColorAddress; |
|
784 while (dst < end) |
|
785 { |
|
786 *dst++ = *(TUint32*)colorAddr; |
|
787 colorAddr += aColorPixelPitch; |
|
788 } |
|
789 } |
|
790 |
|
791 |
|
792 extern void BitBltThirtyTwoBpp |
|
793 ( |
|
794 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
795 const TAcceleratedBitmapInfo* /*aDstAlphaBitmap*/, |
|
796 const TRect& aDstRect, |
|
797 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
798 const TAcceleratedBitmapInfo* /*aSrcAlphaBitmap*/, |
|
799 const TLcdTransform& aTransform |
|
800 ) |
|
801 { |
|
802 GenericBlit(aDstColorBitmap, aDstRect, aSrcColorBitmap, aTransform, |
|
803 BlitLineThirtyTwoBpp); |
|
804 } |
|
805 |
|
806 extern void BitBltThirtyTwoBppEightBpp |
|
807 ( |
|
808 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
809 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
810 const TRect& aDstRect, |
|
811 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
812 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
813 const TLcdTransform& aTransform |
|
814 ) |
|
815 { |
|
816 BitBltThirtyTwoBpp(aDstColorBitmap, NULL, aDstRect, aSrcColorBitmap, NULL, aTransform); |
|
817 BitBltEightBpp(aDstAlphaBitmap, NULL, aDstRect, aSrcAlphaBitmap, NULL, aTransform); |
|
818 } |
|
819 |
|
820 extern void BitBltThirtyTwoBppOneBpp |
|
821 ( |
|
822 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
823 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
824 const TRect& aDstRect, |
|
825 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
826 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
827 const TLcdTransform& aTransform |
|
828 ) |
|
829 { |
|
830 BitBltThirtyTwoBpp(aDstColorBitmap, NULL, aDstRect, aSrcColorBitmap, NULL, aTransform); |
|
831 BitBltOneBpp(aDstAlphaBitmap, NULL, aDstRect, aSrcAlphaBitmap, NULL, aTransform); |
|
832 } |
|
833 |
|
834 extern void BitBltThirtyTwoBppThirtyTwoBpp |
|
835 ( |
|
836 const TAcceleratedBitmapInfo* aDstColorBitmap, |
|
837 const TAcceleratedBitmapInfo* aDstAlphaBitmap, |
|
838 const TRect& aDstRect, |
|
839 const TAcceleratedBitmapInfo* aSrcColorBitmap, |
|
840 const TAcceleratedBitmapInfo* aSrcAlphaBitmap, |
|
841 const TLcdTransform& aTransform |
|
842 ) |
|
843 { |
|
844 BitBltThirtyTwoBpp(aDstColorBitmap, NULL, aDstRect, aSrcColorBitmap, NULL, aTransform); |
|
845 BitBltThirtyTwoBpp(aDstAlphaBitmap, NULL, aDstRect, aSrcAlphaBitmap, NULL, aTransform); |
|
846 } |