This sequence of operations ensures that the source's transparent area need not be black,
and logical functions are supported.
-{\bf Note:} on Windows, blitting with masks can be speeded up considerably by using
-\helpref{DC cacheing}{wxdcenablecache}. You can also influence whether MaskBlt
+{\bf Note:} on Windows, blitting with masks can be speeded up considerably by compiling
+wxWindows with the wxUSE\_DC\_CACHE option enabled. You can also influence whether MaskBlt
or the explicit mask blitting code above is used, by using \helpref{wxSystemOptions}{wxsystemoptions} and
setting the {\bf no-maskblt} option to 1.
\helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxBitmap}{wxbitmap}, \helpref{wxMask}{wxmask}
+\begin{comment}
\membersection{wxDC::CacheEnabled}\label{wxdccacheenabled}
\func{static bool}{CacheEnabled}{\void}
\wxheading{See also}
\helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::ClearCache}
+\end{comment}
\membersection{wxDC::CalcBoundingBox}\label{wxdccalcboundingbox}
Clears the device context using the current background brush.
+\begin{comment}
\membersection{wxDC::ClearCache}\label{wxdcclearcache}
\func{static void}{ClearCache}{\void}
\wxheading{See also}
\helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::CacheEnabled}
+\end{comment}
\membersection{wxDC::CrossHair}\label{wxdccrosshair}
but it is ignored by wxMSW. Thus, you should avoid using logical functions
with this function in portable programs.
+\begin{comment}
\membersection{wxDC::EnableCache}\label{wxdcenablecache}
\func{static void}{EnableCache}{\param{bool}{ enableCache}}
\wxheading{See also}
\helpref{wxDC::CacheEnabled}{wxdccacheenabled}, \helpref{wxDC::ClearCache}
+\end{comment}
\membersection{wxDC::EndDoc}\label{wxdcenddoc}
wxClientDC dc(this);
wxGetApp().TileBitmap(rect, dc, wxGetApp().GetBackgroundBitmap());
}
-#if wxUSE_DC_CACHEING
- wxDC::ClearCache();
-#endif
}
else
event.Skip(); // The official way of doing it
shape->Draw(dc);
node = node->Next();
}
-#if wxUSE_DC_CACHEING
- wxDC::ClearCache();
-#endif
}
void MyCanvas::EraseShape(DragShape* shape, wxDC& dc)
wxImage::AddHandler( new wxPNGHandler );
#endif
- // The DC cache is an efficiency measure to be used
- // when a lot of masked blitting is done
-#if wxUSE_DC_CACHEING
- wxDC::EnableCache(TRUE);
-#endif
-
wxImage image;
if (image.LoadFile("backgrnd.png", wxBITMAP_TYPE_PNG))
{
int MyApp::OnExit()
{
-#if wxUSE_DC_CACHEING
- wxDC::ClearCache();
-#endif
return 0;
}
wxLog::FlushActive();
#endif // wxUSE_LOG
+#if wxUSE_DC_CACHEING
+ // automated DC cache management: clear the cached DCs and bitmap
+ // if it's likely that the app has finished with them, that is, we
+ // get an idle event and we're not dragging anything.
+ if (!::GetKeyState(MK_LBUTTON) && !::GetKeyState(MK_MBUTTON) && ::GetKeyState(MK_RBUTTON))
+ wxDC::ClearCache();
+#endif // wxUSE_DC_CACHEING
+
// Send OnIdle events to all windows
if ( SendIdleEvents() )
{
#include "wx/sysopt.h"
#include "wx/dcprint.h"
+#include "wx/module.h"
#include <string.h>
#include <math.h>
sm_dcCache.DeleteContents(FALSE);
}
+// Clean up cache at app exit
+class wxDCModule : public wxModule
+{
+public:
+ virtual bool OnInit() { return TRUE; }
+ virtual void OnExit() { wxDC::ClearCache(); }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxDCModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
+
#endif
// wxUSE_DC_CACHEING