3679
DrawLogo(WindowPtr pWin)
3684
unsigned int width, height, size;
3686
int rc, thin, gap, d31;
3687
DDXPointRec poly[4];
3688
ChangeGCVal fore[2], back[2];
3690
BITS32 fmask, bmask;
3693
pDraw = (DrawablePtr)pWin;
3694
pScreen = pDraw->pScreen;
3695
x = -pWin->origin.x;
3696
y = -pWin->origin.y;
3697
width = pScreen->width;
3698
height = pScreen->height;
3699
pGC = GetScratchGC(pScreen->rootDepth, pScreen);
3703
if ((rand() % 100) <= 17) /* make the probability for white fairly low */
3704
fore[0].val = pScreen->whitePixel;
3706
fore[0].val = pScreen->blackPixel;
3707
if (pWin->backgroundState == BackgroundPixel) {
3708
rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
3709
RT_COLORMAP, serverClient, DixReadAccess);
3710
if (rc == Success) {
3711
Pixel querypixels[2];
3713
querypixels[0] = fore[0].val;
3714
querypixels[1] = pWin->background.pixel;
3715
QueryColors(cmap, 2, querypixels, rgb, serverClient);
3716
if ((rgb[0].red == rgb[1].red) &&
3717
(rgb[0].green == rgb[1].green) &&
3718
(rgb[0].blue == rgb[1].blue)) {
3719
if (fore[0].val == pScreen->blackPixel)
3720
fore[0].val = pScreen->whitePixel;
3722
fore[0].val = pScreen->blackPixel;
3726
fore[1].val = FillSolid;
3727
fmask = GCForeground|GCFillStyle;
3728
if (pWin->backgroundState == BackgroundPixel) {
3729
back[0].val = pWin->background.pixel;
3730
back[1].val = FillSolid;
3731
bmask = GCForeground|GCFillStyle;
3735
ChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin, back);
3736
back[0].val = FillTiled;
3737
back[1].ptr = pWin->background.pixmap;
3738
bmask = GCFillStyle|GCTile;
3741
/* should be the same as the reference function XmuDrawLogo() */
3746
size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
3748
x += rand() % (width - size);
3749
y += rand() % (height - size);
3752
* Draw what will be the thin strokes.
3762
* Point d is 9/44 (~1/5) of the way across.
3766
if (thin < 1) thin = 1;
3768
d31 = thin + thin + gap;
3769
poly[0].x = x + size; poly[0].y = y;
3770
poly[1].x = x + size-d31; poly[1].y = y;
3771
poly[2].x = x + 0; poly[2].y = y + size;
3772
poly[3].x = x + d31; poly[3].y = y + size;
3773
ChangeGC(NullClient, pGC, fmask, fore);
3774
ValidateGC(pDraw, pGC);
3775
(*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3778
* Erase area not needed for lower thin stroke.
3788
poly[0].x = x + d31/2; poly[0].y = y + size;
3789
poly[1].x = x + size / 2; poly[1].y = y + size/2;
3790
poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
3791
poly[3].x = x + d31; poly[3].y = y + size;
3792
ChangeGC(NullClient, pGC, bmask, back);
3793
ValidateGC(pDraw, pGC);
3794
(*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3797
* Erase area not needed for upper thin stroke.
3807
poly[0].x = x + size - d31/2; poly[0].y = y;
3808
poly[1].x = x + size / 2; poly[1].y = y + size/2;
3809
poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
3810
poly[3].x = x + size - d31; poly[3].y = y;
3811
ValidateGC(pDraw, pGC);
3812
(*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3815
* Draw thick stroke.
3816
* Point b is 1/4 of the way across.
3827
poly[0].x = x; poly[0].y = y;
3828
poly[1].x = x + size/4; poly[1].y = y;
3829
poly[2].x = x + size; poly[2].y = y + size;
3830
poly[3].x = x + size - size/4; poly[3].y = y + size;
3831
ChangeGC(NullClient, pGC, fmask, fore);
3832
ValidateGC(pDraw, pGC);
3833
(*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3836
* Erase to create gap.
3845
poly[0].x = x + size- thin; poly[0].y = y;
3846
poly[1].x = x + size-( thin+gap); poly[1].y = y;
3847
poly[2].x = x + thin; poly[2].y = y + size;
3848
poly[3].x = x + thin + gap; poly[3].y = y + size;
3849
ChangeGC(NullClient, pGC, bmask, back);
3850
ValidateGC(pDraw, pGC);
3851
(*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);