X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd9da200285e3c625be91768c9ca61dc218c94d0..1971d23c57b3c582f32d05704914ad902ec76fa5:/include/wx/msw/dc.h diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 2bf3643789..50e310c902 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -71,10 +71,30 @@ #define wx_round(a) (int)((a)+.5) -class WXDLLEXPORT wxDC : public wxDCBase +#if wxUSE_DC_CACHEING +/* + * Cached blitting, maintaining a cache + * of bitmaps required for transparent blitting + * instead of constant creation/deletion + */ + +class wxDCCacheEntry: public wxObject { - DECLARE_DYNAMIC_CLASS(wxDC) +public: + wxDCCacheEntry(WXHBITMAP hBitmap, int w, int h, int depth); + wxDCCacheEntry(WXHDC hDC, int depth); + ~wxDCCacheEntry(); + + WXHBITMAP m_bitmap; + WXHDC m_dc; + int m_width; + int m_height; + int m_depth; +}; +#endif +class WXDLLEXPORT wxDC : public wxDCBase +{ public: wxDC(); ~wxDC(); @@ -125,7 +145,6 @@ public: // -------------------------- virtual void SetRop(WXHDC cdc); - virtual void DoClipping(WXHDC cdc); virtual void SelectOldObjects(WXHDC dc); wxWindow *GetWindow() const { return m_canvas; } @@ -141,6 +160,18 @@ public: const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; } wxBitmap& GetSelectedBitmap() { return m_selectedBitmap; } + // update the internal clip box variables + void UpdateClipBox(); + +#if wxUSE_DC_CACHEING + static wxDCCacheEntry* FindBitmapInCache(WXHDC hDC, int w, int h); + static wxDCCacheEntry* FindDCInCache(wxDCCacheEntry* notThis, WXHDC hDC); + + static void AddToBitmapCache(wxDCCacheEntry* entry); + static void AddToDCCache(wxDCCacheEntry* entry); + static void ClearCache(); +#endif + protected: virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); @@ -176,7 +207,7 @@ protected: virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop = wxCOPY, bool useMask = FALSE); + int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); // this is gnarly - we can't even call this function DoSetClippingRegion() // because of virtual function hiding @@ -198,9 +229,6 @@ protected: wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE); -#if wxUSE_SPLINES - virtual void DoDrawSpline(wxList *points); -#endif // wxUSE_SPLINES // common part of DoDrawText() and DoDrawRotatedText() void DrawAnyText(const wxString& text, wxCoord x, wxCoord y); @@ -217,10 +245,8 @@ protected: // TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it bool m_bOwnsDC:1; - // our HDC and its usage count: we only free it when the usage count drops - // to 0 + // our HDC WXHDC m_hDC; - int m_hDCCount; // Store all old GDI objects when do a SelectObject, so we can select them // back in (this unselecting user's objects) so we can safely delete the @@ -230,6 +256,25 @@ protected: WXHBRUSH m_oldBrush; WXHFONT m_oldFont; WXHPALETTE m_oldPalette; + +#if wxUSE_DC_CACHEING + static wxList sm_bitmapCache; + static wxList sm_dcCache; +#endif + + DECLARE_DYNAMIC_CLASS(wxDC) +}; + +// ---------------------------------------------------------------------------- +// wxDCTemp: a wxDC which doesn't free the given HDC (used by wxWindows +// only/mainly) +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxDCTemp : public wxDC +{ +public: + wxDCTemp(WXHDC hdc) { SetHDC(hdc); } + virtual ~wxDCTemp() { SetHDC((WXHDC)NULL); } }; #endif