Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented state manager for caching DirectX render state changes

  • Loading branch information...
commit bd6675d702ec17226dafe8a0d6513ec4d4dcdf4c 1 parent b78cbd5
tourettes tourettes authored
2  DirectShowFilters/fontEngine/fontEngine.vcxproj
View
@@ -122,6 +122,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="source\EffectStateManager.cpp" />
<ClCompile Include="source\fontEngine.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(DSHOW_BASE); $(WINDOWS_SDK)Include; $(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@@ -134,6 +135,7 @@
<None Include="source\fontEngine.def" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="source\EffectStateManager.h" />
<ClInclude Include="source\TransformMatrix.h" />
<ClInclude Include="source\fontEngine.h" />
<ClInclude Include="source\stdafx.h" />
184 DirectShowFilters/fontEngine/source/EffectStateManager.cpp
View
@@ -0,0 +1,184 @@
+// Copyright (C) 2005-2012 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#include "stdafx.h"
+#include "EffectStateManager.h"
+
+CPureDeviceStateManager::CPureDeviceStateManager(LPDIRECT3DDEVICE9 pDevice) :
+ m_pDevice(pDevice),
+ m_lRef(0),
+ m_cacheRenderStates(D3DRS_BLENDOPALPHA),
+ m_vecCacheSamplerStates(CACHED_STAGES, samplerStageCache(D3DSAMP_DMAPOFFSET)),
+ m_vecCacheTextureStates(CACHED_STAGES, textureStateStageCache(D3DTSS_CONSTANT))
+{
+ m_pDevice->AddRef();
+}
+
+CPureDeviceStateManager::~CPureDeviceStateManager()
+{
+ m_pDevice->Release();
+}
+
+HRESULT CPureDeviceStateManager::QueryInterface(REFIID iid, LPVOID* ppv)
+{
+ if (iid == IID_IUnknown || iid == IID_ID3DXEffectStateManager)
+ *ppv = static_cast<ID3DXEffectStateManager*>(this);
+ else
+ {
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ reinterpret_cast<IUnknown*>(this)->AddRef();
+ return S_OK;
+}
+
+ULONG CPureDeviceStateManager::AddRef()
+{
+ return (ULONG)InterlockedIncrement(&m_lRef);
+}
+
+ULONG CPureDeviceStateManager::Release()
+{
+ if (InterlockedDecrement(&m_lRef) == 0L)
+ {
+ delete this;
+ return 0L;
+ }
+
+ return m_lRef;
+}
+
+void CPureDeviceStateManager::DirtyCachedValues()
+{
+ m_cacheRenderStates.dirtyall();
+
+ vector <samplerStageCache>::iterator it_samplerStages;
+ for(it_samplerStages = m_vecCacheSamplerStates.begin(); it_samplerStages != m_vecCacheSamplerStates.end(); it_samplerStages++)
+ {
+ (*it_samplerStages).dirtyall();
+ }
+
+ vector <textureStateStageCache>::iterator it_textureStages;
+ for(it_textureStages = m_vecCacheTextureStates.begin(); it_textureStages != m_vecCacheTextureStates.end(); it_textureStages++)
+ {
+ (*it_textureStages).dirtyall();
+ }
+}
+
+HRESULT CPureDeviceStateManager::SetRenderState(D3DRENDERSTATETYPE d3dRenderState, DWORD dwValue)
+{
+ if (m_cacheRenderStates.set_val(d3dRenderState, dwValue))
+ return m_pDevice->SetRenderState(d3dRenderState, dwValue);
+
+ return S_OK;
+}
+
+HRESULT CPureDeviceStateManager::SetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE d3dSamplerState, DWORD dwValue)
+{
+ if (dwStage >= CACHED_STAGES || m_vecCacheSamplerStates[dwStage].set_val(d3dSamplerState, dwValue))
+ return m_pDevice->SetSamplerState(dwStage, d3dSamplerState, dwValue);
+
+ return S_OK;
+}
+
+HRESULT CPureDeviceStateManager::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTextureStageState, DWORD dwValue)
+{
+ if (dwStage >= CACHED_STAGES || m_vecCacheTextureStates[dwStage].set_val(d3dTextureStageState, dwValue))
+ return m_pDevice->SetTextureStageState(dwStage, d3dTextureStageState, dwValue);
+
+ return S_OK;
+}
+
+HRESULT CPureDeviceStateManager::SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture)
+{
+ return m_pDevice->SetTexture(dwStage, pTexture);
+}
+
+HRESULT CPureDeviceStateManager::SetVertexShader(LPDIRECT3DVERTEXSHADER9 pShader)
+{
+ return m_pDevice->SetVertexShader(pShader);
+}
+
+HRESULT CPureDeviceStateManager::SetPixelShader(LPDIRECT3DPIXELSHADER9 pShader)
+{
+ return m_pDevice->SetPixelShader(pShader);
+}
+
+HRESULT CPureDeviceStateManager::SetFVF(DWORD dwFVF)
+{
+ return m_pDevice->SetFVF(dwFVF);
+}
+
+HRESULT CPureDeviceStateManager::SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix)
+{
+ return m_pDevice->SetTransform(State, pMatrix);
+}
+
+HRESULT CPureDeviceStateManager::SetMaterial(CONST D3DMATERIAL9 *pMaterial)
+{
+ return m_pDevice->SetMaterial(pMaterial);
+}
+
+HRESULT CPureDeviceStateManager::SetLight(DWORD Index, CONST D3DLIGHT9 *pLight)
+{
+ return m_pDevice->SetLight(Index, pLight);
+}
+
+HRESULT CPureDeviceStateManager::LightEnable(DWORD Index, BOOL Enable)
+{
+ return m_pDevice->LightEnable(Index, Enable);
+}
+
+HRESULT CPureDeviceStateManager::SetNPatchMode(FLOAT NumSegments)
+{
+ return m_pDevice->SetNPatchMode(NumSegments);
+}
+
+HRESULT CPureDeviceStateManager::SetVertexShaderConstantF(UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetVertexShaderConstantF( RegisterIndex, pConstantData, RegisterCount);
+}
+
+HRESULT CPureDeviceStateManager::SetVertexShaderConstantI(UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetVertexShaderConstantI( RegisterIndex, pConstantData, RegisterCount);
+}
+
+HRESULT CPureDeviceStateManager::SetVertexShaderConstantB(UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetVertexShaderConstantB(RegisterIndex, pConstantData, RegisterCount);
+}
+
+HRESULT CPureDeviceStateManager::SetPixelShaderConstantF(UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetPixelShaderConstantF(RegisterIndex, pConstantData, RegisterCount);
+}
+
+HRESULT CPureDeviceStateManager::SetPixelShaderConstantI(UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetPixelShaderConstantI(RegisterIndex, pConstantData, RegisterCount);
+}
+
+HRESULT CPureDeviceStateManager::SetPixelShaderConstantB(UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount)
+{
+ return m_pDevice->SetPixelShaderConstantB(RegisterIndex, pConstantData, RegisterCount);
+}
+
+CStateManagerInterface* CStateManagerInterface::Create(LPDIRECT3DDEVICE9 pDevice)
+{
+ return new CPureDeviceStateManager(pDevice);
+}
133 DirectShowFilters/fontEngine/source/EffectStateManager.h
View
@@ -0,0 +1,133 @@
+// Copyright (C) 2005-2012 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+#ifndef _EFFECTSTATEMANAGER_H_
+#define _EFFECTSTATEMANAGER_H_
+
+#include "stdafx.h"
+
+#pragma warning (push)
+#pragma warning (disable : 4512) // 'class' : assignment operator could not be generated
+#pragma warning (disable : 4702) // unreachable code
+#include <vector>
+#include <utility>
+#pragma warning (pop)
+using std::vector;
+#pragma warning(default: 4995)
+
+#define CACHED_STAGES 4
+
+// template for the cache
+template <typename _Kty, typename _Ty> class multicache
+{
+public:
+
+ multicache(unsigned int scope)
+ {
+ m_vecCache.resize(scope);
+ }
+
+ struct cacheItem
+ {
+ _Ty value;
+ bool set;
+ };
+
+protected:
+ std::vector <cacheItem> m_vecCache;
+
+public:
+ inline void dirtyall()
+ {
+ m_vecCache.clear();
+ }
+
+ inline void dirty(_Kty key)
+ {
+ m_vecCache[key].set = false;
+ }
+
+ inline bool set_val(_Kty key, _Ty value)
+ {
+ if (m_vecCache[key].value == value && m_vecCache[key].set)
+ return false;
+ else
+ {
+ m_vecCache[key].value = value;
+ m_vecCache[key].set = true;
+
+ return true;
+ }
+ }
+};
+
+class CStateManagerInterface : public ID3DXEffectStateManager
+{
+public:
+
+ virtual ~CStateManagerInterface(){};
+ virtual void DirtyCachedValues() = 0;
+
+ static CStateManagerInterface* CStateManagerInterface::Create(LPDIRECT3DDEVICE9 pDevice);
+};
+
+class CPureDeviceStateManager : public CStateManagerInterface
+{
+public:
+
+ CPureDeviceStateManager(LPDIRECT3DDEVICE9 pDevice);
+ virtual ~CPureDeviceStateManager();
+
+ STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppv);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ void DirtyCachedValues();
+
+ STDMETHOD(SetRenderState)(D3DRENDERSTATETYPE d3dRenderState, DWORD dwValue);
+ STDMETHOD(SetSamplerState)(DWORD dwStage, D3DSAMPLERSTATETYPE d3dSamplerState, DWORD dwValue);
+ STDMETHOD(SetTextureStageState)(DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTextureStageState, DWORD dwValue);
+ STDMETHOD(SetTexture)(DWORD dwStage, LPDIRECT3DBASETEXTURE9 pTexture);
+ STDMETHOD(SetVertexShader)(LPDIRECT3DVERTEXSHADER9 pShader);
+ STDMETHOD(SetPixelShader)(LPDIRECT3DPIXELSHADER9 pShader);
+ STDMETHOD(SetFVF)(DWORD dwFVF);
+ STDMETHOD(SetTransform)(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix);
+ STDMETHOD(SetMaterial)(CONST D3DMATERIAL9 *pMaterial);
+ STDMETHOD(SetLight)(DWORD Index, CONST D3DLIGHT9 *pLight);
+ STDMETHOD(LightEnable)(DWORD Index, BOOL Enable);
+ STDMETHOD(SetNPatchMode)(FLOAT NumSegments);
+ STDMETHOD(SetVertexShaderConstantF)(UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount);
+ STDMETHOD(SetVertexShaderConstantI)(UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount);
+ STDMETHOD(SetVertexShaderConstantB)(UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount);
+ STDMETHOD(SetPixelShaderConstantF)(UINT RegisterIndex, CONST FLOAT *pConstantData, UINT RegisterCount);
+ STDMETHOD(SetPixelShaderConstantI)(UINT RegisterIndex, CONST INT *pConstantData, UINT RegisterCount);
+ STDMETHOD(SetPixelShaderConstantB)(UINT RegisterIndex, CONST BOOL *pConstantData, UINT RegisterCount);
+
+protected:
+ typedef multicache <DWORD, DWORD> samplerStageCache;
+ typedef multicache <DWORD, DWORD> textureStateStageCache;
+
+protected:
+ LPDIRECT3DDEVICE9 m_pDevice;
+ LONG m_lRef;
+
+ multicache <DWORD, DWORD> m_cacheRenderStates;
+ vector <samplerStageCache> m_vecCacheSamplerStates;
+ vector <textureStateStageCache> m_vecCacheTextureStates;
+};
+
+#endif
344 DirectShowFilters/fontEngine/source/fontEngine.cpp
View
@@ -21,6 +21,7 @@
#include "fontEngine.h"
#include "transformmatrix.h"
+#include "EffectStateManager.h"
using namespace std;
@@ -120,13 +121,14 @@ struct TEXTURE_PLACE
D3DRECT rect[200];
};
-static FONT_DATA_T* fontData = new FONT_DATA_T[MAX_FONTS];
-static TEXTURE_DATA_T* textureData = new TEXTURE_DATA_T[MAX_TEXTURES];
-static LPDIRECT3DDEVICE9 m_pDevice=NULL;
-static int textureZ[MAX_TEXTURES];
-static TEXTURE_PLACE* texturePlace[MAX_TEXTURES];
-static D3DTEXTUREFILTERTYPE m_Filter;
-int textureCount;
+static FONT_DATA_T* fontData = new FONT_DATA_T[MAX_FONTS];
+static TEXTURE_DATA_T* textureData = new TEXTURE_DATA_T[MAX_TEXTURES];
+static LPDIRECT3DDEVICE9 m_pDevice=NULL;
+static CStateManagerInterface* m_pStateManager;
+static int textureZ[MAX_TEXTURES];
+static TEXTURE_PLACE* texturePlace[MAX_TEXTURES];
+static D3DTEXTUREFILTERTYPE m_Filter;
+int textureCount;
static bool inPresentTextures=false;
static vector<int> texturesToBeRemoved;
@@ -139,7 +141,6 @@ int m_iTexturesInUse=0;
int m_iScreenWidth=0;
int m_iScreenHeight=0;
D3DPOOL m_ipoolFormat=D3DPOOL_MANAGED;
-DWORD m_alphaBlend=-1;
void Log(char* txt)
{
@@ -184,7 +185,7 @@ void Cleanup()
}
delete[] textureData;
delete[] fontData;
- return;
+ delete m_pStateManager;
}
//*******************************************************************************************************************
@@ -249,19 +250,26 @@ void FontEngineSetDevice(void* device)
{
m_Filter = D3DTEXF_LINEAR;
}
- m_pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
- m_alphaBlend = -1;
+
+ m_pStateManager = CStateManagerInterface::Create(m_pDevice);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX);
}
//*******************************************************************************************************************
-void FontEngineSetAlphaBlend(DWORD alphaBlend)
+void FontEngineSetRenderState(D3DRENDERSTATETYPE state, DWORD dwValue)
{
- if(alphaBlend!=m_alphaBlend)
- {
- m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE ,alphaBlend);
- m_alphaBlend = alphaBlend;
- }
+ m_pStateManager->SetRenderState(state, dwValue);
+}
+
+void FontEngineSetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE d3dSamplerState, DWORD dwValue)
+{
+ m_pStateManager->SetSamplerState(dwStage, d3dSamplerState, dwValue);
+}
+
+void FontEngineSetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTextureStageState, DWORD dwValue)
+{
+ m_pStateManager->SetTextureStageState(dwStage, d3dTextureStageState, dwValue);
}
//*******************************************************************************************************************
@@ -690,7 +698,7 @@ void FontEngineDrawTexture(int textureNo,float x, float y, float nw, float nh, f
void FontEngineDrawTexture2(int textureNo1,float x, float y, float nw, float nh, float uoff, float voff, float umax, float vmax,
unsigned int color, float m[3][4],
int textureNo2, float uoff2, float voff2, float umax2, float vmax2,
- int blendMode)
+ BLEND_MODE blendMode)
{
if (textureNo1 < 0 || textureNo1>=MAX_TEXTURES) return;
if (textureNo2 < 0 || textureNo2>=MAX_TEXTURES) return;
@@ -891,77 +899,77 @@ void FontEngineDrawTexture2(int textureNo1,float x, float y, float nw, float nh,
verts[3].tv2 = ty1_2;//v2*m_diffuseScaleV;
verts[3].color = color;
- FontEngineSetAlphaBlend(TRUE);
- m_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
- m_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+ m_pStateManager->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
+ m_pStateManager->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
+ m_pStateManager->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
// If clipping is enabled then set the render pipeline to apply the SetScissorRect() setting.
// The caller must have already called SetScissorRect() to set the clipping rectangle.
if (clipEnabled)
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
}
else
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
- if (blendMode > 0)
+ if (blendMode > BLEND_NONE)
{
- m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
- if (blendMode == 1)
+ if (blendMode == BLEND_DIFFUSE)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
}
- else if (blendMode == 2)
+ else if (blendMode == BLEND_OVERLAY)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
}
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
- if (blendMode == 1)
+ if (blendMode == BLEND_DIFFUSE)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
}
- else if (blendMode == 2)
+ else if (blendMode == BLEND_OVERLAY)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
}
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
// Disable the remainder of the texture stages.
- m_pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
}
- m_pDevice->SetTexture(0, texture1->pTexture);
- if (blendMode > 0)
+ m_pStateManager->SetTexture(0, texture1->pTexture);
+ if (blendMode > BLEND_NONE)
{
- m_pDevice->SetTexture(1, texture2->pTexture);
+ m_pStateManager->SetTexture(1, texture2->pTexture);
}
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX2);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX2);
m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX2));
-
- m_pDevice->SetTexture(0, NULL);
- if (blendMode > 0)
+
+ m_pStateManager->SetTexture(0, NULL);
+ if (blendMode > BLEND_NONE)
{
- m_pDevice->SetTexture(1, NULL);
+ m_pStateManager->SetTexture(1, NULL);
}
// Important - the scissor test (for clipping) must be disabled before return.
// Clipping may not be defined other FontEngine calls that draw textures.
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
//*******************************************************************************************************************
@@ -1167,66 +1175,65 @@ void FontEngineDrawMaskedTexture(int textureNo1, float x, float y, float nw, flo
verts[3].tv2 = ty1_2;
verts[3].color = color;
- FontEngineSetAlphaBlend(TRUE);
-
- m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- m_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ m_pStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ m_pStateManager->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
// If clipping is enabled then set the render pipeline to apply the SetScissorRect() setting.
// The caller must have already called SetScissorRect() to set the clipping rectangle.
if (clipEnabled)
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
}
else
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
// This stage simply selects color and alpha from texture1.
// Choose the alpha and color from the current texture (texture1).
- m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
// This stage blends the alpha of texture1 and texture2.
// Select the color from the current texture (the output of stage 1) but select the alpha from the new texture (texture2)
// and modulate (multiply) the alpha values of the new texture (texture2) and the current texture (output of stage 1).
// Alpha values of zero in texture2 (the mask) result in alpha values of zero (transparent pixels) in the output.
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
// This stage blends the masked resultant texture with the background (the diffuse texture).
- m_pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
// Disable the remainder of the texture stages.
- m_pDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- m_pDevice->SetTexture(0, texture1->pTexture);
- m_pDevice->SetTexture(1, texture2->pTexture);
+ m_pStateManager->SetTexture(0, texture1->pTexture);
+ m_pStateManager->SetTexture(1, texture2->pTexture);
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX2);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX2);
m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX2));
- m_pDevice->SetTexture(0, NULL);
- m_pDevice->SetTexture(1, NULL);
+ m_pStateManager->SetTexture(0, NULL);
+ m_pStateManager->SetTexture(1, NULL);
// Important - the scissor test (for clipping) must be disabled before return.
// Clipping may not be defined other FontEngine calls that draw textures.
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
//*******************************************************************************************************************
-// blendMode 0 = ignore/bypass blending operation (completely disregard the use of textureNo2)
-// blendMode 1 = diffuse blending (choose D3DTOP_MODULATE)
-// blendMode 2 = linear blending (choose D3DTOP_BLENDTEXTUREALPHA)
+// BLEND_NONE = ignore/bypass blending operation (completely disregard the use of textureNo2)
+// BLEND_DIFFUSE = diffuse blending (choose D3DTOP_MODULATE)
+// BLEND_OVERLAY = linear blending (choose D3DTOP_BLENDTEXTUREALPHA)
void FontEngineDrawMaskedTexture2(int textureNo1,float x, float y, float nw, float nh, float uoff, float voff, float umax, float vmax,
unsigned int color, float m[3][4],
int textureNo2, float uoff2, float voff2, float umax2, float vmax2,
@@ -1464,89 +1471,88 @@ void FontEngineDrawMaskedTexture2(int textureNo1,float x, float y, float nw, flo
verts[3].tv3 = ty1_3;
verts[3].color = color;
- FontEngineSetAlphaBlend(TRUE);
-
- m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- m_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+ m_pStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+ m_pStateManager->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
// If clipping is enabled then set the render pipeline to apply the SetScissorRect() setting.
// The caller must have already called SetScissorRect() to set the clipping rectangle.
if (clipEnabled)
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
}
else
{
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
if (blendMode > 0)
{
// This stage blends the color and alpha of the current texture (texture1) with the background (diffuse image).
- m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
// This stage blends the alpha of result of the last stage with texture2 (our own alpha mask).
if (blendMode == 1)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
}
else if (blendMode == 2)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
}
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
if (blendMode == 1)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
}
else if (blendMode == 2)
{
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
}
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
// This stage selects the color of the mask (arg1 = texture3) and blends it with the result of the
// last stage (our alpha adjusted texture).
- m_pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
- m_pDevice->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_CURRENT);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
// This stage blends the masked resultant texture with the background (the diffuse texture).
- m_pDevice->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(3, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(3, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(3, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
// Disable the remainder of the texture stages.
- m_pDevice->SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pDevice->SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
}
- m_pDevice->SetTexture(0, texture1->pTexture);
- m_pDevice->SetTexture(1, texture2->pTexture);
- m_pDevice->SetTexture(2, texture3->pTexture);
+ m_pStateManager->SetTexture(0, texture1->pTexture);
+ m_pStateManager->SetTexture(1, texture2->pTexture);
+ m_pStateManager->SetTexture(2, texture3->pTexture);
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX3);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX3);
m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(CUSTOMVERTEX3));
- m_pDevice->SetTexture(0, NULL);
- m_pDevice->SetTexture(1, NULL);
- m_pDevice->SetTexture(2, NULL);
+ m_pStateManager->SetTexture(0, NULL);
+ m_pStateManager->SetTexture(1, NULL);
+ m_pStateManager->SetTexture(2, NULL);
// Important - the scissor test (for clipping) must be disabled before return.
// Clipping may not be defined other FontEngine calls that draw textures.
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
//*******************************************************************************************************************
@@ -1562,26 +1568,24 @@ void FontEnginePresentTextures()
try
{
if (textureCount > 0)
- {
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
-
+ {
// Set the texture blending operations for default rendering.
- m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
-
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
-
- m_pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
+
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
for (int i=0; i < textureCount; ++i)
{
@@ -1597,17 +1601,10 @@ void FontEnginePresentTextures()
{
m_iTexturesInUse++;
- if (texture->useAlphaBlend)
- {
- FontEngineSetAlphaBlend(TRUE);
- }
- else
- {
- FontEngineSetAlphaBlend(FALSE);
- }
-
- m_pDevice->SetTexture(0, texture->pTexture);
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
+ m_pStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, texture->useAlphaBlend ? 1 : 0);
+ m_pStateManager->SetTexture(0, texture->pTexture);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX);
+
WORD* pIndices = NULL;
texture->pIndexBuffer->Lock(0, 0, (VOID**)&pIndices, D3DLOCK_READONLY);
@@ -1960,27 +1957,28 @@ void FontEnginePresent3D(int fontNumber)
if (font->dwNumTriangles !=0)
{
// Set the texture blending operations for default rendering.
- m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
-
- m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
- m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
-
- m_pDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
- m_pDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
- FontEngineSetAlphaBlend(1);
- m_pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
- m_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
- m_pDevice->SetTexture(0, font->pTexture);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
+ m_pStateManager->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
+
+ m_pStateManager->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ m_pStateManager->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+ m_pStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+ m_pStateManager->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
+ m_pStateManager->SetFVF(D3DFVF_CUSTOMVERTEX);
+ m_pStateManager->SetTexture(0, font->pTexture);
+
WORD* pIndices = NULL;
font->pIndexBuffer->Lock(0, 0, (VOID**)&pIndices, D3DLOCK_READONLY);
@@ -2046,7 +2044,7 @@ void FontEngineSetTexture(void* surface)
//LPDIRECT3DTEXTURE9 pTexture = (LPDIRECT3DTEXTURE9)pContainer;
LPDIRECT3DTEXTURE9 pTexture = (LPDIRECT3DTEXTURE9)surface;
- m_pDevice->SetTexture(0, pTexture);
+ m_pStateManager->SetTexture(0, pTexture);
//pTexture->Release();
}
catch(...)
@@ -2063,7 +2061,7 @@ void FontEngineDrawSurface( int fx, int fy, int nw, int nh, int dstX, int dstY,
{
IDirect3DSurface9* pBackBuffer;
- FontEngineSetAlphaBlend(FALSE);
+ m_pStateManager->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
m_pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
LPDIRECT3DSURFACE9 pSurface = (LPDIRECT3DSURFACE9)surface;
8 DirectShowFilters/fontEngine/source/fontEngine.def
View
@@ -19,6 +19,8 @@ FontEngineSetDevice @14
FontEngineDrawTexture2 @15
FontEngineDrawMaskedTexture @16
FontEngineDrawMaskedTexture2 @17
-FontEngineSetAlphaBlend @18
-FontEngineSetClipEnable @19
-FontEngineSetClipDisable @20
+FontEngineSetClipEnable @18
+FontEngineSetClipDisable @19
+FontEngineSetRenderState @20
+FontEngineSetSamplerState @21
+FontEngineSetTextureStageState @22
11 DirectShowFilters/fontEngine/source/fontEngine.h
View
@@ -14,6 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+enum BLEND_MODE
+{
+ BLEND_NONE = 0,
+ BLEND_DIFFUSE = 1,
+ BLEND_OVERLAY = 2
+};
+
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the FONTENGINE_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
@@ -48,5 +55,9 @@ void FontEngineDrawSurface( int fx, int fy, int nw, int nh,
void FontEngineSetClipEnable();
void FontEngineSetClipDisable();
+void FontEngineSetRenderState(D3DRENDERSTATETYPE state, DWORD dwValue);
+void FontEngineSetSamplerState(DWORD dwStage, D3DSAMPLERSTATETYPE d3dSamplerState, DWORD dwValue);
+void FontEngineSetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTextureStageState, DWORD dwValue);
+
void PrintStatistics();
void Cleanup();
2  mediaportal/Core/Core.csproj
View
@@ -334,6 +334,7 @@
<Compile Include="ExtensionMethods\ListExtMethods.cs" />
<Compile Include="ExtensionMethods\DictionaryExtMethods.cs" />
<Compile Include="ExtensionMethods\ObjectMethods.cs" />
+ <Compile Include="guilib\DXNative.cs" />
<Compile Include="guilib\ExpressionManager.cs" />
<Compile Include="guilib\Functions.cs" />
<Compile Include="guilib\FontObject.cs" />
@@ -486,6 +487,7 @@
<Compile Include="UserInterfaceControls\MPToolTip.cs">
<SubType>Component</SubType>
</Compile>
+ <Compile Include="guilib\DXEnums.cs" />
<Compile Include="Util\EncryptDecrypt.cs" />
<Compile Include="Util\FanArt.cs" />
<Compile Include="Util\FastImage.cs" />
9 mediaportal/Core/Player/BDOSDRenderer.cs
View
@@ -28,10 +28,7 @@ namespace MediaPortal.Player
{
public class BDOSDRenderer
{
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetAlphaBlend(UInt32 alphaBlend);
-
- private static BDOSDRenderer _instance;
+ private static BDOSDRenderer _instance;
/// <summary>
/// The coordinates of current vertex buffer
@@ -135,8 +132,8 @@ public void Render()
wx = GUIGraphicsContext.VideoWindow.Right - (GUIGraphicsContext.VideoWindow.Width);
wy = GUIGraphicsContext.VideoWindow.Top;
}
-
- FontEngineSetAlphaBlend(1); //TRUE
+
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 1);
CreateVertexBuffer(wx, wy, wwidth, wheight);
// Make sure D3D objects haven't been disposed for some reason. This would cause
25 mediaportal/Core/Player/PlaneScene.cs
View
@@ -50,16 +50,6 @@ namespace MediaPortal.Player
/// </summary>
public class PlaneScene : IVMR9PresentCallback, IRenderLayer
{
- #region imports
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetTexture(void* texture);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetAlphaBlend(UInt32 alphaBlend);
-
- #endregion
-
#region variables
private bool _stopPainting = false;
@@ -733,16 +723,17 @@ private void DrawTexture(uint texAddr, long lColorDiffuse)
unsafe
{
IntPtr ptr = new IntPtr(texAddr);
- FontEngineSetTexture(ptr.ToPointer());
+ DXNative.FontEngineSetTexture(ptr.ToPointer());
+
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_ADDRESSU, (int)D3DTEXTUREADDRESS.D3DTADDRESS_CLAMP);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_ADDRESSV, (int)D3DTEXTUREADDRESS.D3DTADDRESS_CLAMP);
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].AddressU = TextureAddress.Clamp;
- GUIGraphicsContext.DX9Device.SamplerState[0].AddressV = TextureAddress.Clamp;
GUIGraphicsContext.DX9Device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
- FontEngineSetAlphaBlend(0); //FALSE
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 0);
if (_useNonLinearStretch)
{
5 mediaportal/Core/Player/Subtitles/SubtitleRenderer.cs
View
@@ -186,9 +186,6 @@ public interface IDVBSubtitleSource
public class SubtitleRenderer
{
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetAlphaBlend(UInt32 alphaBlend);
-
private bool _useBitmap = false; // if false use teletext
private int _activeSubPage = -1; // if use teletext, what page
private static SubtitleRenderer _instance = null;
@@ -797,7 +794,7 @@ public void Render()
// Log.Debug("Subtitle render target: wx = {0} wy = {1} ww = {2} wh = {3}", wx, wy, wwidth, wheight);
// enable alpha blending so that the subtitle is rendered with transparent background
- FontEngineSetAlphaBlend(1); //TRUE
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHABLENDENABLE, 1);
// Make sure D3D objects haven't been disposed for some reason. This would cause
// an access violation on native side, causing Skin Engine to halt rendering
92 mediaportal/Core/Util/Picture.cs
View
@@ -24,6 +24,7 @@
using System.IO;
using System.Threading;
using System.Windows.Forms;
+using System.Runtime.InteropServices;
using MediaPortal.ExtensionMethods;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
@@ -401,18 +402,18 @@ public static Texture ConvertImageToTexture(Bitmap theImage, out int iWidth, out
GUIGraphicsContext.DX9Device.SetTexture(0, texture);
int g_nAnisotropy = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
float g_fMipMapLodBias = 0.0f;
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipMapLevelOfDetailBias = g_fMipMapLodBias;
- GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipMapLevelOfDetailBias = g_fMipMapLodBias;
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
// Render the image
GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
@@ -556,18 +557,17 @@ public static Texture ConvertImageToTexture(Bitmap theImage, out int iWidth, out
GUIGraphicsContext.DX9Device.SetTexture(0, texture);
int g_nAnisotropy = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
float g_fMipMapLodBias = 0.0f;
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipMapLevelOfDetailBias = g_fMipMapLodBias;
-
- GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipMapLevelOfDetailBias = g_fMipMapLodBias;
-
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
+
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
// Render the image
GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
@@ -709,30 +709,40 @@ public static Texture ConvertImageToTexture(Bitmap theImage, out int iWidth, out
GUIGraphicsContext.DX9Device.SetTexture(0, texture);
- GUIGraphicsContext.DX9Device.TextureState[0].ColorOperation = Direct3D.TextureOperation.Modulate;
- GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument1 = Direct3D.TextureArgument.TextureColor;
- GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument2 = Direct3D.TextureArgument.Diffuse;
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);
+
+
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
+
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaOperation = Direct3D.TextureOperation.Modulate;
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument1 = Direct3D.TextureArgument.TextureColor;
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument2 = Direct3D.TextureArgument.Diffuse;
- GUIGraphicsContext.DX9Device.TextureState[1].ColorOperation = Direct3D.TextureOperation.Disable;
- GUIGraphicsContext.DX9Device.TextureState[1].AlphaOperation = Direct3D.TextureOperation.Disable;
+ DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
+ DXNative.FontEngineSetTextureStageState(1, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_DISABLE);
int g_nAnisotropy = GUIGraphicsContext.DX9Device.DeviceCaps.MaxAnisotropy;
float g_fMipMapLodBias = 0.0f;
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipMapLevelOfDetailBias = g_fMipMapLodBias;
-
- GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipMapLevelOfDetailBias = g_fMipMapLodBias;
+
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (uint)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
+
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPMAPLODBIAS, (uint)g_fMipMapLodBias);
// Render the image
GUIGraphicsContext.DX9Device.SetStreamSource(0, m_vbBuffer, 0);
52 mediaportal/Core/guilib/CachedTexture.cs
View
@@ -38,38 +38,6 @@ namespace MediaPortal.GUI.Library
/// </summary>
public class CachedTexture : IDisposable
{
- #region imports
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineRemoveTexture(int textureNo);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe int FontEngineAddTexture(int hasCode, bool useAlphaBlend, void* fontTexture);
-
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawTexture(int textureNo, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax, uint color,
- float[,] matrix);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawMaskedTexture(int textureNo1, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax,
- uint color,
- float[,] matrix, int textureNo2, float uoff2,
- float voff2,
- float umax2, float vmax2);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawTexture2(int textureNo1, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax,
- uint color,
- float[,] matrix, int textureNo2, float uoff2,
- float voff2,
- float umax2, float vmax2,
- GUIImage.FontEngineBlendMode blendMode);
- #endregion
-
#region events / delegates
public event EventHandler Disposed;
@@ -116,7 +84,7 @@ public Frame(string name, Texture image, int duration)
_image.Disposing -= new EventHandler(D3DTexture_Disposing);
_image.Disposing += new EventHandler(D3DTexture_Disposing);
IntPtr ptr = DirectShowUtil.GetUnmanagedTexture(_image);
- _textureNumber = FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
+ _textureNumber = DXNative.FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
if (logTextures)
{
Log.Info("Frame:ctor() fontengine: added texture:{0} {1}", _textureNumber.ToString(), _imageName);
@@ -172,7 +140,7 @@ public Texture Image
unsafe
{
IntPtr ptr = DirectShowUtil.GetUnmanagedTexture(_image);
- _textureNumber = FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
+ _textureNumber = DXNative.FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
if (logTextures)
{
Log.Info("Frame:Image fontengine: added texture:{0} {1}", _textureNumber.ToString(), _imageName);
@@ -254,7 +222,7 @@ private void DisposeUnmanagedResources()
{
if (_textureNumber >= 0)
{
- FontEngineRemoveTexture(_textureNumber);
+ DXNative.FontEngineRemoveTexture(_textureNumber);
_textureNumber = -1;
}
@@ -298,7 +266,7 @@ public void Draw(float x, float y, float nw, float nh, float uoff, float voff, f
if (_textureNumber >= 0)
{
float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
- FontEngineDrawTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color, matrix);
+ DXNative.FontEngineDrawTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color, matrix);
}
else
{
@@ -333,7 +301,7 @@ public void Draw(float x, float y, float nw, float nh, float uoff, float voff, f
TransformMatrix finalTransform = GUIGraphicsContext.GetFinalTransform();
localTransform = finalTransform.multiply(localTransform);
- FontEngineDrawTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color, localTransform.Matrix);
+ DXNative.FontEngineDrawTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax, color, localTransform.Matrix);
}
else
{
@@ -364,7 +332,7 @@ public void Draw(float x, float y, float nw, float nh, float uoff, float voff, f
/// <param name="vmaxd"></param>
public void Draw(float x, float y, float nw, float nh, float zrot, float uoff, float voff, float umax, float vmax,
uint color, int blendableTextureNo, float uoffd, float voffd, float umaxd, float vmaxd,
- GUIImage.FontEngineBlendMode blendMode)
+ FontEngineBlendMode blendMode)
{
if (_textureNumber >= 0)
{
@@ -374,7 +342,7 @@ public void Draw(float x, float y, float nw, float nh, float uoff, float voff, f
TransformMatrix finalTransform = GUIGraphicsContext.GetFinalTransform();
localTransform = finalTransform.multiply(localTransform);
- FontEngineDrawTexture2(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax,
+ DXNative.FontEngineDrawTexture2(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax,
color, localTransform.Matrix,
blendableTextureNo, uoffd, voffd, umaxd, vmaxd,
blendMode);
@@ -411,9 +379,9 @@ public void Draw(float x, float y, float nw, float nh, float uoff, float voff, f
if (_textureNumber >= 0)
{
float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
- FontEngineDrawMaskedTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax,
- color, matrix,
- maskTextureNo, uoffm, voffm, umaxm, vmaxm);
+ DXNative.FontEngineDrawMaskedTexture(_textureNumber, x, y, nw, nh, uoff, voff, umax, vmax,
+ color, matrix,
+ maskTextureNo, uoffm, voffm, umaxm, vmaxm);
}
else
{
287 mediaportal/Core/guilib/DXEnums.cs
View
@@ -0,0 +1,287 @@
+// Copyright (C) 2005-2012 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+using System;
+
+namespace MediaPortal
+{
+ public enum D3DRENDERSTATETYPE : int
+ {
+ D3DRS_ZENABLE = 7,
+ D3DRS_FILLMODE = 8,
+ D3DRS_SHADEMODE = 9,
+ D3DRS_ZWRITEENABLE = 14,
+ D3DRS_ALPHATESTENABLE = 15,
+ D3DRS_LASTPIXEL = 16,
+ D3DRS_SRCBLEND = 19,
+ D3DRS_DESTBLEND = 20,
+ D3DRS_CULLMODE = 22,
+ D3DRS_ZFUNC = 23,
+ D3DRS_ALPHAREF = 24,
+ D3DRS_ALPHAFUNC = 25,
+ D3DRS_DITHERENABLE = 26,
+ D3DRS_ALPHABLENDENABLE = 27,
+ D3DRS_FOGENABLE = 28,
+ D3DRS_SPECULARENABLE = 29,
+ D3DRS_FOGCOLOR = 34,
+ D3DRS_FOGTABLEMODE = 35,
+ D3DRS_FOGSTART = 36,
+ D3DRS_FOGEND = 37,
+ D3DRS_FOGDENSITY = 38,
+ D3DRS_RANGEFOGENABLE = 48,
+ D3DRS_STENCILENABLE = 52,
+ D3DRS_STENCILFAIL = 53,
+ D3DRS_STENCILZFAIL = 54,
+ D3DRS_STENCILPASS = 55,
+ D3DRS_STENCILFUNC = 56,
+ D3DRS_STENCILREF = 57,
+ D3DRS_STENCILMASK = 58,
+ D3DRS_STENCILWRITEMASK = 59,
+ D3DRS_TEXTUREFACTOR = 60,
+ D3DRS_WRAP0 = 128,
+ D3DRS_WRAP1 = 129,
+ D3DRS_WRAP2 = 130,
+ D3DRS_WRAP3 = 131,
+ D3DRS_WRAP4 = 132,
+ D3DRS_WRAP5 = 133,
+ D3DRS_WRAP6 = 134,
+ D3DRS_WRAP7 = 135,
+ D3DRS_CLIPPING = 136,
+ D3DRS_LIGHTING = 137,
+ D3DRS_AMBIENT = 139,
+ D3DRS_FOGVERTEXMODE = 140,
+ D3DRS_COLORVERTEX = 141,
+ D3DRS_LOCALVIEWER = 142,
+ D3DRS_NORMALIZENORMALS = 143,
+ D3DRS_DIFFUSEMATERIALSOURCE = 145,
+ D3DRS_SPECULARMATERIALSOURCE = 146,
+ D3DRS_AMBIENTMATERIALSOURCE = 147,
+ D3DRS_EMISSIVEMATERIALSOURCE = 148,
+ D3DRS_VERTEXBLEND = 151,
+ D3DRS_CLIPPLANEENABLE = 152,
+ D3DRS_POINTSIZE = 154,
+ D3DRS_POINTSIZE_MIN = 155,
+ D3DRS_POINTSPRITEENABLE = 156,
+ D3DRS_POINTSCALEENABLE = 157,
+ D3DRS_POINTSCALE_A = 158,
+ D3DRS_POINTSCALE_B = 159,
+ D3DRS_POINTSCALE_C = 160,
+ D3DRS_MULTISAMPLEANTIALIAS = 161,
+ D3DRS_MULTISAMPLEMASK = 162,
+ D3DRS_PATCHEDGESTYLE = 163,
+ D3DRS_DEBUGMONITORTOKEN = 165,
+ D3DRS_POINTSIZE_MAX = 166,
+ D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
+ D3DRS_COLORWRITEENABLE = 168,
+ D3DRS_TWEENFACTOR = 170,
+ D3DRS_BLENDOP = 171,
+ D3DRS_POSITIONDEGREE = 172,
+ D3DRS_NORMALDEGREE = 173,
+ D3DRS_SCISSORTESTENABLE = 174,
+ D3DRS_SLOPESCALEDEPTHBIAS = 175,
+ D3DRS_ANTIALIASEDLINEENABLE = 176,
+ D3DRS_MINTESSELLATIONLEVEL = 178,
+ D3DRS_MAXTESSELLATIONLEVEL = 179,
+ D3DRS_ADAPTIVETESS_X = 180,
+ D3DRS_ADAPTIVETESS_Y = 181,
+ D3DRS_ADAPTIVETESS_Z = 182,
+ D3DRS_ADAPTIVETESS_W = 183,
+ D3DRS_ENABLEADAPTIVETESSELLATION = 184,
+ D3DRS_TWOSIDEDSTENCILMODE = 185,
+ D3DRS_CCW_STENCILFAIL = 186,
+ D3DRS_CCW_STENCILZFAIL = 187,
+ D3DRS_CCW_STENCILPASS = 188,
+ D3DRS_CCW_STENCILFUNC = 189,
+ D3DRS_COLORWRITEENABLE1 = 190,
+ D3DRS_COLORWRITEENABLE2 = 191,
+ D3DRS_COLORWRITEENABLE3 = 192,
+ D3DRS_BLENDFACTOR = 193,
+ D3DRS_SRGBWRITEENABLE = 194,
+ D3DRS_DEPTHBIAS = 195,
+ D3DRS_WRAP8 = 198,
+ D3DRS_WRAP9 = 199,
+ D3DRS_WRAP10 = 200,
+ D3DRS_WRAP11 = 201,
+ D3DRS_WRAP12 = 202,
+ D3DRS_WRAP13 = 203,
+ D3DRS_WRAP14 = 204,
+ D3DRS_WRAP15 = 205,
+ D3DRS_SEPARATEALPHABLENDENABLE = 206,
+ D3DRS_SRCBLENDALPHA = 207,
+ D3DRS_DESTBLENDALPHA = 208,
+ D3DRS_BLENDOPALPHA = 209,
+ D3DRS_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DTEXTURESTAGESTATETYPE : int
+ {
+ D3DTSS_COLOROP = 1,
+ D3DTSS_COLORARG1 = 2,
+ D3DTSS_COLORARG2 = 3,
+ D3DTSS_ALPHAOP = 4,
+ D3DTSS_ALPHAARG1 = 5,
+ D3DTSS_ALPHAARG2 = 6,
+ D3DTSS_BUMPENVMAT00 = 7,
+ D3DTSS_BUMPENVMAT01 = 8,
+ D3DTSS_BUMPENVMAT10 = 9,
+ D3DTSS_BUMPENVMAT11 = 10,
+ D3DTSS_TEXCOORDINDEX = 11,
+ D3DTSS_BUMPENVLSCALE = 22,
+ D3DTSS_BUMPENVLOFFSET = 23,
+ D3DTSS_TEXTURETRANSFORMFLAGS = 24,
+ D3DTSS_COLORARG0 = 26,
+ D3DTSS_ALPHAARG0 = 27,
+ D3DTSS_RESULTARG = 28,
+ D3DTSS_CONSTANT = 32,
+ D3DTSS_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DSAMPLERSTATETYPE : int
+ {
+ D3DSAMP_ADDRESSU = 1,
+ D3DSAMP_ADDRESSV = 2,
+ D3DSAMP_ADDRESSW = 3,
+ D3DSAMP_BORDERCOLOR = 4,
+ D3DSAMP_MAGFILTER = 5,
+ D3DSAMP_MINFILTER = 6,
+ D3DSAMP_MIPFILTER = 7,
+ D3DSAMP_MIPMAPLODBIAS = 8,
+ D3DSAMP_MAXMIPLEVEL = 9,
+ D3DSAMP_MAXANISOTROPY = 10,
+ D3DSAMP_SRGBTEXTURE = 11,
+ D3DSAMP_ELEMENTINDEX = 12,
+ D3DSAMP_DMAPOFFSET = 13,
+ D3DSAMP_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DCULL : int
+ {
+ D3DCULL_NONE = 1,
+ D3DCULL_CW = 2,
+ D3DCULL_CCW = 3,
+ D3DCULL_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DFILLMODE : int
+ {
+ D3DFILL_POINT = 1,
+ D3DFILL_WIREFRAME = 2,
+ D3DFILL_SOLID = 3,
+ D3DFILL_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DBLEND : int
+ {
+ D3DBLEND_ZERO = 1,
+ D3DBLEND_ONE = 2,
+ D3DBLEND_SRCCOLOR = 3,
+ D3DBLEND_INVSRCCOLOR = 4,
+ D3DBLEND_SRCALPHA = 5,
+ D3DBLEND_INVSRCALPHA = 6,
+ D3DBLEND_DESTALPHA = 7,
+ D3DBLEND_INVDESTALPHA = 8,
+ D3DBLEND_DESTCOLOR = 9,
+ D3DBLEND_INVDESTCOLOR = 10,
+ D3DBLEND_SRCALPHASAT = 11,
+ D3DBLEND_BOTHSRCALPHA = 12,
+ D3DBLEND_BOTHINVSRCALPHA = 13,
+ D3DBLEND_BLENDFACTOR = 14,
+ D3DBLEND_INVBLENDFACTOR = 15,
+ D3DBLEND_SRCCOLOR2 = 16,
+ D3DBLEND_INVSRCCOLOR2 = 17,
+ D3DBLEND_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DTEXTUREOP : int
+ {
+ D3DTOP_DISABLE = 1,
+ D3DTOP_SELECTARG1 = 2,
+ D3DTOP_SELECTARG2 = 3,
+ D3DTOP_MODULATE = 4,
+ D3DTOP_MODULATE2X = 5,
+ D3DTOP_MODULATE4X = 6,
+ D3DTOP_ADD = 7,
+ D3DTOP_ADDSIGNED = 8,
+ D3DTOP_ADDSIGNED2X = 9,
+ D3DTOP_SUBTRACT = 10,
+ D3DTOP_ADDSMOOTH = 11,
+ D3DTOP_BLENDDIFFUSEALPHA = 12,
+ D3DTOP_BLENDTEXTUREALPHA = 13,
+ D3DTOP_BLENDFACTORALPHA = 14,
+ D3DTOP_BLENDTEXTUREALPHAPM = 15,
+ D3DTOP_BLENDCURRENTALPHA = 16,
+ D3DTOP_PREMODULATE = 17,
+ D3DTOP_MODULATEALPHA_ADDCOLOR = 18,
+ D3DTOP_MODULATECOLOR_ADDALPHA = 19,
+ D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
+ D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
+ D3DTOP_BUMPENVMAP = 22,
+ D3DTOP_BUMPENVMAPLUMINANCE = 23,
+ D3DTOP_DOTPRODUCT3 = 24,
+ D3DTOP_MULTIPLYADD = 25,
+ D3DTOP_LERP = 26,
+ D3DTOP_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DTEXTUREFILTERTYPE : int
+ {
+ D3DTEXF_NONE = 0,
+ D3DTEXF_POINT = 1,
+ D3DTEXF_LINEAR = 2,
+ D3DTEXF_ANISOTROPIC = 3,
+ D3DTEXF_PYRAMIDALQUAD = 6,
+ D3DTEXF_GAUSSIANQUAD = 7,
+ D3DTEXF_CONVOLUTIONMONO = 8,
+ D3DTEXF_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DCMPFUNC : int
+ {
+ D3DCMP_NEVER = 1,
+ D3DCMP_LESS = 2,
+ D3DCMP_EQUAL = 3,
+ D3DCMP_LESSEQUAL = 4,
+ D3DCMP_GREATER = 5,
+ D3DCMP_NOTEQUAL = 6,
+ D3DCMP_GREATEREQUAL = 7,
+ D3DCMP_ALWAYS = 8,
+ D3DCMP_FORCE_DWORD = 0x7fffffff
+ }
+
+ public enum D3DTA : int
+ {
+ D3DTA_SELECTMASK = 0x0000000f,
+ D3DTA_DIFFUSE = 0x00000000,
+ D3DTA_CURRENT = 0x00000001,
+ D3DTA_TEXTURE = 0x00000002,
+ D3DTA_TFACTOR = 0x00000003,
+ D3DTA_SPECULAR = 0x00000004,
+ D3DTA_TEMP = 0x00000005,
+ D3DTA_CONSTANT = 0x00000006,
+ D3DTA_COMPLEMENT = 0x00000010,
+ D3DTA_ALPHAREPLICATE = 0x00000020
+ }
+
+ public enum D3DTEXTUREADDRESS
+ {
+ D3DTADDRESS_WRAP = 1,
+ D3DTADDRESS_MIRROR = 2,
+ D3DTADDRESS_CLAMP = 3,
+ D3DTADDRESS_BORDER = 4,
+ D3DTADDRESS_MIRRORONCE = 5,
+ D3DTADDRESS_FORCE_DWORD = 0x7fffffff
+ }
+}
128 mediaportal/Core/guilib/DXNative.cs
View
@@ -0,0 +1,128 @@
+#region Copyright (C) 2005-2012 Team MediaPortal
+
+// Copyright (C) 2005-2011 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#endregion
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace MediaPortal
+{
+ public enum FontEngineBlendMode
+ {
+ BLEND_NONE = 0,
+ BLEND_DIFFUSE = 1,
+ BLEND_OVERLAY = 2
+ }
+}
+
+namespace MediaPortal.GUI.Library
+{
+ /// <summary>
+ /// A proxy class which handles all native fontEngine.dll calls
+ /// </summary>
+ public class DXNative
+ {
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineInitialize(int iScreenWidth, int iScreenHeight, int poolFormat);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetRenderState(Int32 state, System.UInt32 dwValue);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetSamplerState(System.UInt32 dwStage, Int32 state, System.UInt32 dwValue);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetTextureStageState(System.UInt32 dwStage, Int32 state, System.UInt32 dwValue);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetTexture(void* texture);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineRemoveTexture(int textureNo);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe int FontEngineAddTexture(int hasCode, bool useAlphaBlend, void* fontTexture);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineDrawTexture(int textureNo, float x, float y, float nw, float nh,
+ float uoff, float voff, float umax, float vmax, uint color,
+ float[,] matrix);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineDrawMaskedTexture(int textureNo1, float x, float y, float nw, float nh,
+ float uoff, float voff, float umax, float vmax,
+ uint color,
+ float[,] matrix, int textureNo2, float uoff2,
+ float voff2,
+ float umax2, float vmax2);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineDrawMaskedTexture2(int textureNo1, float x, float y, float nw, float nh,
+ float uoff, float voff, float umax, float vmax,
+ uint color,
+ float[,] matrix, int textureNo2, float uoff2,
+ float voff2,
+ float umax2, float vmax2, int textureNo3, float uoff3,
+ float voff3, float umax3, float vmax3,
+ FontEngineBlendMode blendMode);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineDrawTexture2(int textureNo1, float x, float y, float nw, float nh,
+ float uoff, float voff, float umax, float vmax,
+ uint color,
+ float[,] matrix, int textureNo2, float uoff2,
+ float voff2,
+ float umax2, float vmax2,
+ FontEngineBlendMode blendMode);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEnginePresentTextures();
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetDevice(void* device);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetClipEnable();
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetClipDisable();
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineAddFont(int fontNumber, void* fontTexture, int firstChar, int endChar,
+ float textureScale, float textureWidth, float textureHeight,
+ float fSpacingPerChar, int maxVertices);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineRemoveFont(int fontNumber);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineSetCoordinate(int fontNumber, int index, int subindex, float fValue1,
+ float fValue2, float fValue3, float fValue4);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEngineDrawText3D(int fontNumber, void* text, int xposStart, int yposStart,
+ uint intColor, int maxWidth, float[,] matrix);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe void FontEnginePresent3D(int fontNumber);
+
+ [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern unsafe int FontEngineSetMaximumFrameLatency(uint maxLatency);
+ }
+}
53 mediaportal/Core/guilib/GUIFont.cs
View
@@ -71,33 +71,6 @@ public IntPtr ptr
/// </summary>
public class GUIFont : IDisposable
{
- #region imports
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineInitialize(int iScreenWidth, int iScreenHeight, int poolFormat);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineAddFont(int fontNumber, void* fontTexture, int firstChar, int endChar,
- float textureScale, float textureWidth, float textureHeight,
- float fSpacingPerChar, int maxVertices);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineRemoveFont(int fontNumber);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetCoordinate(int fontNumber, int index, int subindex, float fValue1,
- float fValue2, float fValue3, float fValue4);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawText3D(int fontNumber, void* text, int xposStart, int yposStart,
- uint intColor, int maxWidth, float[,] matrix);
-
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEnginePresent3D(int fontNumber);
-
- #endregion
-
#region enums
// Font rendering flags
@@ -154,7 +127,7 @@ public GUIFont(string fontName, string fileName, int fontHeight)
: this()
{
//Log.Debug("GUIFont:ctor({0}) fontengine: Initialize()", fontName);
- FontEngineInitialize(GUIGraphicsContext.Width, GUIGraphicsContext.Height,
+ DXNative.FontEngineInitialize(GUIGraphicsContext.Width, GUIGraphicsContext.Height,
(int)GUIGraphicsContext.GetTexturePoolType());
_fontName = fontName;
_fileName = fileName;
@@ -172,7 +145,7 @@ public GUIFont(string fontName, string fileName, int iHeight, FontStyle style)
: this()
{
//Log.Debug("GUIFont:ctor({0}) fontengine: Initialize()", fontName);
- FontEngineInitialize(GUIGraphicsContext.Width, GUIGraphicsContext.Height,
+ DXNative.FontEngineInitialize(GUIGraphicsContext.Width, GUIGraphicsContext.Height,
(int)GUIGraphicsContext.GetTexturePoolType());
_fontName = fontName;
_fileName = fileName;
@@ -473,7 +446,7 @@ public void Present()
{
if (ID >= 0)
{
- FontEnginePresent3D(ID);
+ DXNative.FontEnginePresent3D(ID);
}
}
@@ -851,8 +824,8 @@ public void DrawTextEx(float xpos, float ypos, long color, string text, ref Font
{
float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
- FontEngineDrawText3D(ID, (void*)(context.ptr.ToPointer()), (int)xpos, (int)ypos, (uint)color, maxWidth,
- matrix);
+ DXNative.FontEngineDrawText3D(ID, (void*)(context.ptr.ToPointer()), (int)xpos, (int)ypos, (uint)color, maxWidth,
+ matrix);
return;
}
}
@@ -908,8 +881,8 @@ protected void DrawText(float xpos, float ypos, Color color, string text, Render
float[,] matrix = GUIGraphicsContext.GetFinalMatrix();
IntPtr ptrStr = Marshal.StringToCoTaskMemUni(text); //SLOW
- FontEngineDrawText3D(ID, (void*)(ptrStr.ToPointer()), (int)xpos, (int)ypos, (uint)intColor, maxWidth,
- matrix);
+ DXNative.FontEngineDrawText3D(ID, (void*)(ptrStr.ToPointer()), (int)xpos, (int)ypos, (uint)intColor, maxWidth,
+ matrix);
Marshal.FreeCoTaskMem(ptrStr);
return;
}
@@ -1045,7 +1018,7 @@ public void Dispose(object sender, EventArgs e)
//Log.Debug("GUIFont:Dispose({0}) fontengine: Remove font:{1}", _fontName, ID.ToString());
if (ID >= 0)
{
- FontEngineRemoveFont(ID);
+ DXNative.FontEngineRemoveFont(ID);
}
}
_fontAdded = false;
@@ -1289,7 +1262,7 @@ private void _textureFont_Disposing(object sender, EventArgs e)
_textureFont = null;
if (_fontAdded && ID >= 0)
{
- FontEngineRemoveFont(ID);
+ DXNative.FontEngineRemoveFont(ID);
}
_fontAdded = false;
}
@@ -1314,15 +1287,15 @@ public void SetFontEgine()
IntPtr upTexture = DirectShowUtil.GetUnmanagedTexture(_textureFont);
unsafe
{
- FontEngineAddFont(ID, upTexture.ToPointer(), _StartCharacter, _EndCharacter, _textureScale, _textureWidth,
- _textureHeight, _spacingPerChar, MaxNumfontVertices);
+ DXNative.FontEngineAddFont(ID, upTexture.ToPointer(), _StartCharacter, _EndCharacter, _textureScale, _textureWidth,
+ _textureHeight, _spacingPerChar, MaxNumfontVertices);
}
int length = _textureCoords.GetLength(0);
for (int i = 0; i < length; ++i)
{
- FontEngineSetCoordinate(ID, i, 0, _textureCoords[i, 0], _textureCoords[i, 1], _textureCoords[i, 2],
- _textureCoords[i, 3]);
+ DXNative.FontEngineSetCoordinate(ID, i, 0, _textureCoords[i, 0], _textureCoords[i, 1], _textureCoords[i, 2],
+ _textureCoords[i, 3]);
}
_fontAdded = true;
}
14 mediaportal/Core/guilib/GUIFontManager.cs
View
@@ -43,12 +43,6 @@ namespace MediaPortal.GUI.Library
/// </summary>
public class GUIFontManager
{
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEnginePresentTextures();
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetDevice(void* device);
-
#region Constructors
// singleton. Dont allow any instance of this class
@@ -99,7 +93,7 @@ public static void ReleaseUnmanagedResources()
{
unsafe
{
- FontEngineSetDevice(null);
+ DXNative.FontEngineSetDevice(null);
}
}
@@ -494,7 +488,7 @@ public static void Present()
{
lock (Renderlock)
{
- FontEnginePresentTextures();
+ DXNative.FontEnginePresentTextures();
for (int i = 0; i < _listFonts.Count; ++i)
{
GUIFont font = _listFonts[i];
@@ -614,7 +608,7 @@ public static void SetDevice()
unsafe
{
- FontEngineSetDevice(upDevice.ToPointer());
+ DXNative.FontEngineSetDevice(upDevice.ToPointer());
}
}
@@ -630,7 +624,7 @@ public static void InitializeDeviceObjects()
unsafe
{
- FontEngineSetDevice(upDevice.ToPointer());
+ DXNative.FontEngineSetDevice(upDevice.ToPointer());
}
foreach (GUIFont font in _listFonts)
{
144 mediaportal/Core/guilib/GUIImage.cs
View
@@ -37,43 +37,6 @@ namespace MediaPortal.GUI.Library
/// </summary>
public class GUIImage : GUIControl
{
- public enum FontEngineBlendMode
- {
- BLEND_NONE = 0,
- BLEND_DIFFUSE = 1,
- BLEND_OVERLAY = 2
- }
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawTexture(int textureNo, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax, uint color,
- float[,] matrix);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawTexture2(int textureNo1, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax, uint color,
- float[,] matrix, int textureNo2, float uoff2, float voff2,
- float umax2, float vmax2,
- FontEngineBlendMode blendMode);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawMaskedTexture(int textureNo1, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax,
- uint color,
- float[,] matrix, int textureNo2, float uoff2,
- float voff2,
- float umax2, float vmax2);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineDrawMaskedTexture2(int textureNo1, float x, float y, float nw, float nh,
- float uoff, float voff, float umax, float vmax,
- uint color,
- float[,] matrix, int textureNo2, float uoff2,
- float voff2,
- float umax2, float vmax2, int textureNo3, float uoff3,
- float voff3, float umax3, float vmax3,
- FontEngineBlendMode blendMode);
-
/// <summary>
/// enum to specify the border position
/// </summary>
@@ -1491,16 +1454,16 @@ public override void Render(float timePassed)
umaxm = _masktexUmax + _masktexUoff;
vmaxm = _masktexVmax + _masktexVoff;
- FontEngineDrawMaskedTexture(_packedTextureNo, _fx, _fy, _nw, _nh, uoff, voff, umax, vmax,
- color, matrix,
- _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm);
+ DXNative.FontEngineDrawMaskedTexture(_packedTextureNo, _fx, _fy, _nw, _nh, uoff, voff, umax, vmax,
+ color, matrix,
+ _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm);
}
}
else
{
// Default behavior, draw the image texture with no mask.
- FontEngineDrawTexture(_packedTextureNo, _fx, _fy, _nw, _nh, _uoff, _voff, _umax, _vmax, color,
- matrix);
+ DXNative.FontEngineDrawTexture(_packedTextureNo, _fx, _fy, _nw, _nh, _uoff, _voff, _umax, _vmax, color,
+ matrix);
}
}
@@ -1576,18 +1539,18 @@ public override void Render(float timePassed)
umaxm = _masktexUmax + _masktexUoff;
vmaxm = _masktexVmax + _masktexVoff;
- FontEngineDrawMaskedTexture2(_packedTextureNo, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1,
- color, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm,
- _blendMode);
+ DXNative.FontEngineDrawMaskedTexture2(_packedTextureNo, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1,
+ color, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm,
+ _blendMode);
}
}
else
{
- FontEngineDrawTexture2(_packedTextureNo, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1, color, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- _blendMode);
+ DXNative.FontEngineDrawTexture2(_packedTextureNo, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1, color, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ _blendMode);
}
// Draw flipped image border.
@@ -1778,19 +1741,18 @@ public override void Render(float timePassed)
umaxm = _masktexUmax + _masktexUoff;
vmaxm = _masktexVmax + _masktexVoff;
- FontEngineDrawMaskedTexture2(frame.TextureNumber, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1,
- color, matrix,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm,
- _blendMode);
+ DXNative.FontEngineDrawMaskedTexture2(frame.TextureNumber, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1,
+ color, matrix,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ _packedMaskTextureNo, uoffm, voffm, umaxm, vmaxm, _blendMode);
}
}
else
{
- FontEngineDrawTexture2(frame.TextureNumber, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1, color,
- matrix,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- _blendMode);
+ DXNative.FontEngineDrawTexture2(frame.TextureNumber, fx, fy, nw, nh, uoff1, voff1, umax1, vmax1, color,
+ matrix,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ _blendMode);
}
}
@@ -2221,30 +2183,30 @@ private void DrawBorder(bool flip)
if (flip)
{
// Upper left corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
- cvmaxLeft, mergedBorderColorKey, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- FontEngineBlendMode.BLEND_DIFFUSE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
+ cvmaxLeft, mergedBorderColorKey, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ FontEngineBlendMode.BLEND_DIFFUSE);
// Upper right corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
- cumaxRight, cvmaxRight, mergedBorderColorKey, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- FontEngineBlendMode.BLEND_DIFFUSE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
+ cumaxRight, cvmaxRight, mergedBorderColorKey, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ FontEngineBlendMode.BLEND_DIFFUSE);
}
else
{
// Upper left corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
- cvmaxLeft, mergedBorderColorKey, m,
- cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
- FontEngineBlendMode.BLEND_NONE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
+ cvmaxLeft, mergedBorderColorKey, m,
+ cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
+ FontEngineBlendMode.BLEND_NONE);
// Upper right corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
- cumaxRight, cvmaxRight, mergedBorderColorKey, m,
- cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
- FontEngineBlendMode.BLEND_NONE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
+ cumaxRight, cvmaxRight, mergedBorderColorKey, m,
+ cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
+ FontEngineBlendMode.BLEND_NONE);
}
}
}
@@ -2375,30 +2337,30 @@ private void DrawBorder(bool flip)
if (flip)
{
// Lower left corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
- cvmaxLeft, mergedBorderColorKey, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- FontEngineBlendMode.BLEND_DIFFUSE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
+ cvmaxLeft, mergedBorderColorKey, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ FontEngineBlendMode.BLEND_DIFFUSE);
// Lower right corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
- cumaxRight, cvmaxRight, mergedBorderColorKey, m,
- _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
- FontEngineBlendMode.BLEND_DIFFUSE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
+ cumaxRight, cvmaxRight, mergedBorderColorKey, m,
+ _packedBlendableTextureNo, _blendabletexUoffCalc, _blendabletexVoffCalc, _blendabletexUmaxCalc, _blendabletexVmaxCalc,
+ FontEngineBlendMode.BLEND_DIFFUSE);
}
else
{
// Lower left corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
- cvmaxLeft, mergedBorderColorKey, m,
- cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
- FontEngineBlendMode.BLEND_NONE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxLeft, cyLeft, cwLeft, chLeft, cuLeft, cvLeft, cumaxLeft,
+ cvmaxLeft, mergedBorderColorKey, m,
+ cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
+ FontEngineBlendMode.BLEND_NONE);
// Lower right corner
- FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
- cumaxRight, cvmaxRight, mergedBorderColorKey, m,
- cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
- FontEngineBlendMode.BLEND_NONE);
+ DXNative.FontEngineDrawTexture2(cornerTexture.TextureNumber, cxRight, cyRight, cwRight, chRight, cuRight, cvRight,
+ cumaxRight, cvmaxRight, mergedBorderColorKey, m,
+ cornerTexture.TextureNumber, cuRight, cvRight, cumaxRight, cvmaxRight,
+ FontEngineBlendMode.BLEND_NONE);
}
}
}
10 mediaportal/Core/guilib/GraphicContext.cs
View
@@ -53,12 +53,6 @@ namespace MediaPortal.GUI.Library
/// </summary>
public class GUIGraphicsContext
{
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetClipEnable();
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineSetClipDisable();
-
public static event BlackImageRenderedHandler OnBlackImageRendered;
public static event VideoReceivedHandler OnVideoReceived;
@@ -2057,7 +2051,7 @@ public static void BeginClip(Rectangle rect, bool constrain)
// Place the clip rectangle on the top of the stack and set it as the current clip rectangle.
_clipRectangleStack.Push(r3);
DX9Device.ScissorRectangle = _clipRectangleStack.Peek();
- FontEngineSetClipEnable();
+ DXNative.FontEngineSetClipEnable();
}
/// <summary>
@@ -2071,7 +2065,7 @@ public static void EndClip()
// If the clip stack is empty then tell the font engine to stop clipping otherwise restore the current clip rectangle.
if (_clipRectangleStack.Count == 0)
{
- FontEngineSetClipDisable();
+ DXNative.FontEngineSetClipDisable();
}
else
{
16 mediaportal/Core/guilib/TexturePacker.cs
View
@@ -46,16 +46,6 @@ public class TexturePacker : IDisposable
public event DisposeEventHandler Disposing;
- #region imports
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe void FontEngineRemoveTexture(int textureNo);
-
- [DllImport("fontEngine.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
- private static extern unsafe int FontEngineAddTexture(int hasCode, bool useAlphaBlend, void* fontTexture);
-
- #endregion
-
#region PackedTexture Class
[Serializable]
@@ -531,7 +521,7 @@ private void texture_Disposing(object sender, EventArgs e)
if (bigOne.textureNo >= 0)
{
Log.Info("TexturePacker: disposing texture:{0}", bigOne.textureNo);
- FontEngineRemoveTexture(bigOne.textureNo);
+ DXNative.FontEngineRemoveTexture(bigOne.textureNo);
if (Disposing != null)
{
Disposing(this, bigOne.textureNo);
@@ -680,7 +670,7 @@ private bool AddBitmap(PackedTextureNode root, Image rootImage, string file, out
unsafe
{
IntPtr ptr = DirectShowUtil.GetUnmanagedTexture(bigOne.texture);
- bigOne.textureNo = FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
+ bigOne.textureNo = DXNative.FontEngineAddTexture(ptr.ToInt32(), true, (void*)ptr.ToPointer());
Log.Info("TexturePacker: fontengine add texure:{0}", bigOne.textureNo);
}
}
@@ -713,7 +703,7 @@ public void Dispose()
if (bigOne.textureNo >= 0)
{
Log.Info("TexturePacker: remove texture:{0}", bigOne.textureNo);
- FontEngineRemoveTexture(bigOne.textureNo);
+ DXNative.FontEngineRemoveTexture(bigOne.textureNo);
if (Disposing != null)
{
Disposing(this, bigOne.textureNo);
93 mediaportal/MediaPortal.Application/MediaPortal.cs
View
@@ -3607,51 +3607,54 @@ public void OnStopExternal(Process proc, bool waitForExit)
#endregion
- #region helper funcs
-
- private void CreateStateBlock()
- {
- GUIGraphicsContext.DX9Device.RenderState.CullMode = Cull.None;
- GUIGraphicsContext.DX9Device.RenderState.Lighting = false;
- GUIGraphicsContext.DX9Device.RenderState.ZBufferEnable = true;
- GUIGraphicsContext.DX9Device.RenderState.FogEnable = false;
- GUIGraphicsContext.DX9Device.RenderState.FillMode = FillMode.Solid;
- GUIGraphicsContext.DX9Device.RenderState.SourceBlend = Blend.SourceAlpha;
- GUIGraphicsContext.DX9Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
- GUIGraphicsContext.DX9Device.TextureState[0].ColorOperation = TextureOperation.Modulate;
- GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
- GUIGraphicsContext.DX9Device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
- GUIGraphicsContext.DX9Device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
- if (supportsFiltering)
- {
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[0].MaxAnisotropy = g_nAnisotropy;
- GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Linear;
- GUIGraphicsContext.DX9Device.SamplerState[1].MaxAnisotropy = g_nAnisotropy;
- }
- else
- {
- GUIGraphicsContext.DX9Device.SamplerState[0].MinFilter = TextureFilter.Point;
- GUIGraphicsContext.DX9Device.SamplerState[0].MagFilter = TextureFilter.Point;
- GUIGraphicsContext.DX9Device.SamplerState[0].MipFilter = TextureFilter.Point;
- GUIGraphicsContext.DX9Device.SamplerState[1].MinFilter = TextureFilter.Point;
- GUIGraphicsContext.DX9Device.SamplerState[1].MagFilter = TextureFilter.Point;
- GUIGraphicsContext.DX9Device.SamplerState[1].MipFilter = TextureFilter.Point;
- }
- if (bSupportsAlphaBlend)
- {
- GUIGraphicsContext.DX9Device.RenderState.AlphaTestEnable = true;
- GUIGraphicsContext.DX9Device.RenderState.ReferenceAlpha = 0x01;
- GUIGraphicsContext.DX9Device.RenderState.AlphaFunction = Compare.GreaterEqual;
- }
- return;
- }
+ #region helper funcs
+
+ private void CreateStateBlock()
+ {
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_CULLMODE, (int)D3DCULL.D3DCULL_NONE);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_LIGHTING, 0);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ZENABLE, 1);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_FOGENABLE, 0);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_FILLMODE, (int)D3DFILLMODE.D3DFILL_SOLID);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_SRCBLEND, (int)D3DBLEND.D3DBLEND_SRCALPHA);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_DESTBLEND, (int)D3DBLEND.D3DBLEND_INVSRCALPHA);
+
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLOROP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_COLORARG2, (int)D3DTA.D3DTA_DIFFUSE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAOP, (int)D3DTEXTUREOP.D3DTOP_MODULATE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG1, (int)D3DTA.D3DTA_TEXTURE);
+ DXNative.FontEngineSetTextureStageState(0, (int)D3DTEXTURESTAGESTATETYPE.D3DTSS_ALPHAARG2, (int)D3DTA.D3DTA_DIFFUSE);
+
+ if (supportsFiltering)
+ {
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_LINEAR);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAXANISOTROPY, (uint)g_nAnisotropy);
+ }
+ else
+ {
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+ DXNative.FontEngineSetSamplerState(0, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MINFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MAGFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+ DXNative.FontEngineSetSamplerState(1, (int)D3DSAMPLERSTATETYPE.D3DSAMP_MIPFILTER, (int)D3DTEXTUREFILTERTYPE.D3DTEXF_POINT);
+ }
+ if (bSupportsAlphaBlend)
+ {
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHATESTENABLE, 1);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHAREF, 1);
+ DXNative.FontEngineSetRenderState((int)D3DRENDERSTATETYPE.D3DRS_ALPHAFUNC, (int)D3DCMPFUNC.D3DCMP_GREATEREQUAL);
+ }
+ }
/// <summary>
/// Get the current date from the system and localize it based on the user preferences.
Please sign in to comment.
Something went wrong with that request. Please try again.