text: /**
  * Copyright (C) 2020 Elisha Riedlinger
  *
  * This software is  provided 'as-is', without any express  or implied  warranty. In no event will the
  * authors be held liable for any damages arising from the use of this software.
  * Permission  is granted  to anyone  to use  this software  for  any  purpose,  including  commercial
  * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  *
  *   1. The origin of this software must not be misrepresented; you must not claim that you  wrote the
  *      original  software. If you use this  software  in a product, an  acknowledgment in the product
  *      documentation would be appreciated but is not required.
  *   2. Altered source versions must  be plainly  marked as such, and  must not be  misrepresented  as
  *      being the original software.
  *   3. This notice may not be removed or altered from any source distribution.
  */
  
  #include "d3d8.h"
  
  HRESULT m_IDirect3DSwapChain8::QueryInterface(THIS_ REFIID riid, void** ppvObj)
  {
  	if ((riid == IID_IDirect3DSwapChain8 || riid == IID_IUnknown) && ppvObj)
  	{
  		AddRef();
  
  		*ppvObj = this;
  
  		return S_OK;
  	}
  
  	HRESULT hr = ProxyInterface->QueryInterface(riid, ppvObj);
  
  	if (SUCCEEDED(hr))
  	{
  		genericQueryInterface(riid, ppvObj, m_pDevice);
  	}
  
  	return hr;
  }
  
  ULONG m_IDirect3DSwapChain8::AddRef(THIS)
  {
  	return ProxyInterface->AddRef();
  }
  
  ULONG m_IDirect3DSwapChain8::Release(THIS)
  {
  	return ProxyInterface->Release();
  }
  
  HRESULT m_IDirect3DSwapChain8::Present(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
  {
  	return ProxyInterface->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
  }
  
  HRESULT m_IDirect3DSwapChain8::GetBackBuffer(THIS_ UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer)
  {
  	HRESULT hr = ProxyInterface->GetBackBuffer(BackBuffer, Type, ppBackBuffer);
  
  	if (SUCCEEDED(hr) && ppBackBuffer)
  	{
  		*ppBackBuffer = m_pDevice->ProxyAddressLookupTable->FindAddress<m_IDirect3DSurface8>(*ppBackBuffer);
  	}
  
  	return hr;
  }
  