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_plane.c,v < prev    next >
Text File  |  1989-05-09  |  4KB  |  222 lines

  1. head     2.2;
  2. access   ;
  3. symbols  pre-merge:2.0;
  4. locks    ; strict;
  5. comment  @ * @;
  6.  
  7.  
  8. 2.2
  9. date     89.05.08.18.33.45;  author joel;  state Exp;
  10. branches ;
  11. next     2.1;
  12.  
  13. 2.1
  14. date     89.05.03.14.17.45;  author joel;  state Exp;
  15. branches ;
  16. next     2.0;
  17.  
  18. 2.0
  19. date     89.01.31.17.04.41;  author erik;  state Exp;
  20. branches ;
  21. next     1.3;
  22.  
  23. 1.3
  24. date     89.01.31.17.04.41;  author joel;  state Exp;
  25. branches ;
  26. next     1.2;
  27.  
  28. 1.2
  29. date     89.01.05.18.28.38;  author joel;  state Exp;
  30. branches ;
  31. next     1.1;
  32.  
  33. 1.1
  34. date     88.12.15.13.40.59;  author joel;  state Exp;
  35. branches ;
  36. next     ;
  37.  
  38.  
  39. desc
  40. @CopyPlane benchmark code
  41. @
  42.  
  43.  
  44. 2.2
  45. log
  46. @Code merged into do_copyarea.c
  47. @
  48. text
  49. @@
  50.  
  51.  
  52. 2.1
  53. log
  54. @Massive changes, I'm not going to go into details.
  55. @
  56. text
  57. @a0 105
  58. #include "x11perf.h"
  59.  
  60. static Window w;
  61. static char **charBuf = NULL;
  62. static GC fggc, bggc;
  63. static XFontStruct *font;
  64. static int height, ypos, lines;
  65. static Pixmap pixmap;
  66.  
  67. #define XPOS 20
  68. #define SEGMENTS 3
  69. #define STARTBOLD 20
  70. #define NUMBOLD 20
  71.  
  72. #define max(why, me)    (((why) > (me)) ? why : me)
  73.  
  74. Bool InitCopyPlane(d, p)
  75.     Display *d;
  76.     Parms p;
  77. {
  78.     int     i, j;
  79.     XGCValues gcv;
  80.     GC      pixgc;
  81.  
  82.     font = XLoadQueryFont (d, p->font);
  83.     if (font == NULL) {
  84.     printf("Could not load font '%s', benchmark omitted\n", p->font);
  85.     return False;
  86.     }
  87.  
  88.     ypos = XPOS;
  89.     height = max(font->max_bounds.ascent, font->ascent) + 
  90.          max(font->max_bounds.descent, font->descent) + 1;
  91.     lines = (HEIGHT - ypos) / height;
  92.  
  93.     CreatePerfStuff (d, 1, 800, HEIGHT, &w, &bggc, &fggc);
  94.  
  95.     if (charBuf == NULL) {
  96.     charBuf = (char **) malloc(lines*sizeof (char *));
  97.     for (i = 0; i < lines; i++) {
  98.         charBuf[i] = (char *) malloc (sizeof (char)*CHARS);
  99.         for (j = 0; j < CHARS; j++) {
  100.         charBuf[i][j] = ' ' + (rand () % ('\177' - ' '));
  101.         }
  102.     }
  103.     }
  104.  
  105.     /* Create depth-1 pixmap to write stuff into */
  106.     pixmap = XCreatePixmap(d, w, 800, HEIGHT, 1);
  107.  
  108.     /* Create gc to go with it */
  109.     
  110.     gcv.foreground = 1;
  111.     gcv.background = 0;
  112.     gcv.font = font->fid;
  113.     pixgc = XCreateGC(d, pixmap,
  114.         GCForeground | GCBackground | GCFont, &gcv);
  115.     
  116.     /* Write text into the pixmap */
  117.     for (i = 0; i < lines; i++) {
  118.     XDrawString(d, pixmap, pixgc, XPOS, ypos, charBuf[i], CHARS);
  119.     ypos += height;
  120.     }
  121.     XFreeGC(d, pixgc);
  122.     return True;
  123. }
  124.  
  125. void DoCopyPlane(d, p)
  126.     Display *d;
  127.     Parms p;
  128. {
  129.     int     i;
  130.  
  131.     for (i = 0; i < p->reps; i++) {
  132.     XCopyPlane(d, pixmap, w, (i & 1) ? fggc : bggc,
  133.         0, 0, 800, HEIGHT, 
  134.         0, 0, 1);
  135. /* other configurations for making sure clipping works
  136.         20, 20, 800-40, HEIGHT-40,
  137.         20, 20, 1);
  138. */
  139. /*
  140.         -20, -20, 800-40, HEIGHT+40,
  141.         0, 0, 1);
  142. */
  143.     }
  144. }
  145.  
  146. void EndCopyPlane(d, p)
  147.     Display *d;
  148.     Parms p;
  149. {
  150.     int i;
  151.  
  152.     XDestroyWindow(d, w);
  153.     XFreePixmap(d, pixmap);
  154.     XFreeGC(d, fggc);
  155.     XFreeGC(d, bggc);
  156.     for (i = 0; i < lines; i++)
  157.     free(charBuf[i]);
  158.     free(charBuf);
  159.     charBuf = NULL;
  160.     XFreeFont(d, font);
  161. }
  162.  
  163. @
  164.  
  165.  
  166. 2.0
  167. log
  168. @version from /usr/src/pmax
  169. @
  170. text
  171. @d17 1
  172. a17 1
  173. void InitCopyPlane(d, p)
  174. d26 5
  175. d65 1
  176. d78 1
  177. a78 1
  178. /* other configurations for making sure clipping works still
  179. @
  180.  
  181.  
  182. 1.3
  183. log
  184. @Added -fg -bg capabilities
  185. @
  186. text
  187. @@
  188.  
  189.  
  190. 1.2
  191. log
  192. @Added a few weird cases that can be uncommented.
  193. @
  194. text
  195. @d5 1
  196. a5 1
  197. static GC blackgc, whitegc;
  198. d31 1
  199. a31 1
  200.     CreatePerfStuff (d, 1, 800, HEIGHT, &w, &whitegc, &blackgc);
  201. d48 2
  202. a49 2
  203.     gcv.foreground = 1 /* BlackPixel(d, 0) */;
  204.     gcv.background = 0 /* WhitePixel(d, 0) */;
  205. d69 1
  206. a69 1
  207.     XCopyPlane(d, pixmap, w, (i & 1) ? blackgc : whitegc,
  208. d91 2
  209. a92 2
  210.     XFreeGC(d, blackgc);
  211.     XFreeGC(d, whitegc);
  212. @
  213.  
  214.  
  215. 1.1
  216. log
  217. @Initial revision
  218. @
  219. text
  220. @d72 8
  221. @
  222.