vscreen.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 "duck_mem.h"
  12. #include "dxl_main.h"
  13. #include <assert.h>
  14. /***********************************************/
  15. int DXL_GetVScreenSizeOfPixel(DXL_VSCREEN_HANDLE vSc)
  16. {
  17. switch (vSc->bd){
  18. case DXRGB8:
  19. case DXHALFTONE8:
  20. case DXRGB8VESA:
  21. return 1;
  22. case DXRGB16_555:
  23. case DXRGB16_565:
  24. case DXRGB16VESA:
  25. case DXYUY2:
  26. case DXUYVY:
  27. return 2;
  28. case DXRGB24:
  29. return 3;
  30. case DXRGB32:
  31. return 4;
  32. default:
  33. return -1;
  34. }
  35. }
  36. void DXL_DestroyVScreen(DXL_VSCREEN_HANDLE dst)
  37. {
  38. if (dst != NULL){
  39. dst->dkFlags.inUse = 0;
  40. dst->addr = NULL;
  41. if (dst->dkFlags.allocated)
  42. duck_free(dst);
  43. }
  44. }
  45. int DXL_AlterVScreen(DXL_VSCREEN_HANDLE dst, unsigned char *addr,enum BITDEPTH bd, int p,int h)
  46. {
  47. validate(dst);
  48. if (addr != NULL) dst->addr = addr;
  49. if (bd != DXRGBNULL) dst->bd = bd;
  50. if (p != -1) dst->pitch = (short) p;
  51. if (h != -1) dst->height = (short) h;
  52. return DXL_OK;
  53. }
  54. int DXL_AlterVScreenView(DXL_VSCREEN_HANDLE dst,int x,int y,int w,int h)
  55. {
  56. validate(dst);
  57. if (x > -1) dst->viewX = (short)x;// & 0xfffe;
  58. if (y > -1) dst->viewY = (short)y;
  59. if (w > -1) dst->viewW = (short)w;// & 0xfffe;
  60. if (h > -1) dst->viewH = (short)h;
  61. return DXL_OK;
  62. }
  63. DXL_VSCREEN_HANDLE DXL_CreateVScreen(unsigned char *addr, enum BITDEPTH bd, short p,short h)
  64. {
  65. #pragma warning(disable: 4210) // nonstandard extension used : function given file scope
  66. DXL_VSCREEN_HANDLE vScreenCreate(void);
  67. #pragma warning(default: 4210) // nonstandard extension used : function given file scope
  68. DXL_VSCREEN_HANDLE nScreen = vScreenCreate();
  69. if (!nScreen) return NULL;
  70. nScreen->dkFlags.inUse = 1;
  71. nScreen->blitFormat = -1;
  72. DXL_AlterVScreen(nScreen, addr, bd, p, h);
  73. nScreen->bx = nScreen->by = 0;
  74. nScreen->bAddr = NULL;
  75. nScreen->bq = DXBLIT_SAME;
  76. return nScreen;
  77. }
  78. int DXL_GetVScreenView(DXL_VSCREEN_HANDLE dst,int *x,int *y,int *w,int *h)
  79. {
  80. validate(dst);
  81. *x = dst->viewX;
  82. *y = dst->viewY;
  83. *w = dst->viewW;
  84. *h = dst->viewH;
  85. return DXL_OK;
  86. }
  87. int DXL_GetVScreenAttributes(
  88. DXL_VSCREEN_HANDLE vScreen,
  89. void **addr,
  90. dxvBlitQuality *bq,
  91. dxvBitDepth *bd,
  92. short *pitch,
  93. short *height
  94. )
  95. {
  96. if (addr)
  97. {
  98. *addr = (void *) (vScreen->addr);
  99. }
  100. else
  101. {
  102. assert(0);
  103. }
  104. if (bq)
  105. {
  106. *bq = vScreen->bq;
  107. }
  108. else
  109. {
  110. assert(0);
  111. }
  112. if (bd)
  113. {
  114. *bd = vScreen->bd;
  115. }
  116. else
  117. {
  118. assert(0);
  119. }
  120. if (pitch)
  121. {
  122. *pitch = vScreen->pitch;
  123. }
  124. else
  125. {
  126. assert(0);
  127. }
  128. if (height)
  129. {
  130. *height = vScreen->height;
  131. }
  132. else
  133. {
  134. assert(0);
  135. }
  136. return 0;
  137. } /* end get attributes */