generic.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __GENERIC_H__
  24. #define __GENERIC_H__
  25. #include <dfb_types.h>
  26. #include <directfb.h>
  27. #include <core/coretypes.h>
  28. #include <core/gfxcard.h>
  29. /* this order is required for Intel with MMX, how about bigendian? */
  30. typedef union {
  31. struct {
  32. u16 b;
  33. u16 g;
  34. u16 r;
  35. u16 a;
  36. } RGB;
  37. struct {
  38. u16 u;
  39. u16 v;
  40. u16 y;
  41. u16 a;
  42. } YUV;
  43. } GenefxAccumulator;
  44. typedef struct _GenefxState GenefxState;
  45. typedef void (*GenefxFunc)(GenefxState *gfxs);
  46. /*
  47. * State of the virtual graphics processing unit "Genefx" (pron. 'genie facts').
  48. */
  49. struct _GenefxState {
  50. GenefxFunc funcs[32];
  51. int length; /* span length */
  52. int Slen; /* span length (source) */
  53. int Dlen; /* span length (destination) */
  54. /*
  55. * state values
  56. */
  57. void *dst_org[3];
  58. void *src_org[3];
  59. int dst_pitch;
  60. int src_pitch;
  61. int dst_bpp;
  62. int src_bpp;
  63. DFBSurfaceCapabilities dst_caps;
  64. DFBSurfaceCapabilities src_caps;
  65. DFBSurfacePixelFormat src_format;
  66. DFBSurfacePixelFormat dst_format;
  67. int dst_height;
  68. int src_height;
  69. int dst_field_offset;
  70. int src_field_offset;
  71. DFBColor color;
  72. /*
  73. * operands
  74. */
  75. void *Aop[3];
  76. void *Bop[3];
  77. u32 Cop;
  78. int Astep;
  79. int Bstep;
  80. u8 YCop;
  81. u8 CbCop;
  82. u8 CrCop;
  83. int Aop_field;
  84. int Bop_field;
  85. int AopY;
  86. int BopY;
  87. int s;
  88. int t;
  89. /*
  90. * color keys
  91. */
  92. u32 Dkey;
  93. u32 Skey;
  94. /*
  95. * color lookup tables
  96. */
  97. CorePalette *Alut;
  98. CorePalette *Blut;
  99. /*
  100. * accumulators
  101. */
  102. void *ABstart;
  103. int ABsize;
  104. GenefxAccumulator *Aacc;
  105. GenefxAccumulator *Bacc;
  106. GenefxAccumulator *Tacc; /* for simultaneous S+D blending */
  107. GenefxAccumulator Cacc;
  108. GenefxAccumulator SCacc;
  109. /*
  110. * dataflow control
  111. */
  112. GenefxAccumulator *Xacc; /* writing pointer for blending */
  113. GenefxAccumulator *Yacc; /* input pointer for blending */
  114. GenefxAccumulator *Dacc;
  115. GenefxAccumulator *Sacc;
  116. void **Sop;
  117. CorePalette *Slut;
  118. int Ostep; /* controls horizontal blitting direction */
  119. int SperD; /* for scaled/texture routines only */
  120. int TperD; /* for texture routines only */
  121. int Xphase; /* initial value for fractional steps (zero if not clipped) */
  122. bool need_accumulator;
  123. int *trans;
  124. int num_trans;
  125. };
  126. /**********************************************************************************************************************/
  127. typedef struct {
  128. int x;
  129. int y;
  130. int s;
  131. int t;
  132. } GenefxVertexAffine;
  133. /**********************************************************************************************************************/
  134. void gGetDriverInfo( GraphicsDriverInfo *info );
  135. void gGetDeviceInfo( GraphicsDeviceInfo *info );
  136. bool gAcquire ( CardState *state, DFBAccelerationMask accel );
  137. void gRelease ( CardState *state );
  138. void gFillRectangle ( CardState *state, DFBRectangle *rect );
  139. void gDrawLine ( CardState *state, DFBRegion *line );
  140. void gBlit ( CardState *state, DFBRectangle *rect, int dx, int dy );
  141. void gStretchBlit ( CardState *state, DFBRectangle *srect, DFBRectangle *drect );
  142. void Genefx_TextureTriangles( CardState *state,
  143. DFBVertex *vertices,
  144. int num,
  145. DFBTriangleFormation formation,
  146. const DFBRegion *clip );
  147. void Genefx_TextureTrianglesAffine( CardState *state,
  148. GenefxVertexAffine *vertices,
  149. int num,
  150. DFBTriangleFormation formation,
  151. const DFBRegion *clip );
  152. /**********************************************************************************************************************/
  153. /**********************************************************************************************************************/
  154. void Genefx_TextureTriangleAffine( GenefxState *gfxs,
  155. GenefxVertexAffine *v0,
  156. GenefxVertexAffine *v1,
  157. GenefxVertexAffine *v2,
  158. const DFBRegion *clip );
  159. /**********************************************************************************************************************/
  160. /**********************************************************************************************************************/
  161. #define CHECK_PIPELINE() \
  162. { \
  163. if (!gfxs->funcs[0]) \
  164. return; \
  165. \
  166. if (dfb_config->software_trace) { \
  167. int i; \
  168. GenefxFunc *funcs = gfxs->funcs; \
  169. \
  170. direct_log_lock( NULL ); \
  171. direct_log_printf( NULL, " Software Fallback Pipeline:\n" ); \
  172. \
  173. for (i=0; funcs[i]; ++i) \
  174. direct_log_printf( NULL, " [%2d] %s\n", i, \
  175. direct_trace_lookup_symbol_at( funcs[i] ) ); \
  176. \
  177. direct_log_printf( NULL, "\n" ); \
  178. direct_log_unlock( NULL ); \
  179. } \
  180. }
  181. #define RUN_PIPELINE() \
  182. { \
  183. int i; \
  184. GenefxFunc *funcs = gfxs->funcs; \
  185. \
  186. for (i=0; funcs[i]; ++i) \
  187. funcs[i]( gfxs ); \
  188. }
  189. /**********************************************************************************************************************/
  190. typedef void (*XopAdvanceFunc)( GenefxState *gfxs );
  191. void Genefx_Aop_xy( GenefxState *gfxs, int x, int y );
  192. void Genefx_Aop_crab( GenefxState *gfxs );
  193. void Genefx_Aop_next( GenefxState *gfxs );
  194. void Genefx_Aop_prev( GenefxState *gfxs );
  195. void Genefx_Bop_xy( GenefxState *gfxs, int x, int y );
  196. void Genefx_Bop_next( GenefxState *gfxs );
  197. void Genefx_Bop_prev( GenefxState *gfxs );
  198. /**********************************************************************************************************************/
  199. bool Genefx_ABacc_prepare( GenefxState *gfxs, int width );
  200. void Genefx_ABacc_flush( GenefxState *gfxs );
  201. #endif