Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: zippy.c
  3. *
  4. * Triangle drawing fast path.
  5. *
  6. * 28-Oct-1994 mikeke Created
  7. *
  8. * Copyright (c) 1994 Microsoft Corporation
  9. \**************************************************************************/
  10. /*
  11. ** Copyright 1991, 1992, 1993, Silicon Graphics, Inc.
  12. ** All Rights Reserved.
  13. **
  14. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  15. ** the contents of this file may not be disclosed to third parties, copied or
  16. ** duplicated in any form, in whole or in part, without the prior written
  17. ** permission of Silicon Graphics, Inc.
  18. **
  19. ** RESTRICTED RIGHTS LEGEND:
  20. ** Use, duplication or disclosure by the Government is subject to restrictions
  21. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  22. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  23. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  24. ** rights reserved under the Copyright Laws of the United States.
  25. */
  26. #include "precomp.h"
  27. #pragma hdrstop
  28. /**************************************************************************\
  29. *
  30. * Subtriangle functions
  31. *
  32. \**************************************************************************/
  33. #define TEXTURE 1
  34. #define SHADE 1
  35. #define ZBUFFER 1
  36. #include "zippy.h"
  37. #undef ZBUFFER
  38. #define ZBUFFER 0
  39. #include "zippy.h"
  40. #undef SHADE
  41. #define SHADE 0
  42. #include "zippy.h"
  43. #undef TEXTURE
  44. #define TEXTURE 0
  45. #undef SHADE
  46. #define SHADE 1
  47. #include "zippy.h"
  48. #undef SHADE
  49. #define SHADE 0
  50. #include "zippy.h"
  51. /**************************************************************************\
  52. *
  53. * Flat subtriangle function
  54. *
  55. \**************************************************************************/
  56. void FASTCALL
  57. __ZippyFSTCI8Flat
  58. (__GLcontext *gc, GLint iyBottom, GLint iyTop)
  59. {
  60. __GLGENcontext *gengc = (__GLGENcontext *)gc;
  61. GENACCEL *pGenAccel = (GENACCEL *)(gengc->pPrivateArea);
  62. int scansize;
  63. ULONG color1;
  64. //
  65. // this function assumes all this stuff
  66. //
  67. ASSERTOPENGL((gc->drawBuffer->buf.flags & DIB_FORMAT) != 0,
  68. "Zippy target must have DIB format\n");
  69. ASSERTOPENGL((gc->drawBuffer->buf.flags & NO_CLIP) != 0,
  70. "Zippy doesn't support per-pixel clipping\n");
  71. ASSERTOPENGL(gc->state.raster.drawBuffer != GL_FRONT_AND_BACK,
  72. "Zippy only handles one draw buffer\n");
  73. ASSERTOPENGL(gc->transform.reasonableViewport,
  74. "Zippy requires reasonableViewport\n");
  75. ASSERTOPENGL(gc->transform.clipY0 <= iyBottom,
  76. "Zippy requires unclipped area\n");
  77. ASSERTOPENGL(iyTop <= gc->transform.clipY1,
  78. "Zippy requires unclipped area\n");
  79. //
  80. // calculate the color
  81. //
  82. color1 = gengc->pajTranslateVector[
  83. ((pGenAccel->spanValue.r + 0x0800) >> 16) & 0xff
  84. ];
  85. //
  86. // render the spans
  87. //
  88. scansize = gc->polygon.shader.cfb->buf.outerWidth;
  89. gc->polygon.shader.frag.x = gc->polygon.shader.ixLeft;
  90. for (gc->polygon.shader.frag.y = iyBottom;
  91. gc->polygon.shader.frag.y != iyTop;
  92. gc->polygon.shader.frag.y++
  93. ) {
  94. GLint spanWidth = gc->polygon.shader.ixRight - gc->polygon.shader.frag.x;
  95. if (spanWidth > 0) {
  96. RtlFillMemory(
  97. pGenAccel->pPix + gengc->gc.polygon.shader.frag.x,
  98. spanWidth,
  99. color1);
  100. }
  101. pGenAccel->pPix += scansize;
  102. gc->polygon.shader.ixRightFrac += gc->polygon.shader.dxRightFrac;
  103. if (gc->polygon.shader.ixRightFrac < 0) {
  104. /*
  105. * Carry/Borrow'd. Use large step
  106. */
  107. gc->polygon.shader.ixRight += gc->polygon.shader.dxRightBig;
  108. gc->polygon.shader.ixRightFrac &= ~0x80000000;
  109. } else {
  110. gc->polygon.shader.ixRight += gc->polygon.shader.dxRightLittle;
  111. }
  112. gc->polygon.shader.ixLeftFrac += gc->polygon.shader.dxLeftFrac;
  113. if (gc->polygon.shader.ixLeftFrac < 0) {
  114. /*
  115. * Carry/Borrow'd. Use large step
  116. */
  117. gc->polygon.shader.frag.x += gc->polygon.shader.dxLeftBig;
  118. gc->polygon.shader.ixLeftFrac &= ~0x80000000;
  119. } else {
  120. /*
  121. * Use small step
  122. */
  123. gc->polygon.shader.frag.x += gc->polygon.shader.dxLeftLittle;
  124. }
  125. }
  126. gc->polygon.shader.ixLeft = gc->polygon.shader.frag.x;
  127. }