vscreen.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #include "../include/duck_dxl.h"
  12. #include "duck_mem.h"
  13. #include "../include/dxl_plugin.h"
  14. typedef struct tagflgs
  15. {
  16. unsigned inUse : 1;
  17. unsigned DXed : 1;
  18. unsigned clutOwner: 1;
  19. unsigned doCompleteBlit : 1;
  20. unsigned keyFrame : 1;
  21. unsigned nullFrame : 1;
  22. unsigned interframe : 1;
  23. unsigned logo : 1;
  24. unsigned allocated : 1;
  25. } dkInfoFlags;
  26. typedef struct vScreen
  27. {
  28. DXL_OBJECT_VERSION version;
  29. unsigned char *_addr;
  30. unsigned char *laddr; /* address of destination and what it was the last time */
  31. enum BITDEPTH bd; /* format of destination */
  32. enum BLITQUALITY bq; /* blit translation mode */
  33. short pitch, height; /* pitch and height of dest */
  34. short viewX,viewY; /* offset/clipping viewport within destination */
  35. short viewW,viewH;
  36. dkInfoFlags dkFlags;
  37. } DXL_VSCREEN;
  38. #define validate(x) \
  39. { \
  40. if (!x) \
  41. return (int) DXL_NULLSOURCE; \
  42. if (!x->dkFlags.inUse) \
  43. return (int) DXL_NOTINUSE; \
  44. }
  45. /***********************************************/
  46. DXL_VSCREEN_HANDLE
  47. vScreenCreate(void)
  48. {
  49. DXL_VSCREEN_HANDLE nScreen;
  50. nScreen = (DXL_VSCREEN_HANDLE)duck_calloc(1,sizeof(DXL_VSCREEN),DMEM_GENERAL);
  51. if (nScreen)
  52. nScreen->dkFlags.allocated = 1;
  53. return nScreen;
  54. }
  55. int
  56. DXL_SetVScreenBlitQuality(DXL_VSCREEN_HANDLE dst, enum BLITQUALITY blitquality)
  57. {
  58. int oldBQ;
  59. validate(dst);
  60. oldBQ = dst->bq;
  61. dst->bq = blitquality;
  62. return oldBQ;
  63. }
  64. void
  65. DXL_DestroyVScreen(DXL_VSCREEN_HANDLE dst)
  66. {
  67. if (dst != NULL){
  68. dst->dkFlags.inUse = 0;
  69. dst->_addr = NULL;
  70. if (dst->dkFlags.allocated)
  71. duck_free(dst);
  72. }
  73. }
  74. int
  75. DXL_AlterVScreen(DXL_VSCREEN_HANDLE dst, unsigned char *_addr, enum BITDEPTH bd, int p, int h)
  76. {
  77. validate(dst);
  78. if (_addr != NULL) dst->_addr = _addr;
  79. if (bd != DXRGBNULL) dst->bd = bd;
  80. if (p != -1) dst->pitch = (short) p;
  81. if (h != -1) dst->height = (short) h;
  82. return DXL_OK;
  83. }
  84. int
  85. DXL_AlterVScreenView(DXL_VSCREEN_HANDLE dst,int x,int y,int w,int h)
  86. {
  87. validate(dst);
  88. if (x > -1) dst->viewX = (short)x;
  89. if (y > -1) dst->viewY = (short)y;
  90. if (w > -1) dst->viewW = (short)w;
  91. if (h > -1) dst->viewH = (short)h;
  92. return DXL_OK;
  93. }
  94. DXL_VSCREEN_HANDLE
  95. DXL_CreateVScreen(unsigned char *_addr, enum BITDEPTH bd, short p,short h)
  96. {
  97. DXL_VSCREEN_HANDLE vScreenCreate(void);
  98. DXL_VSCREEN_HANDLE nScreen = vScreenCreate();
  99. if (!nScreen)
  100. return NULL;
  101. nScreen->dkFlags.inUse = 1;
  102. DXL_AlterVScreen(nScreen, _addr, bd, p, h);
  103. return nScreen;
  104. }
  105. int DXL_GetVScreenView(DXL_VSCREEN_HANDLE dst,int *x,int *y,int *w,int *h)
  106. {
  107. validate(dst);
  108. if(x)
  109. *x = dst->viewX;
  110. if(y)
  111. *y = dst->viewY;
  112. if(w)
  113. *w = dst->viewW;
  114. if(h)
  115. *h = dst->viewH;
  116. return DXL_OK;
  117. }
  118. int DXL_GetVScreenAttributes(DXL_VSCREEN_HANDLE dst, void **_addr, dxvBlitQuality *bq, dxvBitDepth *bd, short *pitch, short *height)
  119. {
  120. validate(dst);
  121. if(_addr)
  122. *_addr = dst->_addr;
  123. if(bq)
  124. *bq = dst->bq;
  125. if(bd)
  126. *bd = dst->bd;
  127. if(pitch)
  128. *pitch = dst->pitch;
  129. if(height)
  130. *height = dst->height;
  131. return DXL_OK;
  132. }