diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/dx_proxy/dxincludeimpl.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/dx_proxy/dxincludeimpl.h')
| -rw-r--r-- | utils/dx_proxy/dxincludeimpl.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/utils/dx_proxy/dxincludeimpl.h b/utils/dx_proxy/dxincludeimpl.h new file mode 100644 index 0000000..1c67c62 --- /dev/null +++ b/utils/dx_proxy/dxincludeimpl.h @@ -0,0 +1,52 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + +#ifndef DXINCLUDEIMPL_H +#define DXINCLUDEIMPL_H +#ifdef _WIN32 +#pragma once +#endif + +FileCache s_incFileCache; + +struct DxIncludeImpl : public ID3DXInclude +{ + STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) + { + CachedFileData *pFileData = s_incFileCache.Get( pFileName ); + if ( !pFileData || !pFileData->IsValid() ) + return E_FAIL; + + *ppData = pFileData->GetDataPtr(); + *pBytes = pFileData->GetDataLen(); + + pFileData->UpdateRefCount( +1 ); + + return S_OK; + } + + STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, + LPCVOID *ppData, UINT *pBytes, + /* OUT */ LPSTR pFullPath, DWORD cbFullPath) + { + if ( pFullPath && cbFullPath ) strncpy( pFullPath, pFileName, cbFullPath ); + return Open( IncludeType, pFileName, pParentData, ppData, pBytes ); + } + + STDMETHOD(Close)(THIS_ LPCVOID pData) + { + if ( CachedFileData *pFileData = CachedFileData::GetByDataPtr( pData ) ) + pFileData->UpdateRefCount( -1 ); + + return S_OK; + } +}; + +DxIncludeImpl s_incDxImpl; + +#endif // #ifndef DXINCLUDEIMPL_H |