1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
/*
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
*
*Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
*"Software"), to deal in the Software without restriction, including
*without limitation the rights to use, copy, modify, merge, publish,
*distribute, sublicense, and/or sell copies of the Software, and to
*permit persons to whom the Software is furnished to do so, subject to
*the following conditions:
*
*The above copyright notice and this permission notice shall be
*included in all copies or substantial portions of the Software.
*
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
*EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
*MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
*NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
*ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
*CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
*WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*Except as contained in this notice, the name of the XFree86 Project
*shall not be used in advertising or otherwise to promote the sale, use
*or other dealings in this Software without prior written authorization
*from the XFree86 Project.
*
* Authors: Harold L Hunt II
*/
/* $XFree86: xc/programs/Xserver/hw/xwin/winfillsp.c,v 1.9 2001/11/01 12:19:40 alanh Exp $ */
#include "win.h"
/* See Porting Layer Definition - p. 54 */
void
winFillSpansNativeGDI (DrawablePtr pDrawable,
GCPtr pGC,
int iSpans,
DDXPointPtr pPoints,
int *piWidths,
int fSorted)
{
winGCPriv(pGC);
int iSpan;
DDXPointPtr pPoint = NULL;
int *piWidth = 0;
HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
PixmapPtr pPixmap = NULL;
winPrivPixmapPtr pPixmapPriv = NULL;
HBITMAP hbmpFilledStipple = NULL, hbmpMaskedForeground = NULL;
PixmapPtr pStipple = NULL;
winPrivPixmapPtr pStipplePriv = NULL;
PixmapPtr pTile = NULL;
winPrivPixmapPtr pTilePriv = NULL;
HBRUSH hbrushStipple = NULL;
HDC hdcStipple = NULL;
BYTE *pbbitsFilledStipple = NULL;
int iX;
DEBUG_FN_NAME("winFillSpans");
DEBUGVARS;
DEBUGPROC_MSG;
/* Branch on the type of drawable we have */
switch (pDrawable->type)
{
case DRAWABLE_PIXMAP:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP\n");
#if 0
/* Branch on the raster operation type */
switch (pGC->alu)
{
case GXclear:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXclear\n");
break;
case GXand:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXand\n");
break;
case GXandReverse:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXandReverse\n");
break;
case GXcopy:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXcopy\n");
break;
case GXandInverted:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXandInverted\n");
break;
case GXnoop:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXnoop\n");
break;
case GXxor:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXxor\n");
break;
case GXor:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXor\n");
break;
case GXnor:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXnor\n");
break;
case GXequiv:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXequiv\n");
break;
case GXinvert:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXinvert\n");
break;
case GXorReverse:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXorReverse\n");
break;
case GXcopyInverted:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXcopyInverted\n");
break;
case GXorInverted:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXorInverted\n");
break;
case GXnand:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXnand\n");
break;
case GXset:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - GXset\n");
break;
default:
FatalError ("winFillSpans - DRAWABLE_PIXMAP - Unknown ROP\n");
break;
}
#endif
/* Get a pixmap pointer from the drawable pointer, and fetch privates */
pPixmap = (PixmapPtr) pDrawable;
pPixmapPriv = winGetPixmapPriv (pPixmap);
/* Select the drawable pixmap into memory hdc */
hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
if (hbmpOrig == NULL)
FatalError ("winFillSpans - DRAWABLE_PIXMAP - "
"SelectObject () failed on pPixmapPriv->hBitmap\n");
/* Branch on the fill type */
switch (pGC->fillStyle)
{
case FillSolid:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - FillSolid %08x\n",
pDrawable);
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width, pDrawable->height,
pDrawable->width, pDrawable->height,
pGCPriv->hdcMem,
0, 0,
SRCCOPY);
DEBUG_MSG ("FillSolid - Original bitmap");
/* Enumerate spans */
for (iSpan = 0; iSpan < iSpans; ++iSpan)
{
/* Get pointers to the current span location and width */
pPoint = pPoints + iSpan;
piWidth = piWidths + iSpan;
/* Display some useful information */
ErrorF ("(%dx%dx%d) (%d,%d) fg: %d bg: %d w: %d\n",
pDrawable->width, pDrawable->height, pDrawable->depth,
pPoint->x, pPoint->y,
pGC->fgPixel, pGC->bgPixel,
*piWidth);
/* Draw the requested line */
MoveToEx (pGCPriv->hdcMem, pPoint->x, pPoint->y, NULL);
LineTo (pGCPriv->hdcMem, pPoint->x + *piWidth, pPoint->y);
}
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width * 2, pDrawable->height,
pDrawable->width, pDrawable->height,
pGCPriv->hdcMem,
0, 0,
SRCCOPY);
DEBUG_MSG ("FillSolid - Filled bitmap");
/* Push the drawable pixmap out of the GC HDC */
SelectObject (pGCPriv->hdcMem, hbmpOrig);
break;
case FillStippled:
ErrorF ("winFillSpans - DRAWABLE_PIXMAP - FillStippled %08x\n",
pDrawable);
/*
* FIXME: Assuming that pGC->patOrg.x = pGC->patOrg.y = 0
*/
pStipple = pGC->stipple;
pStipplePriv = winGetPixmapPriv (pStipple);
/* Create a memory DC to hold the stipple */
hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
/* Create a destination sized compatible bitmap */
hbmpFilledStipple = winCreateDIBNativeGDI (pDrawable->width,
pDrawable->height,
pDrawable->depth,
&pbbitsFilledStipple,
NULL);
/* Select the stipple bitmap into the stipple DC */
hbmpOrigStipple = SelectObject (hdcStipple, hbmpFilledStipple);
if (hbmpOrigStipple == NULL)
FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
"SelectObject () failed on hbmpFilledStipple\n");
/* Create a pattern brush from the original stipple */
hbrushStipple = CreatePatternBrush (pStipplePriv->hBitmap);
/* Select the original stipple brush into the stipple DC */
SelectObject (hdcStipple, hbrushStipple);
/* PatBlt the original stipple to the filled stipple */
PatBlt (hdcStipple,
0, 0,
pDrawable->width, pDrawable->height,
PATCOPY);
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width, 0,
pDrawable->width, pDrawable->height,
hdcStipple,
0, 0,
SRCCOPY);
DEBUG_MSG("Filled a drawable-sized stipple");
/*
* Mask out the bits from the drawable that are being preserved;
* hbmpFilledStipple now contains the preserved original bits.
*/
BitBlt (hdcStipple,
0, 0,
pDrawable->width, pDrawable->height,
pGCPriv->hdcMem,
0, 0,
SRCERASE);
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width * 2, 0,
pDrawable->width, pDrawable->height,
hdcStipple,
0, 0,
SRCCOPY);
DEBUG_MSG("Preserved original bits");
/*
* Create a destination sized compatible bitmap to hold
* the masked foreground color.
*/
hbmpMaskedForeground = winCreateDIBNativeGDI (pDrawable->width,
pDrawable->height,
pDrawable->depth,
NULL,
NULL);
/*
* Select the masked foreground bitmap into the default memory DC;
* this should pop the drawable bitmap out of the default DC.
*/
if (SelectObject (pGCPriv->hdcMem, hbmpMaskedForeground) == NULL)
FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
"SelectObject () failed on hbmpMaskedForeground\n");
/* Free the original drawable */
DeleteObject (pPixmapPriv->hBitmap);
pPixmapPriv->hBitmap = NULL;
pPixmapPriv->pbBits = NULL;
/* Select the stipple brush into the default memory DC */
SelectObject (pGCPriv->hdcMem, hbrushStipple);
/* Create the masked foreground bitmap using the original stipple */
PatBlt (pGCPriv->hdcMem,
0, 0,
pDrawable->width, pDrawable->height,
PATCOPY);
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width * 3, 0,
pDrawable->width, pDrawable->height,
pGCPriv->hdcMem,
0, 0,
SRCCOPY);
DEBUG_MSG("Masked foreground bitmap");
/*
* Combine the masked foreground with the masked drawable;
* hbmpFilledStipple will contain the drawable stipple filled
* with the current foreground color
*/
BitBlt (hdcStipple,
0, 0,
pDrawable->width, pDrawable->height,
pGCPriv->hdcMem,
0, 0,
SRCPAINT);
/*
* REMOVE - Visual verification only.
*/
BitBlt (pGCPriv->hdc,
pDrawable->width * 4, 0,
pDrawable->width, pDrawable->height,
hdcStipple,
0, 0,
SRCCOPY);
DEBUG_MSG("Completed stipple");
/* Release the stipple DC */
SelectObject (hdcStipple, hbmpOrig);
DeleteDC (hdcStipple);
/* Pop the stipple pattern brush out of the default mem DC */
SelectObject (pGCPriv->hdcMem, GetStockObject (WHITE_BRUSH));
/* Destroy the original stipple pattern brush */
DeleteObject (hbrushStipple);
/* Clear the memory DC */
SelectObject (pGCPriv->hdcMem, hbmpOrig);
/* Free the masked foreground bitmap */
DeleteObject (hbmpMaskedForeground);
/* Point the drawable to the new bitmap */
pPixmapPriv->hBitmap = hbmpFilledStipple;
pPixmapPriv->pbBits = pbbitsFilledStipple;
break;
case FillTiled:
FatalError ("\nwinFillSpans - DRAWABLE_PIXMAP - FillTiled\n\n");
break;
case FillOpaqueStippled:
FatalError ("winFillSpans - DRAWABLE_PIXMAP - OpaqueStippled\n");
break;
default:
FatalError ("winFillSpans - DRAWABLE_PIXMAP - Unknown "
"fillStyle\n");
break;
}
break;
case DRAWABLE_WINDOW:
/* Branch on fill style */
switch (pGC->fillStyle)
{
case FillSolid:
ErrorF ("\nwinFillSpans - DRAWABLE_WINDOW - FillSolid\n\n");
/* Enumerate spans */
for (iSpan = 0; iSpan < iSpans; ++iSpan)
{
/* Get pointers to the current span location and width */
pPoint = pPoints + iSpan;
piWidth = piWidths + iSpan;
/* Display some useful information */
ErrorF ("(%dx%dx%d) (%d,%d) fg: %d bg: %d w: %d\n",
pDrawable->width, pDrawable->height, pDrawable->depth,
pPoint->x, pPoint->y,
pGC->fgPixel, pGC->bgPixel,
*piWidth);
/* Draw the requested line */
MoveToEx (pGCPriv->hdc, pPoint->x, pPoint->y, NULL);
LineTo (pGCPriv->hdc, pPoint->x + *piWidth, pPoint->y);
}
break;
case FillStippled:
FatalError ("winFillSpans - DRAWABLE_WINDOW - FillStippled\n\n");
break;
case FillTiled:
ErrorF ("\nwinFillSpans - DRAWABLE_WINDOW - FillTiled\n\n");
/* Get a pixmap pointer from the tile pointer, and fetch privates */
pTile = (PixmapPtr) pGC->tile.pixmap;
pTilePriv = winGetPixmapPriv (pTile);
/* Select the tile into a DC */
hbmpOrig = SelectObject (pGCPriv->hdcMem, pTilePriv->hBitmap);
if (hbmpOrig == NULL)
FatalError ("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
"SelectObject () failed on pTilePric->hBitmap\n");
/* Enumerate spans */
for (iSpan = 0; iSpan < iSpans; ++iSpan)
{
/* Get pointers to the current span location and width */
pPoint = pPoints + iSpan;
piWidth = piWidths + iSpan;
for (iX = 0; iX < *piWidth; iX += pTile->drawable.width)
{
/* Blit the tile to the screen, one line at a time */
BitBlt (pGCPriv->hdc,
pPoint->x + iX, pPoint->y,
pTile->drawable.width, 1,
pGCPriv->hdcMem,
0, pPoint->y % pTile->drawable.height,
SRCCOPY);
}
}
/* Push the drawable pixmap out of the GC HDC */
SelectObject (pGCPriv->hdcMem, hbmpOrig);
#if 0
DEBUG_MSG("Completed tile fill");
#endif
break;
case FillOpaqueStippled:
FatalError ("winFillSpans - DRAWABLE_WINDOW - "
"OpaqueStippled\n");
break;
default:
FatalError ("winFillSpans - DRAWABLE_WINDOW - Unknown "
"fillStyle\n");
}
/* Branch on the raster operation type */
switch (pGC->alu)
{
case GXclear:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXclear\n");
break;
case GXand:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXand\n");
break;
case GXandReverse:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXandReverse\n");
break;
case GXcopy:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXcopy\n");
break;
case GXandInverted:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXandInverted\n");
break;
case GXnoop:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXnoop\n");
break;
case GXxor:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXxor\n");
break;
case GXor:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXor\n");
break;
case GXnor:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXnor\n");
break;
case GXequiv:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXequiv\n");
break;
case GXinvert:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXinvert\n");
break;
case GXorReverse:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXorReverse\n");
break;
case GXcopyInverted:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXcopyInverted\n");
break;
case GXorInverted:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXorInverted\n");
break;
case GXnand:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXnand\n");
break;
case GXset:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - GXset\n");
break;
default:
ErrorF ("winFillSpans - DRAWABLE_WINDOW - Unknown ROP\n");
break;
}
break;
case UNDRAWABLE_WINDOW:
FatalError ("winFillSpans - UNDRAWABLE_WINDOW\n\n");
switch (pGC->fillStyle)
{
case FillSolid:
ErrorF ("\nwinFillSpans - UNDRAWABLE_WINDOW - FillSolid\n\n");
break;
case FillStippled:
ErrorF ("\nwinFillSpans - UNDRAWABLE_WINDOW - FillStippled\n\n");
break;
case FillTiled:
ErrorF ("\nwinFillSpans - UNDRAWABLE_WINDOW - FillTiled\n\n");
break;
case FillOpaqueStippled:
FatalError ("winFillSpans () - UNDRAWABLE_WINDOW - "
"OpaqueStippled\n");
break;
default:
FatalError ("winFillSpans () - UNDRAWABLE_WINDOW - Unknown "
"fillStyle\n");
}
break;
case DRAWABLE_BUFFER:
FatalError ("winFillSpansNativeGDI - DRAWABLE_BUFFER\n");
break;
default:
FatalError ("winFillSpansNativeGDI - Unknown drawable type\n");
break;
}
}
|