//
// Asura_HDRHistogram_Gadget.h
//
// Created by Andrew Southgate - 20 Feb 2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//


#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_HDRHISTOGRAM_GADGET_H__
#define __ASURA_HDRHISTOGRAM_GADGET_H__

#ifdef ASURA_USE_HDR


class Asura_HDRHistogram_Gadget : public Asura_Gadget
{
public:
	static void Initialise();

	// Constructor
	Asura_HDRHistogram_Gadget( const Asura_Vector_2& xOffset,
		const float fWidth,
		const float fHeight,
		bool &bShowRedChannel,
		bool &bShowGreenChannel,
		bool &bShowBlueChannel,
		bool &bShowLumChannel
		);
	~Asura_HDRHistogram_Gadget();


	// Functions
	void Clear();
	void Reload();

	void UpdateHDR(const Asura_Direct3D_HDR::HDR_Histogram_Data &xData, float fRange);

	// Virtual overrides
	virtual void Update( const Asura_Vector_2& xOrigin );

protected:
	bool	&m_bShowRedChannel;
	bool	&m_bShowBlueChannel;
	bool	&m_bShowGreenChannel;
	bool	&m_bShowLumChannel;

	float	m_fRange;

	Direct3D_Texture	*m_pDataTexture[2];
	u_int				 m_uCurrentTexture;


	// Virtual overrides
	virtual void Render( const Asura_Vector_2& xOrigin );

};

class Asura_HDRHistogram_Dialog : public Asura_Dialog
{
public:
	Asura_HDRHistogram_Dialog(const char* const szName, const Asura_Vector_2& xOffset, const float fWidth, const float fHeight, bool bAfterToneMap = false);
	~Asura_HDRHistogram_Dialog();
	virtual void Render( const Asura_Vector_2& xOrigin );
	void UpdateHDR(const Asura_Direct3D_HDR::HDR_Histogram_Data &xData);
	// Virtual overrides
	virtual void Update( const Asura_Vector_2& xOrigin );

private:
	bool m_bShowRedChannel;
	bool m_bShowGreenChannel;
	bool m_bShowBlueChannel;
	bool m_bShowLumChannel;

	float m_fRange;
	float m_fRangeMin;
	float m_fRangeMax;

	bool m_bAfterToneMap;

	Asura_HDRHistogram_Gadget *m_pxGadget;

	static void HDR_CB(const Asura_Direct3D_HDR::HDR_Histogram_Data &xData);
};


#endif // defined(ASURA_USE_HDR)
#endif // !defined(__ASURA_HDRHISTOGRAM_GADGET_H__)