Tk Source Code

Changes On Branch bug-21525158b0
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-21525158b0 Excluding Merge-Ins

This is equivalent to a diff from 6cfd57f0 to 5ab674eb

2019-01-20
19:21
Fix [21525158b0]: On MS Windows XImage data and Tk_Visual() return wrong information. Bug report, analysis and patch provided by Scott Pitcher (many thanks!) check-in: efab40f9 user: fvogel tags: trunk
13:29
Rebase to latest trunk check-in: 4a2978da user: jan.nijtmans tags: bug-6ce6e74635
13:15
Rebase against new trunk Closed-Leaf check-in: 5ab674eb user: jan.nijtmans tags: bug-21525158b0
08:46
Remove the last remaining reference to NO_WINRGBFIX check-in: 5bfb6631 user: fvogel tags: bug-21525158b0
2019-01-18
18:08
Clean up Aqua button geometry code so unixButton tests pass, and make a few small adjustments to the appearance. check-in: 6cfd57f0 user: culler tags: trunk
18:05
Clean up Aqua button geometry code so unixButton tests pass, and make a few small adjustments to the appearance. check-in: 521c2e75 user: culler tags: core-8-6-branch
2019-01-13
14:50
Merge 8.6 check-in: 823fb797 user: jan.nijtmans tags: trunk

Changes to generic/tkCanvas.c.
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2765
2766
2767
2768
2769
2770
2771






2772
2773




2774
2775

2776
2777
2778
2779
2780
2781
2782







-
-
-
-
-
-


-
-
-
-


-







            }

            /*
             * We have a pixel with the correct byte order, so pull out the
             * colours and place them in the photo block. Perhaps we could
             * just not bother with the alpha byte because we are using
             * TK_PHOTO_COMPOSITE_SET later?
             * ***Windows: We have to swap the red and blue values. The
             * XImage storage is B - G - R - A which becomes a 32bit ARGB
             * quad. However the visual mask is a 32bit ABGR quad. And
             * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad.
             * If the visual mask was correct there would be no need to
             * swap anything here.
             */

#ifdef _WIN32
#define   R_OFFSET 2
#define   B_OFFSET 0
#else
#define   R_OFFSET 0
#define   B_OFFSET 2
#endif
            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
                    (unsigned char)((pixel & visualPtr->red_mask) >> rshift);
            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
                    (unsigned char)((pixel & visualPtr->green_mask) >> gshift);
            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + B_OFFSET] =
                    (unsigned char)((pixel & visualPtr->blue_mask) >> bshift);
            blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +3] = 0xFF;
Changes to win/tkWinDraw.c.
515
516
517
518
519
520
521

522
523
524
525
526
527
528
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529







+







				/* Dimensions of subimage. */
{
    HDC dc, dcMem;
    TkWinDCState state;
    BITMAPINFO *infoPtr;
    HBITMAP bitmap;
    char *data;
    Visual *visual;

    display->request++;

    dc = TkWinGetDrawableDC(display, d, &state);
    SetROP2(dc, tkpWinRopModes[gc->function]);
    dcMem = CreateCompatibleDC(dc);

552
553
554
555
556
557
558
559

560
561
562
563
564
565
566
567
568
569
570
571
572
573

574
575
576
577
578
579
580
581
582







583
584
585
586
587
588
589
553
554
555
556
557
558
559

560
561
562
563
564
565
566
567

568
569
570
571
572
573
574
575
576
577
578
579
580
581
582

583
584
585
586
587
588
589
590
591
592
593
594
595
596







-
+







-






+








-
+
+
+
+
+
+
+








	usePalette = (image->bits_per_pixel < 16);

	if (usePalette) {
	    infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)
		    + sizeof(RGBQUAD)*ncolors);
	} else {
	    infoPtr = ckalloc(sizeof(BITMAPINFOHEADER));
	    infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(DWORD)*4);
	}

	infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	infoPtr->bmiHeader.biWidth = image->width;
	infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */
	infoPtr->bmiHeader.biPlanes = 1;
	infoPtr->bmiHeader.biBitCount = image->bits_per_pixel;
	infoPtr->bmiHeader.biCompression = BI_RGB;
	infoPtr->bmiHeader.biSizeImage = 0;
	infoPtr->bmiHeader.biXPelsPerMeter = 0;
	infoPtr->bmiHeader.biYPelsPerMeter = 0;
	infoPtr->bmiHeader.biClrImportant = 0;

	if (usePalette) {
	    infoPtr->bmiHeader.biCompression = BI_RGB;
	    infoPtr->bmiHeader.biClrUsed = ncolors;
	    for (i = 0; i < ncolors; i++) {
		infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]);
		infoPtr->bmiColors[i].rgbGreen = GetGValue(colors[i]);
		infoPtr->bmiColors[i].rgbRed = GetRValue(colors[i]);
		infoPtr->bmiColors[i].rgbReserved = 0;
	    }
	} else {
	    infoPtr->bmiHeader.biClrUsed = 0;
	    infoPtr->bmiHeader.biCompression = BI_BITFIELDS;
	    /* Modelled on XGetVisualInfo() in xutil.c.
	     * We want to get the rgb masks for the default visual for the given display. */
	    visual = DefaultVisual(display,0);
	    *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))) = visual->blue_mask;
	    *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+1) = visual->green_mask;
	    *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+2) = visual->red_mask;
	}
	bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT,
		image->data, infoPtr, DIB_RGB_COLORS);
	ckfree(infoPtr);
    }
    if (!bitmap) {
	Tcl_Panic("Fail to allocate bitmap");
Changes to win/tkWinX.c.
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
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







-
+

-
+



-
+

-
+



-
+

-
+







	screen->root_visual->map_entries = 16;
    } else if (screen->root_depth == 8) {
	screen->root_visual->class = StaticColor;
	screen->root_visual->map_entries = 256;
    } else if (screen->root_depth == 12) {
	screen->root_visual->class = TrueColor;
	screen->root_visual->map_entries = 32;
	screen->root_visual->red_mask = 0xf0;
	screen->root_visual->red_mask = 0xf00000;
	screen->root_visual->green_mask = 0xf000;
	screen->root_visual->blue_mask = 0xf00000;
	screen->root_visual->blue_mask = 0xf0;
    } else if (screen->root_depth == 16) {
	screen->root_visual->class = TrueColor;
	screen->root_visual->map_entries = 64;
	screen->root_visual->red_mask = 0xf8;
	screen->root_visual->red_mask = 0xf80000;
	screen->root_visual->green_mask = 0xfc00;
	screen->root_visual->blue_mask = 0xf80000;
	screen->root_visual->blue_mask = 0xf8;
    } else if (screen->root_depth >= 24) {
	screen->root_visual->class = TrueColor;
	screen->root_visual->map_entries = 256;
	screen->root_visual->red_mask = 0xff;
	screen->root_visual->red_mask = 0xff0000;
	screen->root_visual->green_mask = 0xff00;
	screen->root_visual->blue_mask = 0xff0000;
	screen->root_visual->blue_mask = 0xff;
    }
    screen->root_visual->bits_per_rgb = screen->root_depth;
    ReleaseDC(NULL, dc);

    if (screen->cmap != None) {
	XFreeColormap(display, screen->cmap);
    }