home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / cfb / cfbrrop.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-10  |  5.5 KB  |  136 lines

  1. /*
  2.  * $XConsortium: cfbrrop.h,v 1.6 91/04/10 11:42:06 keith Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Keith Packard, MIT X Consortium
  24.  */
  25.  
  26. #ifndef GXcopy
  27. #include "X.h"
  28. #endif
  29.  
  30. #define RROP_FETCH_GC(gc) \
  31.     RROP_FETCH_GCPRIV(((cfbPrivGCPtr)(gc)->devPrivates[cfbGCPrivateIndex].ptr))
  32.  
  33. #ifndef RROP
  34. #define RROP GXset
  35. #endif
  36.  
  37. #if RROP == GXcopy
  38. #define RROP_DECLARE    register unsigned long    rrop_xor;
  39. #define RROP_FETCH_GCPRIV(devPriv)  rrop_xor = (devPriv)->xor;
  40. #define RROP_SOLID(dst)        (*(dst) = (rrop_xor))
  41. #define RROP_SOLID_MASK(dst,mask) (*(dst) = (*(dst) & ~(mask)) | ((rrop_xor) & (mask)))
  42. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,Copy)
  43. #endif
  44.  
  45. #if RROP == GXxor
  46. #define RROP_DECLARE    register unsigned long    rrop_xor;
  47. #define RROP_FETCH_GCPRIV(devPriv)  rrop_xor = (devPriv)->xor;
  48. #define RROP_SOLID(dst)        (*(dst) ^= (rrop_xor))
  49. #define RROP_SOLID_MASK(dst,mask) (*(dst) ^= ((rrop_xor) & (mask)))
  50. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,Xor)
  51. #endif
  52.  
  53. #if RROP == GXand
  54. #define RROP_DECLARE    register unsigned long    rrop_and;
  55. #define RROP_FETCH_GCPRIV(devPriv)  rrop_and = (devPriv)->and;
  56. #define RROP_SOLID(dst)        (*(dst) &= (rrop_and))
  57. #define RROP_SOLID_MASK(dst,mask) (*(dst) &= ((rrop_and) | ~(mask)))
  58. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,And)
  59. #endif
  60.  
  61. #if RROP == GXor
  62. #define RROP_DECLARE    register unsigned long    rrop_or;
  63. #define RROP_FETCH_GCPRIV(devPriv)  rrop_or = (devPriv)->xor;
  64. #define RROP_SOLID(dst)        (*(dst) |= (rrop_or))
  65. #define RROP_SOLID_MASK(dst,mask) (*(dst) |= ((rrop_or) & (mask)))
  66. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,Or)
  67. #endif
  68.  
  69. #if RROP == GXnoop
  70. #define RROP_DECLARE
  71. #define RROP_FETCH_GCPRIV(devPriv)
  72. #define RROP_SOLID(dst)
  73. #define RROP_SOLID_MASK(dst,mask)
  74. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,Noop)
  75. #endif
  76.  
  77. #if RROP ==  GXset
  78. #define RROP_DECLARE        register unsigned long    rrop_and, rrop_xor;
  79. #define RROP_FETCH_GCPRIV(devPriv)  rrop_and = (devPriv)->and; \
  80.                     rrop_xor = (devPriv)->xor;
  81. #define RROP_SOLID(dst)        (*(dst) = DoRRop (*(dst), rrop_and, rrop_xor))
  82. #define RROP_SOLID_MASK(dst,mask)   (*(dst) = DoMaskRRop (*(dst), rrop_and, rrop_xor, (mask)))
  83. #define RROP_NAME(prefix)   RROP_NAME_CAT(prefix,General)
  84. #endif
  85.  
  86. #define RROP_UNROLL_CASE1(p,i)    case (i): RROP_SOLID((p) - (i));
  87. #define RROP_UNROLL_CASE2(p,i)    RROP_UNROLL_CASE1(p,(i)+1) RROP_UNROLL_CASE1(p,i)
  88. #define RROP_UNROLL_CASE4(p,i)    RROP_UNROLL_CASE2(p,(i)+2) RROP_UNROLL_CASE2(p,i)
  89. #define RROP_UNROLL_CASE8(p,i)    RROP_UNROLL_CASE4(p,(i)+4) RROP_UNROLL_CASE4(p,i)
  90. #define RROP_UNROLL_CASE16(p,i)   RROP_UNROLL_CASE8(p,(i)+8) RROP_UNROLL_CASE8(p,i)
  91. #define RROP_UNROLL_CASE3(p)    RROP_UNROLL_CASE2(p,2) RROP_UNROLL_CASE1(p,1)
  92. #define RROP_UNROLL_CASE7(p)    RROP_UNROLL_CASE4(p,4) RROP_UNROLL_CASE3(p)
  93. #define RROP_UNROLL_CASE15(p)    RROP_UNROLL_CASE8(p,8) RROP_UNROLL_CASE7(p)
  94. #define RROP_UNROLL_CASE31(p)    RROP_UNROLL_CASE16(p,16) RROP_UNROLL_CASE15(p)
  95.  
  96. #define RROP_UNROLL_LOOP1(p,i) RROP_SOLID((p) + (i));
  97. #define RROP_UNROLL_LOOP2(p,i) RROP_UNROLL_LOOP1(p,(i)) RROP_UNROLL_LOOP1(p,(i)+1)
  98. #define RROP_UNROLL_LOOP4(p,i) RROP_UNROLL_LOOP2(p,(i)) RROP_UNROLL_LOOP2(p,(i)+2)
  99. #define RROP_UNROLL_LOOP8(p,i) RROP_UNROLL_LOOP4(p,(i)) RROP_UNROLL_LOOP4(p,(i)+4)
  100. #define RROP_UNROLL_LOOP16(p,i) RROP_UNROLL_LOOP8(p,(i)) RROP_UNROLL_LOOP8(p,(i)+8)
  101. #define RROP_UNROLL_LOOP32(p,i) RROP_UNROLL_LOOP16(p,(i)) RROP_UNROLL_LOOP16(p,(i)+16)
  102.  
  103. #if defined (FAST_CONSTANT_OFFSET_MODE) && defined (SHARED_IDCACHE) && (RROP == GXcopy)
  104.  
  105. #define RROP_UNROLL_SHIFT    5
  106. #define RROP_UNROLL        (1<<RROP_UNROLL_SHIFT)
  107. #define RROP_UNROLL_MASK    (RROP_UNROLL-1)
  108. #define RROP_UNROLL_CASE(p)    RROP_UNROLL_CASE31(p)
  109. #define RROP_UNROLL_LOOP(p)    RROP_UNROLL_LOOP32(p,-32)
  110.  
  111. #define RROP_SPAN(pdst,nmiddle) {\
  112.     int part = (nmiddle) & RROP_UNROLL_MASK; \
  113.     (nmiddle) >>= RROP_UNROLL_SHIFT; \
  114.     (pdst) += part * (sizeof (unsigned long) / sizeof (*pdst)); \
  115.     switch (part) {\
  116.     RROP_UNROLL_CASE((unsigned long *) (pdst)) \
  117.     } \
  118.     while (--(nmiddle) >= 0) { \
  119.     (pdst) += RROP_UNROLL * (sizeof (unsigned long) / sizeof (*pdst)); \
  120.     RROP_UNROLL_LOOP((unsigned long *) (pdst)) \
  121.     } \
  122. }
  123. #else
  124. #define RROP_SPAN(pdst,nmiddle) \
  125.     while (--(nmiddle) >= 0) { \
  126.     RROP_SOLID((unsigned long *) (pdst)); \
  127.     (pdst) += sizeof (unsigned long) / sizeof (*pdst); \
  128.     }
  129. #endif
  130.  
  131. #if __STDC__ && !defined(UNIXCPP)
  132. #define RROP_NAME_CAT(prefix,suffix)    prefix##suffix
  133. #else
  134. #define RROP_NAME_CAT(prefix,suffix)    prefix/**/suffix
  135. #endif
  136.