summaryrefslogtreecommitdiff
path: root/game/client/econ/iconrenderreceiver.h
blob: d3911fcd6c3aabc41a8dbc5bcdbc670389ba64e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Holds the result of an AsyncCreateTextureFromRenderTarget for VGUI. Don't reuse these.
//
//=============================================================================
#ifndef ICON_RENDER_RECEIVER_H
#define ICON_RENDER_RECEIVER_H
#ifdef _WIN32
#pragma once
#endif

#include "materialsystem/itexture.h"

class CIconRenderReceiver : public IAsyncTextureOperationReceiver
{
public:
	CIconRenderReceiver() : m_pTex( NULL ) { }

protected:
	virtual ~CIconRenderReceiver() { SafeRelease( &m_pTex ); }

public:
	virtual int AddRef() OVERRIDE 
	{
		return ++m_nReferenceCount;
	}

	virtual int Release() OVERRIDE 
	{
		int retVal = --m_nReferenceCount;
		if ( retVal == 0 )
			delete this;
		return retVal;
	}

	virtual void OnAsyncCreateComplete( ITexture* pTex, void *pRtSrc ) OVERRIDE 
	{
		SafeAssign( &m_pTex, pTex );
	}

	virtual void OnAsyncFindComplete( ITexture* pTex, void * ) OVERRIDE  { Assert( !"Should never be called." ); }
	virtual void OnAsyncMapComplete( ITexture* pTex, void* pExtraArgs, void* pMemory, int pPitch ) OVERRIDE { Assert( !"Should never be called." ); }
	virtual void OnAsyncReadbackBegin( ITexture* pDst, ITexture* pSrc, void* pExtraArgs ) OVERRIDE { Assert( !"Should never be called." ); }

	virtual int GetRefCount() const OVERRIDE { return m_nReferenceCount; } 

	ITexture* GetTexture() const { return m_pTex; }

private:
	CInterlockedInt m_nReferenceCount; 
	ITexture* m_pTex;
};

#endif // ICON_RENDER_RECEIVER_H