//
// Asura_PSP_Filter.h
//
// Created by JG - 01/11/2005 14:31:19
//
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#ifndef __ASURA_PSP_FILTER_H__
#define __ASURA_PSP_FILTER_H__

class Asura_PSP_Filter
{
public:
	static void Initialise( void );

	static void SetFilter(bool bEnable, int iRed, int iGreen, int iBlue, int iAlpha);

	static void SetSourceBuffer( const void* pSource, const unsigned int uSourceWidth, const unsigned int uSourceHeight, bool bRemap = false, bool bShortIndex = false ); 
	static void SetSourceScreen( const void* pSource ); 
	static void SetDestinationBuffer( void* pDest, const unsigned int uDestWidth, const unsigned int uDestHeight ); 
	static void SetDestinationScreen( void* pDest ); 

	static void Copy(const unsigned int uSourceWidth, const unsigned int uSourceHeight, const unsigned int uDestWidth, const unsigned int uDestHeight, const bool bLinearInterpolation = true, const unsigned int uHorizontalOffset = 0, const unsigned int uVerticalOffset = 0); 
	static void CopyFromScreen( const void* pSource, void* pDest, const unsigned int uDestWidth, const unsigned int uDestHeight ); 

	static void Render();
	static void Render( const char* cDisplayList, const unsigned int uCurrentRenderingBuffer );

	static void RenderOutlineUsingColorBuffer( const char* cDisplayList, const unsigned int uCurrentRenderingBuffer, bool bColourBased = false, unsigned int uOutlineColour = 0x00 ); 
	static void RenderOutlineUsingStencilBuffer( const char* cDisplayList, const unsigned int uCurrentRenderingBuffer ); 

	static void RemapImageToPalette(const unsigned int uCurrentRenderingBuffer, const void* const puClut);

	static void StartStencilOutline(); 
	static void StopStencilOutline(); 

	static void FillStencilValueWithColor( const unsigned int uStencilValue, const unsigned int uColor );  
	static void TintStencilValueWithColor( const unsigned int uStencilValue, const unsigned int uColor, const unsigned int uStrength );
	static void FillStencilValueUsingDepthBuffer(const unsigned int uStencilValue, const unsigned int uShift, const unsigned char uMask, const void* const puClut, const bool bIgnoreStencil = false);
	static void ClipDepthBufferAtDistance(const unsigned int uDistance);

	static void*TakeScreenShotCurrentFrame(int iX = 0, int iY = 0, int iWidth = 480, int iHeight = 272); //Take a current rendering frame shoot and return a pointer to the address to directly use when setting the texture; In this moment is using the same memory address as the filter for taking the screen shot; the size of the screen shot is 128 x 128;
	static void*TakeScreenShotLastFrame(int iX = 0, int iY = 0, int iWidth = 480, int iHeight = 272); //Take a current rendering frame shoot and return a pointer to the address to directly use when setting the texture; In this moment is using the same memory address as the filter for taking the screen shot; the size of the screen shot is 128 x 128;

	static bool IsEnabled() { return s_bEnabled; }
	static void GetFilterColour(int& iRed, int& iGreen, int& iBlue, int& iAlpha) { iRed = s_iRed; iGreen = s_iGreen; iBlue = s_iBlue; iAlpha = s_iAlpha; }

private:
	static int s_iRed;
	static int s_iGreen;
	static int s_iBlue;
	static int s_iAlpha;
	static bool s_bEnabled;

	static void*CopyFromAddressToAddress(void* pCopyFromAddress, void* pCopyToAddress, void* pRestoreBackBufferAddress, int iWidth, int iHeight);
};

#endif//__ASURA_PSP_FILTER_H__
