/* ==================================================================== * ÆÄ ÀÏ : CacheAgent.h * ¸ñ Àû : ij½¬¸¦ »ý¼ºÇϰí, ¹öÆÛ¸¦ ¿¬°áÇÏ¿© °ü¸®ÇÑ´Ù. * ÀÛ ¼º ÀÚ : À̹ý¼® * ÀÛ ¼º ÀÏ : 2006.11.10 * * Ãß°¡³»¿ë : * Ãß°¡³¯Â¥ ÀÛ¾÷ÀÚ Ãß°¡³»¿ë * 06.11.10 À̹ý¼® »ý¼º * * ÁÖÀÇ»çÇ× : * =================================================================== */ #pragma once #include "CacheBuffer.h" #define MAX_SEARCH_TABLE_NUM 10 #define MIN_FONT_HEIGHT 8 #define MAX_STRING_BYTES_NUM 256 struct sTextureBufferDesc; struct sFontPropertyDesc { HFONT hFont; unsigned int width; unsigned int height; LPTSTR pszString; unsigned long strLen; unsigned long color; }; /// ƯÁ¤ ÅØ½ºÃÄ ¹öÆÛÁß¿¡¼­ ÇÒ´ç°ø°£ Á¤º¸ struct sTextureLineDesc { /// key°ª unsigned int height; /// ³²¾ÆÀÖ´Â »ç¿ë °¡´É ³ÐÀÌ unsigned int availableWidth; /// ÇÒ´ç¹ÞÀ» XÁÂÇ¥ unsigned int currentPosX; /// °¡¸®Å°´Â ¶óÀÎÀÇ À§Ä¡°ª unsigned int posY; /// ÂüÁ¶ ÅØ½ºÃÄ // D3DTexturePtr pTexture; NiMeshScreenElements* pNiTexture; /// sContainerAE* ÇÚµé void* pSearchHandle; sTextureBufferDesc* pBufferDesc; sTextureLineDesc* pNext; sTextureLineDesc() { pSearchHandle = 0; pBufferDesc = 0; pNext = 0; // pTexture = 0; pNiTexture = 0; } ~sTextureLineDesc() { pSearchHandle = 0; pBufferDesc = 0; pNext = 0; // pTexture = 0; pNiTexture = 0; } }; struct sTextureBlockDesc { unsigned int posX; unsigned int posY; unsigned int width; unsigned int height; /// ÂüÁ¶ ÅØ½ºÃÄ // D3DTexturePtr pTexture; NiMeshScreenElements* pNiTexture; RECT rect; /// sCacheKey ÇÚµé void* pHashHandle; sTextureBufferDesc* pBufferDesc; sTextureBlockDesc* pNext; sTextureBlockDesc() { pHashHandle = 0; pBufferDesc = 0; pNext = 0; // pTexture = 0; pNiTexture = 0; } ~sTextureBlockDesc() { pHashHandle = 0; pBufferDesc = 0; pNext = 0; // pTexture = 0; pNiTexture = 0; } D3DTexturePtr GetDxTexture() { if( pNiTexture == 0 ) return 0; NiTexturingProperty* prop = (NiTexturingProperty*)pNiTexture->GetProperty( NiProperty::TEXTURING ); if( prop == 0 ) return 0; NiSourceTexture* tex = (NiSourceTexture*)prop->GetBaseTexture(); if( tex == 0 ) return 0; NiDX9TextureData* pRenderData = (NiDX9TextureData*)tex->GetRendererData(); if( pRenderData == 0 ) return 0; return (D3DTexturePtr)pRenderData->GetD3DTexture(); } }; /// ÅØ½ºÃÄ ¹öÆÛ Á¤º¸ struct sTextureBufferDesc { int testnum; /// ¿øº» // D3DTexturePtr pTexture; NiMeshScreenElementsPtr pNiTexture; /// ³²¾ÆÀÖ´Â »ç¿ë °¡´É ³ôÀÌ unsigned int availableHeight; /// ÇÒ´ç¹ÞÀ» YÁÂÇ¥ unsigned int posY; sTextureLineDesc* pLineDesc; sTextureBlockDesc* pBlockDesc; /// ¿øÇü ¸®½ºÆ® ±¸¼ºÀ» À§ÇÑ º¯¼ö sTextureBufferDesc* pNext; sTextureBufferDesc() { // pTexture = 0; pLineDesc = 0; pBlockDesc = 0; pNext = 0; pNiTexture = 0; } ~sTextureBufferDesc() { // pTexture = 0; pLineDesc = 0; pBlockDesc = 0; pNext = 0; pNiTexture = 0; } }; class NiDX9Renderer; class cBinSearchAE; class cCacheAgent { public: cCacheAgent(); ~cCacheAgent(); /// ÃʱâÈ­ bool Initialize( unsigned int maxCacheItemNum, unsigned int texWidth, unsigned int texHeight, unsigned int texNum ); /// 2D ÆùÆ® ij½¬¸¦ ȹµæ NiMeshScreenElements* GetCache( RECT* pRect, sFontPropertyDesc* pDesc ); protected: /// À̹ÌÁö¸¦ »ý¼ºÇÑ´Ù.. void CreateBitmapFromText( HFONT hFont, HBITMAP& hBitmap, LPTSTR string, unsigned long strLen, unsigned long color, RECT* pRect, unsigned long fontHeight, VOID** pOut ); void DDBToDIB( HDC hDC,HBITMAP hBitmap, unsigned char* pOut ); /// »õ·Î ÀÛ¼ºµÈ ¹®ÀÚ¿­À» °Ë»öÇÏ¿© ¾ø´Ù¸é »õ·Î »ý¼ºÇÏ´Â ·çƾÀ» Á¦°øÇÑ´Ù. sTextureBlockDesc* AddCache( RECT* pRect, sFontPropertyDesc* pDesc ); sTextureBlockDesc* AllocTextureBlock( unsigned int width, unsigned int height ); sTextureLineDesc* AllocLineDesc( unsigned int height ); void ChangeTextureBuffer(); protected: /// ij½¬ ¹öÆÛ cCacheBuffer* mpCacheHashBuffer; typedef tPool cBlockDescPool; typedef tPool cLineDescPool; cBlockDescPool* mpBlockDescPool; cLineDescPool* mpLineDescPool; cBinSearchAE* mpLineDescSearch; unsigned long mMaxTextureBlockDescNum; unsigned long mMaxLineDescNum; /// ¿øÇü ¸®½ºÆ® ½ÃÀÛÁ¡À̸鼭, ÁÖ ¹öÆÛ sTextureBufferDesc* mpTextureBufferDesc; /// ÇöÀç ÇÒ´çµÇ¾î »ç¿ëÁßÀÎ ¹öÆÛ sTextureBufferDesc* mpPrimaryBufferDesc; /// ¿øÇü ¸®½ºÆ® ±¸¼ºÁ¤º¸ º¯¼ö unsigned long mTextureBufferNum; unsigned long mMaxCacheItemNum; /// ¹®ÀÚ¸¦ Ãâ·ÂÇϱâ À§ÇÑ º¯¼ö unsigned int mTexWidth; unsigned int mTexHeight; // unsigned char* mpImageBuffer; unsigned char mImageDepth; /// ±íÀÌ 16 or 32 -> 2byte or 4byte HDC mhDC; HDC mhMemDC; HBRUSH mhBrush; };