///////////////////////////////////////////////////////////// /// Met à jour les pixels de la texture /// /// \param Rect : Rectangle à mettre à jour dans la texture /// //////////////////////////////////////////////////////////// void DX9Texture::Update(const CRectangle& Rect) { CA_ASSERT(CRectangle(0, 0, m_Size.x, m_Size.y).Intersects(Rect) == INT_IN, "DX9Texture::Update() : rectangle out of bounds"); // Si le format des pixels à copier est le même que celui de la texture on fait une simple copie, // sinon on effectue une conversion if (m_Format == m_Data.GetFormat()) { // Verrouillage de la texture D3DLOCKED_RECT LockedRect; RECT Lock = {Rect.Left(), Rect.Top(), Rect.Right(), Rect.Bottom()}; DXCheck(m_Texture->LockRect(0, &LockedRect, &Lock, 0)); // Copie des pixels UpdateSurface(LockedRect, Rect); // Déverrouillage de la texture m_Texture->UnlockRect(0); } else { // Récupération du device SmartPtr<IDirect3DDevice9, CResourceCOM> Device; m_Texture->GetDevice(&GetPtr(Device)); // Création d'une texture en mémoire système pour y copier les pixels SmartPtr<IDirect3DSurface9, CResourceCOM> Src; if (FAILED(Device->CreateOffscreenPlainSurface(Rect.Width(), Rect.Height(), DX9Enum::Get(m_Data.GetFormat()), D3DPOOL_SYSTEMMEM, &GetPtr(Src), nullptr))) throw DX9Exception("CreateOffscreenPlainSurface", "DX9Texture::Update"); // Verrouillage de la texture temporaire D3DLOCKED_RECT LockedRect; Src->LockRect(&LockedRect, nullptr, 0); // Copie des pixels UpdateSurface(LockedRect, Rect); // Déverrouillage de la texture temporaire Src->UnlockRect(); // Récupération de la surface de niveau 0 de la texture SmartPtr<IDirect3DSurface9, CResourceCOM> Dest; m_Texture->GetSurfaceLevel(0, &GetPtr(Dest)); // Copie de la surface Src sur la surface Dest (c'est ici qu'est effectuée la conversion de format) RECT DestRect = {Rect.Left(), Rect.Top(), Rect.Right(), Rect.Bottom()}; if (FAILED(D3DXLoadSurfaceFromSurface(Dest, nullptr, &DestRect, Src, nullptr, nullptr, D3DX_DEFAULT, 0))) throw DX9Exception("D3DXLoadSurfaceFromSurface", "DX9Texture::Update"); } // Génération des niveaux de mipmapping si nécessaire if (m_HasMipmaps) { if (m_AutoMipmaps) m_Texture->GenerateMipSubLevels(); else D3DXFilterTexture(m_Texture, nullptr, D3DX_DEFAULT, D3DX_DEFAULT); } }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFontBold // // Description: Sets Font Style // // INPUTS: TRUE of FALSE // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFontBold(BOOL bBold) { m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetBackgroundColor // // Description: Set groupbox backgroup color when group style is XPGB_WINDOW // // INPUTS: COLORREF clrBKTilte, COLORREF clrBKClient // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetBackgroundColor(COLORREF clrBKTilte, COLORREF clrBKClient) { m_clrTitleBackground = clrBKTilte; m_clrClientBackground = clrBKClient; UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFont // // Description: Sets font with LOGFONT structure // // INPUTS: LOGFONT structure // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFont(LOGFONT lf) { CopyMemory(&m_lf, &lf, sizeof(m_lf)); ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabelStatic::SetFontBold // // Description: Sets the font ot bold // // INPUTS: True or false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 22/10/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabelStatic& CLabelStatic::SetFontBold(BOOL bBold) { m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabelStatic::SetFont // // Description: Sets font with LOGFONT structure // // INPUTS: // // RETURNS: // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 02072002 1.6 Origin ////////////////////////////////////////////////////////////////////////// CLabelStatic& CLabelStatic::SetFont(LOGFONT lf) { CopyMemory(&m_lf, &lf, sizeof(m_lf)); ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetTextColor // // Description: Sets the text color // // INPUTS: True or false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 22/10/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetTextColor(COLORREF crText) { m_crText = crText; UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetFontUnderline // // Description: Sets font underline attribue // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetFontUnderline(BOOL bSet) { m_lf.lfUnderline = bSet; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetText3DHiliteColor // // Description: Sets the 3D font hilite color // // INPUTS: Color // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 17/07/00 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetText3DHiliteColor(COLORREF cr3DHiliteColor) { m_cr3DHiliteColor = cr3DHiliteColor; UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFontUnderline // // Description: Sets font underline attribue // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFontUnderline(BOOL bSet) { m_lf.lfUnderline = bSet; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFontItalic // // Description: Sets font italic attribue // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFontItalic(BOOL bSet) { m_lf.lfItalic = bSet; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetText // // Description: Short cut to set window text - caption - label // // INPUTS: Text to use // // RETURNS: Reference to this // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetText(const CString& strText) { SetWindowText(strText); UpdateSurface(); return *this; }
void BasicCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer) { if (IsHidden()) return; UpdateSurface(); FireDidTransactionCallback(); PaintWithOpacity(aContext, GetEffectiveOpacity(), aMaskLayer); }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetFontItalic // // Description: Sets font italic attribute // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetFontItalic(BOOL bSet) { m_lf.lfItalic = bSet; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::OnTimer // // Description: Used in conjunction with 'FLASH' functions // // INPUTS: Windows API // // RETURNS: Windows API // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// void CLabel::OnTimer(UINT nIDEvent) { m_bState = !m_bState; UpdateSurface(); CStatic::OnTimer(nIDEvent); }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetTransparent // // Description: Sets the Label window to be transpaent // // INPUTS: True or false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 22/10/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetTransparent(BOOL bSet) { m_bTransparent = bSet; ModifyStyleEx(0,WS_EX_TRANSPARENT); // Fix for transparency UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetText // // Description: Short cut to set window text - caption - label // // INPUTS: Text to use // // RETURNS: Reference to this // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26081998 1.0 Origin // NT ALMOND 02072002 1.6 Crash Fix ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetText(const CString& strText) { if(IsWindow(this->GetSafeHwnd())) { SetWindowText(strText); UpdateSurface(); } return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetFont3D // // Description: Sets the 3D attribute of the font. // // INPUTS: True or false, Raised or Sunken // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 22/10/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetFont3D(BOOL bSet,Type3D type) { m_bFont3d = bSet; m_3dType = type; UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetText // // Description: Set groupbox title // // INPUTS: Text to use // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetText(LPCTSTR lpszText) { if(IsWindow(this->GetSafeHwnd())) { m_strTitle = lpszText; UpdateSurface(); } return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFontName // // Description: Sets the fonts face name // // INPUTS: String containing font name // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFontName(const CString& strFont, BYTE byCharSet) { m_lf.lfCharSet = byCharSet; _tcscpy(m_lf.lfFaceName,strFont); ReconstructFont(); UpdateSurface(); return *this; }
void CanvasLayerD3D9::RenderLayer() { FirePreTransactionCallback(); UpdateSurface(); if (mD3DManager->CompositingDisabled()) { return; } FireDidTransactionCallback(); if (!mTexture) return; /* * We flip the Y axis here, note we can only do this because we are in * CULL_NONE mode! */ ShaderConstantRect quad(0, 0, mBounds.width, mBounds.height); const bool needsYFlip = (mOriginPos == gl::OriginPos::BottomLeft); if (needsYFlip) { quad.mHeight = (float)-mBounds.height; quad.mY = (float)mBounds.height; } device()->SetVertexShaderConstantF(CBvLayerQuad, quad, 1); SetShaderTransformAndOpacity(); if (mHasAlpha) { mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER, GetMaskLayer()); } else { mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBLAYER, GetMaskLayer()); } if (mFilter == GraphicsFilter::FILTER_NEAREST) { device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); } if (!mDataIsPremultiplied) { device()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device()->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); } device()->SetTexture(0, mTexture); device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); if (!mDataIsPremultiplied) { device()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); device()->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); } if (mFilter == GraphicsFilter::FILTER_NEAREST) { device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); } }
////////////////////////////////////////////////////////////////////////// // // Function: CUltimateGroupBox::SetText // // Description: Set groupbox title // // INPUTS: Text to use // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CUltimateGroupBox& CUltimateGroupBox::SetText(LPCTSTR lpszText) { if(IsWindow(this->GetSafeHwnd())) { m_strTitle = lpszText; m_strTitle = _T(" ") + m_strTitle + _T(" "); UpdateSurface(); } return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetFontName // // Description: Sets the fonts face name // // INPUTS: String containing font name // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // NT ALMOND 15092000 1.5 Support internation windows ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetFontName(const CString& strFont, BYTE byCharSet /* Default = ANSI_CHARSET */) { m_lf.lfCharSet = byCharSet; _tcscpy(m_lf.lfFaceName,strFont); ReconstructFont(); UpdateSurface(); return *this; }
void CLabel::OnSysColorChange() { if (m_hwndBrush) ::DeleteObject(m_hwndBrush); m_hwndBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE)); UpdateSurface(); }
void CanvasLayerD3D10::RenderLayer() { FirePreTransactionCallback(); UpdateSurface(); FireDidTransactionCallback(); if (!mTexture) return; nsIntRect visibleRect = mVisibleRegion.GetBounds(); SetEffectTransformAndOpacity(); uint8_t shaderFlags = 0; shaderFlags |= LoadMaskTexture(); shaderFlags |= mDataIsPremultiplied ? SHADER_PREMUL : SHADER_NON_PREMUL | SHADER_RGBA; shaderFlags |= mHasAlpha ? SHADER_RGBA : SHADER_RGB; shaderFlags |= mFilter == GraphicsFilter::FILTER_NEAREST ? SHADER_POINT : SHADER_LINEAR; ID3D10EffectTechnique* technique = SelectShader(shaderFlags); if (mSRView) { effect()->GetVariableByName("tRGB")->AsShaderResource()->SetResource(mSRView); } effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector( ShaderConstantRectD3D10( (float)mBounds.x, (float)mBounds.y, (float)mBounds.width, (float)mBounds.height) ); if (mNeedsYFlip) { effect()->GetVariableByName("vTextureCoords")->AsVector()->SetFloatVector( ShaderConstantRectD3D10( 0, 1.0f, 1.0f, -1.0f) ); } technique->GetPassByIndex(0)->Apply(0); device()->Draw(4, 0); if (mNeedsYFlip) { effect()->GetVariableByName("vTextureCoords")->AsVector()-> SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f)); } }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetText // // Description: Short cut to set window text - caption - label // // INPUTS: Text to use // // RETURNS: Reference to this // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26081998 1.0 Origin // NT ALMOND 02072002 1.6 Crash Fix ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetText(const CString& strText) { if(IsWindow(this->GetSafeHwnd())) { if ( m_sText != strText ) { m_sText = strText; UpdateSurface(); } } return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CTCGroupBox::SetFontSize // // Description: Sets font size attribue // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // // Name Date Version Comments // Jack Jin 2003-12-03 1.0 Origin ////////////////////////////////////////////////////////////////////////// CTCGroupBox& CTCGroupBox::SetFontSize(int nSize) { CFont cf; LOGFONT lf; cf.CreatePointFont(nSize * 10, m_lf.lfFaceName); cf.GetLogFont(&lf); m_lf.lfHeight = lf.lfHeight; m_lf.lfWidth = lf.lfWidth; ReconstructFont(); UpdateSurface(); return *this; }
void CRadar::DrawUI(LPDIRECT3DDEVICE7 lpDevice) { if (!Enabled)return; if ((lpSurface==NULL)||(lpSurface->IsLost())) { UpdateSurface(); Update(); } const float w=130.0f*game->width/640.0f; const float h=130.0f*game->width/640.0f; const float x=game->width-20-w; const float y=game->height-20-h; const int c=D3DRGBA(1,1,1,0.45f); const float r=0.9f; D3DTLVERTEX v[4]={ D3DTLVERTEX(D3DVECTOR(x,y,0),r,c,0,0,0), D3DTLVERTEX(D3DVECTOR(x+w,y,0),r,c,0,1,0), D3DTLVERTEX(D3DVECTOR(x,y+h,0),r,c,0,0,1), D3DTLVERTEX(D3DVECTOR(x+w,y+h,0),r,c,0,1,1) }; if (Config.alpha) { // lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE,FALSE); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,TRUE); lpDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA); lpDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA); lpDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF,8); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC,D3DCMP_GREATEREQUAL); } lpDevice->SetTexture(0,lpSurface); lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_TLVERTEX,v,4,0); lpDevice->SetTexture(0,NULL); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,0); lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,0); // lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE); }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetFontSize // // Description: Sets the font size // // INPUTS: True of false // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetFontSize(int nSize) { CFont cf; LOGFONT lf; cf.CreatePointFont(nSize * 10, m_lf.lfFaceName); cf.GetLogFont(&lf); m_lf.lfHeight = lf.lfHeight; m_lf.lfWidth = lf.lfWidth; // nSize*=-1; // m_lf.lfHeight = nSize; ReconstructFont(); UpdateSurface(); return *this; }
////////////////////////////////////////////////////////////////////////// // // Function: CLabel::SetBkColor // // Description: Sets background color // // INPUTS: Colorref of background color // // RETURNS: Reference to 'this' object // // NOTES: // // MODIFICATIONS: // // Name Date Version Comments // NT ALMOND 26/08/98 1.0 Origin // ////////////////////////////////////////////////////////////////////////// CLabel& CLabel::SetBkColor(COLORREF crBkgnd, COLORREF crBkgndHigh , BackFillMode mode) { m_crLoColor = crBkgnd; m_crHiColor = crBkgndHigh; m_fillmode = mode; if (m_hBackBrush) ::DeleteObject(m_hBackBrush); if (m_fillmode == Normal) m_hBackBrush = ::CreateSolidBrush(crBkgnd); UpdateSurface(); return *this; }