use StretchBlt() if available (part of patch 649866)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2003-01-02 23:25:17 +00:00
parent c75274f93c
commit f178ab7e82

View File

@ -132,6 +132,30 @@ private:
bool m_changed;
};
// this class saves the old stretch blit mode during its life time
class StretchBltModeChanger
{
public:
StretchBltModeChanger(HDC hdc, int mode)
: m_hdc(hdc)
{
m_modeOld = ::SetStretchBltMode(m_hdc, mode);
if ( !m_modeOld )
wxLogLastError(_T("SetStretchBltMode"));
}
~StretchBltModeChanger()
{
if ( !::SetStretchBltMode(m_hdc, m_modeOld) )
wxLogLastError(_T("SetStretchBltMode"));
}
private:
const HDC m_hdc;
int m_modeOld;
};
// ===========================================================================
// implementation
// ===========================================================================
@ -1808,10 +1832,16 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
#endif
{
success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
GetHdcOf(*source), xsrc, ysrc,
(HBITMAP)mask->GetMaskBitmap(), xsrcMask, ysrcMask,
MAKEROP4(dwRop, DSTCOPY)) != 0;
success = ::MaskBlt
(
GetHdc(),
xdest, ydest, width, height,
GetHdcOf(*source),
xsrc, ysrc,
(HBITMAP)mask->GetMaskBitmap(),
xsrcMask, ysrcMask,
MAKEROP4(dwRop, DSTCOPY)
) != 0;
}
if ( !success )
@ -1901,14 +1931,39 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
}
else // no mask, just BitBlt() it
{
success = ::BitBlt(GetHdc(), xdest, ydest,
(int)width, (int)height,
GetHdcOf(*source), xsrc, ysrc, dwRop) != 0;
// use StretchBlt() if available
if ( ::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHBLT )
{
StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
success = ::StretchBlt
(
GetHdc(),
xdest, ydest, width, height,
GetHdcOf(*source),
xsrc, ysrc, width, height,
dwRop
) != 0;
}
else
{
success = ::BitBlt
(
GetHdc(),
xdest, ydest,
(int)width, (int)height,
GetHdcOf(*source),
xsrc, ysrc,
dwRop
) != 0;
}
if ( !success )
{
wxLogLastError(wxT("BitBlt"));
wxLogLastError(wxT("BitBlt/StretchBlt"));
}
}
::SetTextColor(GetHdc(), old_textground);
::SetBkColor(GetHdc(), old_background);