Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * on the rights to use, copy, modify, merge, publish, distribute, sub
  8.  * license, and/or sell copies of the Software, and to permit persons to whom
  9.  * the Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  18.  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  19.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21.  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
  22.  
  23. #ifndef _NINE_SWAPCHAIN9_H_
  24. #define _NINE_SWAPCHAIN9_H_
  25.  
  26. #include "iunknown.h"
  27. #include "adapter9.h"
  28.  
  29. #include "d3dadapter/d3dadapter9.h"
  30.  
  31. #include "threadpool.h"
  32.  
  33. struct NineDevice9;
  34. struct NineSurface9;
  35. struct nine_winsys_swapchain;
  36. struct blit_state;
  37.  
  38. #define DRI_SWAP_FENCES_MAX 4
  39. #define DRI_SWAP_FENCES_MASK 3
  40.  
  41. struct NineSwapChain9
  42. {
  43.     struct NineUnknown base;
  44.  
  45.     /* G3D stuff */
  46.     struct pipe_screen *screen;
  47.     struct pipe_context *pipe;
  48.     struct cso_context *cso;
  49.  
  50.     /* presentation backend */
  51.     ID3DPresent *present;
  52.     D3DPRESENT_PARAMETERS params;
  53.     D3DDISPLAYMODEEX *mode;
  54.     struct d3dadapter9_context *actx;
  55.     BOOL implicit;
  56.  
  57.     /* buffer handles */
  58.     struct NineSurface9 **buffers; /* 0 to BackBufferCount-1 : the back buffers. BackBufferCount : additional buffer */
  59.     struct pipe_resource **present_buffers;
  60.     D3DWindowBuffer **present_handles;
  61.  
  62.     struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
  63.     unsigned int cur_fences;
  64.     unsigned int head;
  65.     unsigned int tail;
  66.     unsigned int desired_fences;
  67.  
  68.     BOOL rendering_done;
  69.  
  70.     struct NineSurface9 *zsbuf;
  71.  
  72.     D3DGAMMARAMP gamma;
  73.  
  74.     struct threadpool *pool;
  75.     struct threadpool_task **tasks;
  76.     BOOL enable_threadpool;
  77. };
  78.  
  79. static INLINE struct NineSwapChain9 *
  80. NineSwapChain9( void *data )
  81. {
  82.     return (struct NineSwapChain9 *)data;
  83. }
  84.  
  85. HRESULT
  86. NineSwapChain9_new( struct NineDevice9 *pDevice,
  87.                     BOOL implicit,
  88.                     ID3DPresent *pPresent,
  89.                     D3DPRESENT_PARAMETERS *pPresentationParameters,
  90.                     struct d3dadapter9_context *pCTX,
  91.                     HWND hFocusWindow,
  92.                     struct NineSwapChain9 **ppOut );
  93.  
  94. HRESULT
  95. NineSwapChain9_ctor( struct NineSwapChain9 *This,
  96.                      struct NineUnknownParams *pParams,
  97.                      BOOL implicit,
  98.                      ID3DPresent *pPresent,
  99.                      D3DPRESENT_PARAMETERS *pPresentationParameters,
  100.                      struct d3dadapter9_context *pCTX,
  101.                      HWND hFocusWindow,
  102.                      D3DDISPLAYMODEEX *mode );
  103.  
  104. void
  105. NineSwapChain9_dtor( struct NineSwapChain9 *This );
  106.  
  107. HRESULT
  108. NineSwapChain9_Resize( struct NineSwapChain9 *This,
  109.                        D3DPRESENT_PARAMETERS *pParams,
  110.                        D3DDISPLAYMODEEX *mode );
  111.  
  112. HRESULT WINAPI
  113. NineSwapChain9_Present( struct NineSwapChain9 *This,
  114.                         const RECT *pSourceRect,
  115.                         const RECT *pDestRect,
  116.                         HWND hDestWindowOverride,
  117.                         const RGNDATA *pDirtyRegion,
  118.                         DWORD dwFlags );
  119.  
  120. HRESULT WINAPI
  121. NineSwapChain9_GetFrontBufferData( struct NineSwapChain9 *This,
  122.                                    IDirect3DSurface9 *pDestSurface );
  123.  
  124. HRESULT WINAPI
  125. NineSwapChain9_GetBackBuffer( struct NineSwapChain9 *This,
  126.                               UINT iBackBuffer,
  127.                               D3DBACKBUFFER_TYPE Type,
  128.                               IDirect3DSurface9 **ppBackBuffer );
  129.  
  130. HRESULT WINAPI
  131. NineSwapChain9_GetRasterStatus( struct NineSwapChain9 *This,
  132.                                 D3DRASTER_STATUS *pRasterStatus );
  133.  
  134. HRESULT WINAPI
  135. NineSwapChain9_GetDisplayMode( struct NineSwapChain9 *This,
  136.                                D3DDISPLAYMODE *pMode );
  137.  
  138. HRESULT WINAPI
  139. NineSwapChain9_GetPresentParameters( struct NineSwapChain9 *This,
  140.                                      D3DPRESENT_PARAMETERS *pPresentationParameters );
  141.  
  142. #endif /* _NINE_SWAPCHAIN9_H_ */
  143.