home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / x / x11p-13.zip / RCS / do_copyarea.c, < prev    next >
Text File  |  1989-12-13  |  23KB  |  1,150 lines

  1. head     2.9;
  2. access   ;
  3. symbols  pre-merge:2.0;
  4. locks    ; strict;
  5. comment  @ * @;
  6.  
  7.  
  8. 2.9
  9. date     89.12.13.19.11.30;  author joel;  state Exp;
  10. branches ;
  11. next     2.8;
  12.  
  13. 2.8
  14. date     89.12.07.16.34.01;  author joel;  state Exp;
  15. branches ;
  16. next     2.7;
  17.  
  18. 2.7
  19. date     89.09.28.15.16.32;  author joel;  state Exp;
  20. branches ;
  21. next     2.6;
  22.  
  23. 2.6
  24. date     89.05.17.11.07.29;  author joel;  state Exp;
  25. branches ;
  26. next     2.5;
  27.  
  28. 2.5
  29. date     89.05.11.16.44.11;  author joel;  state Exp;
  30. branches ;
  31. next     2.4;
  32.  
  33. 2.4
  34. date     89.05.08.18.31.37;  author joel;  state Exp;
  35. branches ;
  36. next     2.3;
  37.  
  38. 2.3
  39. date     89.05.04.14.19.33;  author joel;  state Exp;
  40. branches ;
  41. next     2.2;
  42.  
  43. 2.2
  44. date     89.05.04.13.42.13;  author joel;  state Exp;
  45. branches ;
  46. next     2.1;
  47.  
  48. 2.1
  49. date     89.05.03.14.17.26;  author joel;  state Exp;
  50. branches ;
  51. next     2.0;
  52.  
  53. 2.0
  54. date     89.01.31.17.03.13;  author erik;  state Exp;
  55. branches ;
  56. next     1.2;
  57.  
  58. 1.2
  59. date     89.01.31.17.03.13;  author joel;  state Exp;
  60. branches ;
  61. next     1.1;
  62.  
  63. 1.1
  64. date     88.08.15.16.38.09;  author susan;  state Exp;
  65. branches ;
  66. next     ;
  67.  
  68.  
  69. desc
  70. @Random copyarea test.  Does random 200x200 squares
  71. @
  72.  
  73.  
  74. 2.9
  75. log
  76. @Added all manner of copyarea tween pixmaps and windows
  77. @
  78. text
  79. @/*****************************************************************************
  80. Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
  81.  
  82.                         All Rights Reserved
  83.  
  84. Permission to use, copy, modify, and distribute this software and its 
  85. documentation for any purpose and without fee is hereby granted, 
  86. provided that the above copyright notice appear in all copies and that
  87. both that copyright notice and this permission notice appear in 
  88. supporting documentation, and that the name of Digital not be
  89. used in advertising or publicity pertaining to distribution of the
  90. software without specific, written prior permission.  
  91.  
  92. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  93. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  94. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  95. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  96. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  97. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  98. SOFTWARE.
  99.  
  100. ******************************************************************************/
  101.  
  102. #include "x11perf.h"
  103.  
  104. #define NUMPOINTS 100
  105.  
  106. static Pixmap   pix;
  107. static XImage   *image;
  108. static XPoint   points[NUMPOINTS];
  109. static XSegment *segsa, *segsb;
  110.  
  111. #define NegMod(x, y) ((y) - (((-x)-1) % (7)) - 1)
  112.  
  113. int InitScroll(xp, p, reps)
  114.     XParms  xp;
  115.     Parms   p;
  116.     int     reps;
  117. {
  118.     int i;
  119.  
  120.     for (i = 0; i != NUMPOINTS; i++) {    
  121.         points[i].x = rand() % WIDTH;
  122.         points[i].y = rand() % HEIGHT;
  123.     }
  124.     XDrawLines(xp->d, xp->w, xp->fggc, points, NUMPOINTS, CoordModeOrigin);
  125.     return reps;
  126. }
  127.  
  128. void DoScroll(xp, p, reps)
  129.     XParms  xp;
  130.     Parms   p;
  131.     int     reps;
  132. {
  133.     int i, size, x, y, xorg, yorg;
  134.  
  135.     size = p->special;
  136.     xorg = 0;   yorg = 0;
  137.     x    = 0;   y    = 0;
  138.  
  139.     for (i = 0; i != reps; i++) {
  140.     XCopyArea(xp->d, xp->w, xp->w, xp->fggc, x, y+1, size, size, x, y);
  141.     y += size;
  142.     if (y + size + 1 > HEIGHT) {
  143.         yorg++;
  144.         if (yorg >= size || yorg + size + 1 > HEIGHT) {
  145.         yorg = 0;
  146.         xorg++;
  147.         if (xorg >= size || xorg + size > WIDTH) {
  148.             xorg = 0;
  149.         }
  150.         }
  151.         y = yorg;
  152.         x += size;
  153.         if (x + size > WIDTH) {
  154.         x = xorg;
  155.         }
  156.     }
  157.     }
  158. }
  159.  
  160. void MidScroll(xp, p)
  161.     XParms  xp;
  162.     Parms   p;
  163. {
  164.     XClearWindow(xp->d, xp->w);
  165.     XDrawLines(xp->d, xp->w, xp->fggc, points, NUMPOINTS, CoordModeOrigin);
  166. }
  167.  
  168. void EndScroll(xp, p)
  169.     XParms  xp;
  170.     Parms   p;
  171. {
  172. }
  173.  
  174. static void InitCopyLocations(xp, p, reps)
  175.     XParms  xp;
  176.     Parms   p;
  177.     int     reps;
  178. {
  179.     int x1, y1, x2, y2, size, i;
  180.     int xinc, yinc;
  181.     int width, height;
  182.  
  183.     /* Try to exercise all alignments of src and destination equally, as well
  184.        as all 4 top-to-bottom/bottom-to-top, left-to-right, right-to-left
  185.        copying directions.  Computation done here just to make sure slow
  186.        machines aren't measuring anything but the XCopyArea calls.
  187.     */
  188.     size = p->special;
  189.     xinc = (size & ~3) + 1;
  190.     yinc = xinc + 3;
  191.  
  192.     width = (WIDTH - size) & ~31;
  193.     height = (HEIGHT - size) & ~31;
  194.     
  195.     x1 = 0;
  196.     y1 = 0;
  197.     x2 = width;
  198.     y2 = height;
  199.     
  200.     segsa = (XSegment *)malloc(reps * sizeof(XSegment));
  201.     segsb = (XSegment *)malloc(reps * sizeof(XSegment));
  202.     for (i = 0; i != reps; i++) {
  203.     segsa[i].x1 = x1;
  204.     segsa[i].y1 = y1;
  205.     segsa[i].x2 = x2;
  206.     segsa[i].y2 = y2;
  207.  
  208.     /* Move x2, y2, location backward */
  209.     x2 -= xinc;
  210.     if (x2 < 0) {
  211.         x2 = NegMod(x2, width);
  212.         y2 -= yinc;
  213.         if (y2 < 0) {
  214.         y2 = NegMod(y2, height);
  215.         }
  216.     }
  217.  
  218.     segsb[i].x1 = x1;
  219.     segsb[i].y1 = y1;
  220.     segsb[i].x2 = x2;
  221.     segsb[i].y2 = y2;
  222.  
  223.     /* Move x1, y1 location forward */
  224.     x1 += xinc;
  225.     if (x1 > width) {
  226.         x1 %= 32;
  227.         y1 += yinc;
  228.         if (y1 > height) {
  229.         y1 %= 32;
  230.         }
  231.     }
  232.     } /* end for */
  233. }
  234.  
  235.  
  236. int InitCopyWin(xp, p, reps)
  237.     XParms  xp;
  238.     Parms   p;
  239.     int     reps;
  240. {
  241.     (void) InitScroll(xp, p, reps);
  242.     InitCopyLocations(xp, p, reps);
  243.     return reps;
  244. }
  245.  
  246. int InitCopyPix(xp, p, reps)
  247.     XParms  xp;
  248.     Parms   p;
  249.     int     reps;
  250. {
  251.     (void) InitCopyWin(xp, p, reps);
  252.  
  253.     /* Create pixmap to write stuff into, and initialize it */
  254.     pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT,
  255.         DefaultDepth(xp->d, DefaultScreen(xp->d)));
  256.     XCopyArea(xp->d, xp->w, pix, xp->fggc, 0, 0, WIDTH, HEIGHT, 0, 0);
  257.     return reps;
  258. }
  259.  
  260. Bool InitGetImage(xp, p, reps)
  261.     XParms  xp;
  262.     Parms   p;
  263.     int     reps;
  264. {
  265.     (void) InitCopyWin(xp, p, reps);
  266.  
  267.     /* Create image to stuff bits into */
  268.     image = XGetImage(xp->d, xp->w, 0, 0, WIDTH, HEIGHT, ~0, ZPixmap);
  269.     return reps;
  270. }
  271.  
  272. Bool InitPutImage(xp, p, reps)
  273.     XParms  xp;
  274.     Parms   p;
  275.     int     reps;
  276. {
  277.     (void) InitGetImage(xp, p, reps);
  278.     XClearWindow(xp->d, xp->w);
  279.     return reps;
  280. }
  281.  
  282. static void CopyArea(xp, p, reps, src, dst)
  283.     XParms  xp;
  284.     Parms   p;
  285.     int     reps;
  286.     Drawable src, dst;
  287. {
  288.     int i, size;
  289.     XSegment *sa, *sb;
  290.  
  291.     size = p->special;
  292.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  293.     XCopyArea(xp->d, src, dst, xp->fggc,
  294.         sa->x1, sa->y1, size, size, sa->x2, sa->y2);
  295.     XCopyArea(xp->d, src, dst, xp->fggc,
  296.         sa->x2, sa->y2, size, size, sa->x1, sa->y1);
  297.     XCopyArea(xp->d, src, dst, xp->fggc,
  298.         sb->x2, sb->y2, size, size, sb->x1, sb->y1);
  299.     XCopyArea(xp->d, src, dst, xp->fggc,
  300.         sb->x1, sb->y1, size, size, sb->x2, sb->y2);
  301.     }
  302. }
  303.  
  304. void DoCopyWinWin(xp, p, reps)
  305.     XParms  xp;
  306.     Parms   p;
  307.     int     reps;
  308. {
  309.     CopyArea(xp, p, reps, xp->w, xp->w);
  310. }
  311.  
  312. void DoCopyPixWin(xp, p, reps)
  313.     XParms  xp;
  314.     Parms   p;
  315.     int     reps;
  316. {
  317.     CopyArea(xp, p, reps, pix, xp->w);
  318. }
  319.  
  320. void DoCopyWinPix(xp, p, reps)
  321.     XParms  xp;
  322.     Parms   p;
  323.     int     reps;
  324. {
  325.     CopyArea(xp, p, reps, xp->w, pix);
  326. }
  327.  
  328. void DoCopyPixPix(xp, p, reps)
  329.     XParms  xp;
  330.     Parms   p;
  331.     int     reps;
  332. {
  333.     CopyArea(xp, p, reps, pix, pix);
  334. }
  335.  
  336. void DoGetImage(xp, p, reps)
  337.     XParms  xp;
  338.     Parms   p;
  339.     int     reps;
  340. {
  341.     int i, size;
  342.     XSegment *sa, *sb;
  343.  
  344.     size = p->special;
  345.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  346.     XDestroyImage(image);
  347.     image = XGetImage(xp->d, xp->w, sa->x1, sa->y1, size, size,
  348.         ~0, ZPixmap);
  349.     XDestroyImage(image);
  350.     image = XGetImage(xp->d, xp->w, sa->x2, sa->y2, size, size,
  351.         ~0, ZPixmap);
  352.     XDestroyImage(image);
  353.     image = XGetImage(xp->d, xp->w, sb->x2, sb->y2, size, size,
  354.         ~0, ZPixmap);
  355.     XDestroyImage(image);
  356.     image = XGetImage(xp->d, xp->w, sb->x1, sb->y1, size, size,
  357.         ~0, ZPixmap);
  358. /*
  359.  
  360. One might expect XGetSubImage to be slightly faster than XGetImage.  Go look
  361. at the code in Xlib.  MIT X11R3 ran approximately 30 times slower for a 500x500
  362. rectangle.
  363.  
  364.     (void) XGetSubImage(xp->d, xp->w, sa->x1, sa->y1, size, size,
  365.         ~0, ZPixmap, image, sa->x2, sa->y2);
  366.     (void) XGetSubImage(xp->d, xp->w, sa->x2, sa->y2, size, size,
  367.         ~0, ZPixmap, image, sa->x1, sa->y1);
  368.     (void) XGetSubImage(xp->d, xp->w, sb->x2, sb->y2, size, size,
  369.         ~0, ZPixmap, image, sb->x2, sb->y2);
  370.     (void) XGetSubImage(xp->d, xp->w, sb->x1, sb->y1, size, size,
  371.         ~0, ZPixmap, image, sb->x2, sb->y2);
  372. */
  373.     }
  374. }
  375.  
  376. void DoPutImage(xp, p, reps)
  377.     XParms  xp;
  378.     Parms   p;
  379.     int     reps;
  380. {
  381.     int i, size;
  382.     XSegment *sa, *sb;
  383.  
  384.     size = p->special;
  385.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  386.     XPutImage(xp->d, xp->w, xp->fggc, image,
  387.         sa->x1, sa->y1, sa->x2, sa->y2, size, size);
  388.     XPutImage(xp->d, xp->w, xp->fggc, image,
  389.         sa->x2, sa->y2, sa->x1, sa->y1, size, size);
  390.     XPutImage(xp->d, xp->w, xp->fggc, image,
  391.         sb->x2, sb->y2, sb->x2, sb->y2, size, size);
  392.     XPutImage(xp->d, xp->w, xp->fggc, image,
  393.         sb->x1, sb->y1, sb->x2, sb->y2, size, size);
  394.     }
  395. }
  396.  
  397. #ifdef MITSHM
  398. /* ||| This is included to measure the experimental MIT shared memory interface.
  399.        There are no guarantees that this interface will remain unchanged, but
  400.        then you know that if you'd turned on MITSHM anyway.
  401. */
  402.  
  403.  
  404. #include <sys/types.h>
  405. #include <sys/ipc.h>
  406. #include <sys/shm.h>
  407. #include <X11/extensions/XShm.h>
  408.  
  409. static XImage        shm_image;
  410. static XShmSegmentInfo    shminfo;
  411.  
  412. int InitShmPutImage (xp, p, reps)
  413.     XParms  xp;
  414.     Parms   p;
  415.     int     reps;
  416. {
  417.     int    image_size;
  418.  
  419.     (void) InitGetImage(xp, p);
  420.     XClearWindow(xp->d, xp->w);
  421.     shm_image = *image;
  422.     image_size = image->bytes_per_line * image->height;
  423.     shminfo.shmid = shmget(IPC_PRIVATE, image_size, IPC_CREAT|0777);
  424.     if (shminfo.shmid < 0)
  425.     {
  426.     perror ("shmget");
  427.     return False;
  428.     }
  429.     shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0);
  430.     if (shminfo.shmaddr == ((char *) -1))
  431.     {
  432.     perror ("shmat");
  433.     return False;
  434.     }
  435.     shminfo.readOnly = True;
  436.     XShmAttach (xp->d, &shminfo);
  437.     shm_image.data = shminfo.shmaddr;
  438.     bcopy (image->data, shm_image.data, image_size);
  439.     shm_image.obdata = (char *) &shminfo;
  440.     return reps;
  441. }
  442.  
  443. void DoShmPutImage(xp, p, reps)
  444.     XParms  xp;
  445.     Parms   p;
  446.     int     reps;
  447. {
  448.     int i, size;
  449.     XSegment *sa, *sb;
  450.  
  451.     size = p->special;
  452.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  453.     XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
  454.         sa->x1, sa->y1, sa->x2, sa->y2, size, size, False);
  455.     XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
  456.         sa->x2, sa->y2, sa->x1, sa->y1, size, size, False);
  457.     XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
  458.         sb->x2, sb->y2, sb->x2, sb->y2, size, size, False);
  459.     XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
  460.         sb->x1, sb->y1, sb->x2, sb->y2, size, size, False);
  461.     }
  462. }
  463.  
  464. void EndShmPutImage(xp, p)
  465.     XParms  xp;
  466.     Parms   p;
  467. {
  468.     void    EndGetImage();
  469.  
  470.     EndGetImage (xp, p);
  471.     shmdt (shminfo.shmaddr);
  472.     shmctl (shminfo.shmid, IPC_RMID, 0);
  473. }
  474.  
  475. #endif
  476.  
  477.  
  478. void MidCopyPix(xp, p)
  479.     XParms  xp;
  480.     Parms   p;
  481. {
  482.     XClearWindow(xp->d, xp->w);
  483. }
  484.  
  485. void EndCopyWin(xp, p)
  486.     XParms  xp;
  487.     Parms   p;
  488. {
  489.     EndScroll(xp, p);
  490.     free(segsa);
  491.     free(segsb);
  492. }
  493.  
  494. void EndCopyPix(xp, p)
  495.     XParms  xp;
  496.     Parms   p;
  497. {
  498.     EndCopyWin(xp, p);
  499.     XFreePixmap(xp->d, pix);
  500. }
  501.  
  502. void EndGetImage(xp, p)
  503.     XParms  xp;
  504.     Parms   p;
  505. {
  506.     EndCopyWin(xp, p);
  507.     XDestroyImage(image);
  508. }
  509.  
  510. Bool InitCopyPlane(xp, p, reps)
  511.     XParms  xp;
  512.     Parms   p;
  513.     int     reps;
  514. {
  515.     int        i;
  516.     XGCValues   gcv;
  517.     GC        pixgc;
  518.  
  519.     for (i = 0; i != NUMPOINTS; i++) {    
  520.         points[i].x = rand() % WIDTH;
  521.         points[i].y = rand() % HEIGHT;
  522.     }
  523.     InitCopyLocations(xp, p, reps);
  524.  
  525.     /* Create bitmap to write stuff into, and initialize it */
  526.     pix = XCreatePixmap(xp->d, xp->w, WIDTH, HEIGHT, 1);
  527.     gcv.graphics_exposures = False;
  528.     gcv.foreground = 0;
  529.     gcv.background = 1;
  530.     pixgc = XCreateGC(xp->d, pix, 
  531.         GCForeground | GCBackground | GCGraphicsExposures, &gcv);
  532.     XFillRectangle(xp->d, pix, pixgc, 0, 0, WIDTH, HEIGHT);
  533.     gcv.foreground = 1;
  534.     gcv.background = 0;
  535.     XChangeGC(xp->d, pixgc, GCForeground | GCBackground, &gcv);
  536.     XDrawLines(xp->d, pix, pixgc, points, NUMPOINTS, CoordModeOrigin);
  537.     XFreeGC(xp->d, pixgc);
  538.  
  539.     return reps;
  540. }
  541.  
  542. void DoCopyPlane(xp, p, reps)
  543.     XParms  xp;
  544.     Parms   p;
  545.     int     reps;
  546. {
  547.     int        i, size;
  548.     XSegment    *sa, *sb;
  549.  
  550.     size = p->special;
  551.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  552.     XCopyPlane(xp->d, pix, xp->w, xp->fggc,
  553.         sa->x1, sa->y1, size, size, sa->x2, sa->y2, 1);
  554.     XCopyPlane(xp->d, pix, xp->w, xp->fggc,
  555.         sa->x2, sa->y2, size, size, sa->x1, sa->y1, 1);
  556.     XCopyPlane(xp->d, pix, xp->w, xp->fggc,
  557.         sb->x2, sb->y2, size, size, sb->x1, sb->y1, 1);
  558.     XCopyPlane(xp->d, pix, xp->w, xp->fggc,
  559.         sb->x1, sb->y1, size, size, sb->x2, sb->y2, 1);
  560.     }
  561. }
  562.  
  563. @
  564.  
  565.  
  566. 2.8
  567. log
  568. @Changed interface to p->reps
  569. @
  570. text
  571. @d96 1
  572. a96 1
  573. void InitCopyLocations(xp, p, reps)
  574. d158 1
  575. a158 1
  576. int InitCopyArea(xp, p, reps)
  577. d173 1
  578. a173 1
  579.     (void) InitCopyArea(xp, p, reps);
  580. a178 1
  581.     XClearWindow(xp->d, xp->w);
  582. d187 1
  583. a187 1
  584.     (void) InitCopyArea(xp, p, reps);
  585. d204 1
  586. a204 1
  587. void DoCopyArea(xp, p, reps)
  588. d208 1
  589. d215 1
  590. a215 1
  591.     XCopyArea(xp->d, xp->w, xp->w, xp->fggc,
  592. d217 1
  593. a217 1
  594.     XCopyArea(xp->d, xp->w, xp->w, xp->fggc,
  595. d219 1
  596. a219 1
  597.     XCopyArea(xp->d, xp->w, xp->w, xp->fggc,
  598. d221 1
  599. a221 1
  600.     XCopyArea(xp->d, xp->w, xp->w, xp->fggc,
  601. d226 1
  602. a226 1
  603. void DoCopyPix(xp, p, reps)
  604. d231 2
  605. a232 2
  606.     int i, size;
  607.     XSegment *sa, *sb;
  608. d234 6
  609. a239 11
  610.     size = p->special;
  611.     for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
  612.     XCopyArea(xp->d, pix, xp->w, xp->fggc,
  613.         sa->x1, sa->y1, size, size, sa->x2, sa->y2);
  614.     XCopyArea(xp->d, pix, xp->w, xp->fggc,
  615.         sa->x2, sa->y2, size, size, sa->x1, sa->y1);
  616.     XCopyArea(xp->d, pix, xp->w, xp->fggc,
  617.         sb->x2, sb->y2, size, size, sb->x1, sb->y1);
  618.     XCopyArea(xp->d, pix, xp->w, xp->fggc,
  619.         sb->x1, sb->y1, size, size, sb->x2, sb->y2);
  620.     }
  621. d242 16
  622. d407 1
  623. a407 1
  624. void EndCopyArea(xp, p)
  625. d420 1
  626. a420 1
  627.     EndCopyArea(xp, p);
  628. d428 1
  629. a428 1
  630.     EndCopyArea(xp, p);
  631. @
  632.  
  633.  
  634. 2.7
  635. log
  636. @Added MIT shared-memory benchmarks
  637. @
  638. text
  639. @d35 1
  640. a35 1
  641. Bool InitScrolling(xp, p)
  642. d38 1
  643. d47 1
  644. a47 1
  645.     return True;
  646. d50 1
  647. a50 1
  648. void DoScrolling(xp, p)
  649. d53 1
  650. d61 1
  651. a61 1
  652.     for (i = 0; i != p->reps; i++) {
  653. d90 1
  654. a90 1
  655. void EndScrolling(xp, p)
  656. d96 1
  657. a96 1
  658. void InitCopyLocations(xp, p)
  659. d99 1
  660. d122 3
  661. a124 3
  662.     segsa = (XSegment *)malloc((p->reps) * sizeof(XSegment));
  663.     segsb = (XSegment *)malloc((p->reps) * sizeof(XSegment));
  664.     for (i = 0; i != p->reps; i++) {
  665. d158 1
  666. a158 1
  667. Bool InitCopyArea(xp, p)
  668. d161 1
  669. d163 3
  670. a165 3
  671.     (void) InitScrolling(xp, p);
  672.     InitCopyLocations(xp, p);
  673.     return True;
  674. d168 1
  675. a168 1
  676. Bool InitCopyPix(xp, p)
  677. d171 1
  678. d173 1
  679. a173 1
  680.     (void) InitCopyArea(xp, p);
  681. d180 1
  682. a180 1
  683.     return True;
  684. d183 1
  685. a183 1
  686. Bool InitGetImage(xp, p)
  687. d186 1
  688. d188 1
  689. a188 1
  690.     (void) InitCopyArea(xp, p);
  691. d192 1
  692. a192 1
  693.     return True;
  694. d195 1
  695. a195 1
  696. Bool InitPutImage(xp, p)
  697. d198 1
  698. d200 1
  699. a200 1
  700.     (void) InitGetImage(xp, p);
  701. d202 1
  702. a202 1
  703.     return True;
  704. d205 1
  705. a205 1
  706. void DoCopyArea(xp, p)
  707. d208 1
  708. d214 1
  709. a214 1
  710.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  711. d226 1
  712. a226 1
  713. void DoCopyPix(xp, p)
  714. d229 1
  715. d235 1
  716. a235 1
  717.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  718. d247 1
  719. a247 1
  720. void DoGetImage(xp, p)
  721. d250 1
  722. d256 1
  723. a256 1
  724.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  725. d287 1
  726. a287 1
  727. void DoPutImage(xp, p)
  728. d290 1
  729. d296 1
  730. a296 1
  731.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  732. d323 1
  733. a323 1
  734. Bool InitShmPutImage (xp, p)
  735. d326 1
  736. d351 1
  737. a351 1
  738.     return True;
  739. d354 1
  740. a354 1
  741. void DoShmPutImage(xp, p)
  742. d357 1
  743. d363 1
  744. a363 1
  745.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  746. d400 1
  747. a400 1
  748.     EndScrolling(xp, p);
  749. d421 1
  750. a421 1
  751. Bool InitCopyPlane(xp, p)
  752. d424 1
  753. d434 1
  754. a434 1
  755.     InitCopyLocations(xp, p);
  756. d450 1
  757. a450 1
  758.     return True;
  759. d453 1
  760. a453 1
  761. void DoCopyPlane(xp, p)
  762. d456 1
  763. d462 1
  764. a462 1
  765.     for (sa = segsa, sb = segsb, i = 0; i != p->reps; i++, sa++, sb++) {
  766. @
  767.  
  768.  
  769. 2.6
  770. log
  771. @Fixed gcs to turn of graphics_exposures, which means we don't get zillions
  772. of NoExpose events.
  773. @
  774. text
  775. @d297 79
  776. @
  777.  
  778.  
  779. 2.5
  780. log
  781. @Parameters to all routines now (xp, p)
  782. MAXROWS used in all routines
  783. Junked most global communication variables
  784. @
  785. text
  786. @d345 1
  787. d348 2
  788. a349 1
  789.     pixgc = XCreateGC(xp->d, pix, GCForeground | GCBackground, &gcv);
  790. @
  791.  
  792.  
  793. 2.4
  794. log
  795. @Simplified; copyplane code moved into here
  796. @
  797. text
  798. @d1 23
  799. d28 4
  800. a31 5
  801. static GC bggc, fggc;
  802. static Window w;
  803. static Pixmap pix;
  804. static  XPoint points[NUMPOINTS];
  805. static  XSegment *segsa, *segsb;
  806. d35 3
  807. a37 3
  808. Bool InitScrolling(d, p)
  809.     Display *d;
  810.     Parms p;
  811. d41 1
  812. a41 1
  813.     for (i = 0; i < NUMPOINTS; i++) {    
  814. d45 1
  815. a45 2
  816.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
  817.     XDrawLines(d, w, fggc, points, NUMPOINTS, CoordModeOrigin);
  818. d49 3
  819. a51 3
  820. void DoScrolling(d, p)
  821.     Display *d;
  822.     Parms p;
  823. d53 1
  824. a53 1
  825.     int i;
  826. d55 22
  827. a76 2
  828.     for (i=0; i<p->reps; i++) {
  829.     XCopyArea(d, w, w, fggc, 0, 1, WIDTH, HEIGHT - 1, 0, 0);
  830. d80 3
  831. a82 3
  832. void MidScroll(d, p)
  833.     Display *d;
  834.     Parms p;
  835. d84 2
  836. a85 2
  837.     XClearArea(d, w, 0, 0, WIDTH, HEIGHT, False);
  838.     XDrawLines(d, w, fggc, points, NUMPOINTS, CoordModeOrigin);
  839. d88 3
  840. a90 3
  841. void EndScrolling(d, p)
  842.     Display *d;
  843.     Parms p;
  844. a91 3
  845.     XDestroyWindow(d, w);
  846.     XFreeGC(d, bggc);
  847.     XFreeGC(d, fggc);
  848. d94 3
  849. a96 3
  850. void InitCopyLocations(d, p)
  851.     Display *d;
  852.     Parms p;
  853. d121 1
  854. a121 1
  855.     for (i=0; i<p->reps; i++) {
  856. d155 3
  857. a157 3
  858. Bool InitCopyArea(d, p)
  859.     Display *d;
  860.     Parms p;
  861. d159 2
  862. a160 2
  863.     (void) InitScrolling(d, p);
  864.     InitCopyLocations(d, p);
  865. d164 3
  866. a166 3
  867. Bool InitCopyArea2(d, p)
  868.     Display *d;
  869.     Parms p;
  870. d168 1
  871. a168 1
  872.     (void) InitCopyArea(d, p);
  873. d171 4
  874. a174 3
  875.     pix = XCreatePixmap(d, w, WIDTH, HEIGHT, DefaultDepth(d, DefaultScreen(d)));
  876.     XCopyArea(d, w, pix, fggc, 0, 0, WIDTH, HEIGHT, 0, 0);
  877.     XFillRectangle(d, w, bggc, 0, 0, WIDTH, HEIGHT);
  878. d178 3
  879. a180 3
  880. void DoCopyArea(d, p)
  881.     Display *d;
  882.     Parms p;
  883. d182 20
  884. d206 9
  885. a214 5
  886.     for (sa = segsa, sb = segsb, i=0; i<p->reps; i++, sa++, sb++) {
  887.     XCopyArea(d, w, w, fggc, sa->x1, sa->y1, size, size, sa->x2, sa->y2);
  888.     XCopyArea(d, w, w, fggc, sa->x2, sa->y2, size, size, sa->x1, sa->y1);
  889.     XCopyArea(d, w, w, fggc, sb->x2, sb->y2, size, size, sb->x1, sb->y1);
  890.     XCopyArea(d, w, w, fggc, sb->x1, sb->y1, size, size, sb->x2, sb->y2);
  891. d218 3
  892. a220 3
  893. void DoCopyArea2(d, p)
  894.     Display *d;
  895.     Parms p;
  896. d226 9
  897. a234 5
  898.     for (sa = segsa, sb = segsb, i=0; i<p->reps; i++, sa++, sb++) {
  899.     XCopyArea(d, pix, w, fggc, sa->x1, sa->y1, size, size, sa->x2, sa->y2);
  900.     XCopyArea(d, pix, w, fggc, sa->x2, sa->y2, size, size, sa->x1, sa->y1);
  901.     XCopyArea(d, pix, w, fggc, sb->x2, sb->y2, size, size, sb->x1, sb->y1);
  902.     XCopyArea(d, pix, w, fggc, sb->x1, sb->y1, size, size, sb->x2, sb->y2);
  903. d238 3
  904. a240 3
  905. void MidCopyArea2(d, p)
  906.     Display *d;
  907.     Parms p;
  908. d242 33
  909. a274 1
  910.     XClearArea(d, w, 0, 0, WIDTH, HEIGHT, False);
  911. d277 3
  912. a279 3
  913. void EndCopyArea(d, p)
  914.     Display *d;
  915.     Parms p;
  916. d281 28
  917. a308 1
  918.     EndScrolling(d, w);
  919. d313 3
  920. a315 3
  921. void EndCopyArea2(d, p)
  922.     Display *d;
  923.     Parms p;
  924. d317 2
  925. a318 2
  926.     EndCopyArea(d, p);
  927.     XFreePixmap(d, pix);
  928. d321 3
  929. a323 3
  930. Bool InitCopyPlane(d, p)
  931.     Display *d;
  932.     Parms p;
  933. d325 3
  934. a327 3
  935.     int i;
  936.     XGCValues gcv;
  937.     GC      pixgc;
  938. d329 9
  939. a337 1
  940.     for (i = 0; i < NUMPOINTS; i++) {    
  941. d341 1
  942. a341 2
  943.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
  944.     InitCopyLocations(d, p);
  945. d344 1
  946. a344 1
  947.     pix = XCreatePixmap(d, w, WIDTH, HEIGHT, 1);
  948. d347 2
  949. a348 2
  950.     pixgc = XCreateGC(d, pix, GCForeground | GCBackground, &gcv);
  951.     XFillRectangle(d, pix, pixgc, 0, 0, WIDTH, HEIGHT);
  952. d351 3
  953. a353 3
  954.     XChangeGC(d, pixgc, GCForeground | GCBackground, &gcv);
  955.     XDrawLines(d, pix, pixgc, points, NUMPOINTS, CoordModeOrigin);
  956.     XFreeGC(d, pixgc);
  957. d358 3
  958. a360 3
  959. void DoCopyPlane(d, p)
  960.     Display *d;
  961.     Parms p;
  962. d362 2
  963. a363 2
  964.     int i, size;
  965.     XSegment *sa, *sb;
  966. d366 9
  967. a374 9
  968.     for (sa = segsa, sb = segsb, i=0; i<p->reps; i++, sa++, sb++) {
  969.     XCopyPlane(
  970.         d, pix, w, fggc, sa->x1, sa->y1, size, size, sa->x2, sa->y2, 1);
  971.     XCopyPlane(
  972.         d, pix, w, fggc, sa->x2, sa->y2, size, size, sa->x1, sa->y1, 1);
  973.     XCopyPlane(
  974.         d, pix, w, fggc, sb->x2, sb->y2, size, size, sb->x1, sb->y1, 1);
  975.     XCopyPlane(
  976.         d, pix, w, fggc, sb->x1, sb->y1, size, size, sb->x2, sb->y2, 1);
  977. @
  978.  
  979.  
  980. 2.3
  981. log
  982. @Create pixmap using default depth, not hardwired 8
  983. @
  984. text
  985. @d13 43
  986. d121 1
  987. a121 10
  988.     int i;
  989.  
  990.     w = None;
  991.     for (i = 0; i < NUMPOINTS; i++)
  992.     {    
  993.         points[i].x = rand() % WIDTH;
  994.         points[i].y = rand() % HEIGHT;
  995.     }
  996.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
  997.     XDrawLines(d, w, fggc, points, NUMPOINTS, CoordModeOrigin);
  998. a122 2
  999.  
  1000.     XSync(d, 0);    
  1001. d130 1
  1002. a130 1
  1003.     int i;
  1004. d132 1
  1005. a132 10
  1006.     w = None;
  1007.     i = 0;
  1008.     for (i = 0; i < NUMPOINTS; i++)
  1009.     {    
  1010.         points[i].x = rand() % WIDTH;
  1011.         points[i].y = rand() % HEIGHT;
  1012.     }
  1013.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
  1014.  
  1015.     /* Create depth-8 pixmap to write stuff into, and clear it out */
  1016. d134 2
  1017. a135 5
  1018.     XFillRectangle(d, pix, bggc, 0, 0, WIDTH, HEIGHT);
  1019.     XDrawLines(d, pix, fggc, points, NUMPOINTS, CoordModeOrigin);
  1020.     InitCopyLocations(d, p);
  1021.  
  1022.     XSync(d, 0);    
  1023. a170 9
  1024. void MidCopyArea(d, p)
  1025.     Display *d;
  1026.     Parms p;
  1027. {
  1028.     XClearArea(d, w, 0, 0, WIDTH, HEIGHT, False);
  1029.     XDrawLines(d, w, fggc, points, NUMPOINTS, CoordModeOrigin);
  1030.     XSync(d, 0);    
  1031. }
  1032.  
  1033. a175 1
  1034.     XSync(d, 0);    
  1035. d182 1
  1036. a182 4
  1037.     if (w != None)
  1038.         XDestroyWindow(d, w);
  1039.     XFreeGC(d, bggc);
  1040.     XFreeGC(d, fggc);
  1041. d192 51
  1042. a242 2
  1043.     if (pix != None)
  1044.         XFreePixmap(d, pix);
  1045. @
  1046.  
  1047.  
  1048. 2.2
  1049. log
  1050. @Don't need stdio.h
  1051. @
  1052. text
  1053. @a7 9
  1054. static XRectangle pixrect[] = {
  1055.     0, 0, WIDTH, HEIGHT
  1056. };
  1057.  
  1058. static XRectangle ws[3] = {
  1059.     {100, 100, 200, 200},
  1060.     {150, 150, 200, 200},
  1061.     {200, 200, 200, 200}
  1062.   };
  1063. d110 2
  1064. a111 2
  1065.     pix = XCreatePixmap(d, w, 800, HEIGHT, 8);
  1066.     XFillRectangles(d, pix, bggc, pixrect, 1);
  1067. @
  1068.  
  1069.  
  1070. 2.1
  1071. log
  1072. @Massive changes, I'm not going to go into details.
  1073. @
  1074. text
  1075. @a1 1
  1076. #include <stdio.h>
  1077. @
  1078.  
  1079.  
  1080. 2.0
  1081. log
  1082. @version from /usr/src/pmax
  1083. @
  1084. text
  1085. @d2 1
  1086. d8 5
  1087. d19 1
  1088. d21 3
  1089. a23 1
  1090. void InitCopyArea(d, p)
  1091. d27 61
  1092. a88 1
  1093.     XGCValues gcv;
  1094. a90 1
  1095.     i = 0;
  1096. d98 2
  1097. d101 1
  1098. d104 1
  1099. a104 1
  1100. void DoCopyArea(d, p)
  1101. d110 6
  1102. a115 6
  1103.     
  1104.     for (i=0; i<p->reps; i++)
  1105.     {
  1106.     
  1107.         XCopyArea(d, w, w, fggc, rand() % WIDTH, rand() % HEIGHT,
  1108.         200, 200, rand() % WIDTH, rand() % HEIGHT);
  1109. d117 10
  1110. d129 32
  1111. d165 1
  1112. d170 8
  1113. a181 1
  1114.     int i;
  1115. d186 11
  1116. @
  1117.  
  1118.  
  1119. 1.2
  1120. log
  1121. @Added -fg -bg capabilities
  1122. @
  1123. text
  1124. @@
  1125.  
  1126.  
  1127. 1.1
  1128. log
  1129. @Initial revision
  1130. @
  1131. text
  1132. @d5 1
  1133. a5 1
  1134. static GC whitegc, blackgc;
  1135. d28 2
  1136. a29 2
  1137.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &whitegc, &blackgc);
  1138.     XDrawLines(d, w, blackgc, points, NUMPOINTS, CoordModeOrigin);
  1139. d43 1
  1140. a43 1
  1141.         XCopyArea(d, w, w, blackgc, rand() % WIDTH, rand() % HEIGHT,
  1142. d52 1
  1143. a52 1
  1144.     XDrawLines(d, w, blackgc, points, NUMPOINTS, CoordModeOrigin);
  1145. d63 2
  1146. a64 2
  1147.     XFreeGC(d, whitegc);
  1148.     XFreeGC(d, blackgc);
  1149. @
  1150.