Home | History | Annotate | Download | only in nine
      1 /*
      2  * Copyright 2011 Joakim Sindholt <opensource (at) 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 #include "swapchain9ex.h"
     24 #include "device9.h"
     25 
     26 #include "nine_helpers.h"
     27 
     28 #define DBG_CHANNEL DBG_SWAPCHAIN
     29 
     30 static HRESULT
     31 NineSwapChain9Ex_ctor( struct NineSwapChain9Ex *This,
     32                        struct NineUnknownParams *pParams,
     33                        BOOL implicit,
     34                        ID3DPresent *pPresent,
     35                        D3DPRESENT_PARAMETERS *pPresentationParameters,
     36                        struct d3dadapter9_context *pCTX,
     37                        HWND hFocusWindow,
     38                        D3DDISPLAYMODEEX *mode )
     39 {
     40     DBG("This=%p pParams=%p implicit=%d pPresent=%p pPresentationParameters=%p "
     41         "pCTX=%p hFocusWindow=%p mode=%p",
     42         This, pParams, (int) implicit, pPresent, pPresentationParameters, pCTX, hFocusWindow, mode);
     43 
     44     return NineSwapChain9_ctor(&This->base, pParams, implicit, pPresent,
     45                                pPresentationParameters, pCTX, hFocusWindow, mode);
     46 }
     47 
     48 static void
     49 NineSwapChain9Ex_dtor( struct NineSwapChain9Ex *This )
     50 {
     51     NineSwapChain9_dtor(&This->base);
     52 }
     53 
     54 HRESULT NINE_WINAPI
     55 NineSwapChain9Ex_GetLastPresentCount( struct NineSwapChain9Ex *This,
     56                                       UINT *pLastPresentCount )
     57 {
     58     STUB(D3DERR_INVALIDCALL);
     59 }
     60 
     61 HRESULT NINE_WINAPI
     62 NineSwapChain9Ex_GetPresentStats( struct NineSwapChain9Ex *This,
     63                                   D3DPRESENTSTATS *pPresentationStatistics )
     64 {
     65     STUB(D3DERR_INVALIDCALL);
     66 }
     67 
     68 HRESULT NINE_WINAPI
     69 NineSwapChain9Ex_GetDisplayModeEx( struct NineSwapChain9Ex *This,
     70                                    D3DDISPLAYMODEEX *pMode,
     71                                    D3DDISPLAYROTATION *pRotation )
     72 {
     73     D3DDISPLAYROTATION rot;
     74 
     75     user_assert(pMode != NULL, E_POINTER);
     76     if (!pRotation) { pRotation = &rot; }
     77 
     78     return ID3DPresent_GetDisplayMode(This->base.present, pMode, pRotation);
     79 }
     80 
     81 IDirect3DSwapChain9ExVtbl NineSwapChain9Ex_vtable = {
     82     (void *)NineUnknown_QueryInterface,
     83     (void *)NineUnknown_AddRef,
     84     (void *)NineUnknown_Release,
     85     (void *)NineSwapChain9_Present,
     86     (void *)NineSwapChain9_GetFrontBufferData,
     87     (void *)NineSwapChain9_GetBackBuffer,
     88     (void *)NineSwapChain9_GetRasterStatus,
     89     (void *)NineSwapChain9_GetDisplayMode,
     90     (void *)NineUnknown_GetDevice, /* actually part of NineSwapChain9 iface */
     91     (void *)NineSwapChain9_GetPresentParameters,
     92     (void *)NineSwapChain9Ex_GetLastPresentCount,
     93     (void *)NineSwapChain9Ex_GetPresentStats,
     94     (void *)NineSwapChain9Ex_GetDisplayModeEx
     95 };
     96 
     97 static const GUID *NineSwapChain9Ex_IIDs[] = {
     98     &IID_IDirect3DSwapChain9Ex,
     99     &IID_IDirect3DSwapChain9,
    100     &IID_IUnknown,
    101     NULL
    102 };
    103 
    104 HRESULT
    105 NineSwapChain9Ex_new( struct NineDevice9 *pDevice,
    106                       BOOL implicit,
    107                       ID3DPresent *pPresent,
    108                       D3DPRESENT_PARAMETERS *pPresentationParameters,
    109                       struct d3dadapter9_context *pCTX,
    110                       HWND hFocusWindow,
    111                       D3DDISPLAYMODEEX *mode,
    112                       struct NineSwapChain9Ex **ppOut )
    113 {
    114     NINE_DEVICE_CHILD_NEW(SwapChain9Ex, ppOut, pDevice, /* args */
    115                           implicit, pPresent, pPresentationParameters,
    116                           pCTX, hFocusWindow, mode);
    117 }
    118