Added wxUSE_DC_CACHEING and associated code to wxMSW

Added EnableCache, CacheEnabled to wxDCBase
Added mask source args to DoBlit, Blit
Added cache testing code to dragimag sample
Added wxSystemOptions, regenerated makefiles


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2001-07-11 10:07:06 +00:00
parent 03147cd08e
commit 0cbff1201a
58 changed files with 1147 additions and 478 deletions

View File

@@ -274,17 +274,17 @@ public:
bool Blit(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)
{
return DoBlit(xdest, ydest, width, height,
source, xsrc, ysrc, rop, useMask);
source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
}
bool Blit(const wxPoint& destPt, const wxSize& sz,
wxDC *source, const wxPoint& srcPt,
int rop = wxCOPY, bool useMask = FALSE)
int rop = wxCOPY, bool useMask = FALSE, const wxPoint& srcPtMask = wxPoint(-1, -1))
{
return DoBlit(destPt.x, destPt.y, sz.x, sz.y,
source, srcPt.x, srcPt.y, rop, useMask);
source, srcPt.x, srcPt.y, rop, useMask, srcPtMask.x, srcPtMask.y);
}
#if wxUSE_SPLINES
@@ -486,6 +486,16 @@ public:
virtual void SetOptimization(bool WXUNUSED(opt)) { }
virtual bool GetOptimization() { return FALSE; }
// Some platforms have a DC cache, which should be cleared
// at appropriate points such as after a series of DC operations.
// Put ClearCache in the wxDC implementation class, since it has to be
// static.
// static void ClearCache() ;
#if wxUSE_DC_CACHEING
static void EnableCache(bool cacheing) { sm_cacheing = cacheing; }
static bool CacheEnabled() { return sm_cacheing ; }
#endif
// bounding box
// ------------
@@ -624,7 +634,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) = 0;
int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1) = 0;
virtual void DoGetSize(int *width, int *height) const = 0;
virtual void DoGetSizeMM(int* width, int* height) const = 0;
@@ -688,6 +698,9 @@ protected:
bool m_clipping:1;
bool m_isInteractive:1;
bool m_isBBoxValid:1;
#if wxUSE_DC_CACHEING
static bool sm_cacheing;
#endif
// coordinate system variables

View File

@@ -458,7 +458,7 @@ WX_DEFINE_EXPORTED_ARRAY(void *, wxArrayPtrVoid);
//@}
// -----------------------------------------------------------------------------
// convinience macros
// convenience macros
// -----------------------------------------------------------------------------
// append all element of one array to another one

View File

@@ -69,7 +69,7 @@ protected:
virtual bool DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int logical_func = wxCOPY, bool useMask = FALSE );
int logical_func = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1 );
virtual void DoDrawText( const wxString &text, wxCoord x, wxCoord y );
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,

View File

@@ -69,7 +69,7 @@ protected:
virtual bool DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int logical_func = wxCOPY, bool useMask = FALSE );
int logical_func = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1 );
virtual void DoDrawText( const wxString &text, wxCoord x, wxCoord y );
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,

View File

@@ -213,7 +213,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

View File

@@ -365,6 +365,9 @@
// wxMimeTypesManager class
#define wxUSE_MIMETYPE 1
// wxSystemOptions class
#define wxUSE_SYSTEM_OPTIONS 1
// ----------------------------------------------------------------------------
// Individual GUI controls
// ----------------------------------------------------------------------------
@@ -542,6 +545,9 @@
// wxValidator class and related methods
#define wxUSE_VALIDATORS 1
// wxDC cacheing implementation
#define wxUSE_DC_CACHEING 0
// ----------------------------------------------------------------------------
// common dialogs
// ----------------------------------------------------------------------------

View File

@@ -198,7 +198,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

View File

@@ -117,7 +117,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);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,

View File

@@ -71,6 +71,28 @@
#define wx_round(a) (int)((a)+.5)
#if wxUSE_DC_CACHEING
/*
* Cached blitting, maintaining a cache
* of bitmaps required for transparent blitting
* instead of constant creation/deletion
*/
class wxDCCacheEntry: public wxObject
{
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:
@@ -141,6 +163,15 @@ public:
// 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
@@ -226,6 +257,11 @@ protected:
WXHFONT m_oldFont;
WXHPALETTE m_oldPalette;
#if wxUSE_DC_CACHEING
static wxList sm_bitmapCache;
static wxList sm_dcCache;
#endif
DECLARE_DYNAMIC_CLASS(wxDC)
};

View File

@@ -44,7 +44,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);
// init the dc
void Init();

View File

@@ -33,15 +33,6 @@ public:
// Get a system metric, e.g. scrollbar size
static int GetSystemMetric(int index);
// User-customizable hints to wxWindows or associated libraries
// These could also be used to influence GetSystem... calls, indeed
// to implement SetSystemColour/Font/Metric
static void SetOption(const wxString& name, const wxString& value);
static void SetOption(const wxString& name, int value);
static wxString GetOption(const wxString& name) ;
static int GetOptionInt(const wxString& name) ;
static bool HasOption(const wxString& name) ;
};
#endif

View File

@@ -383,6 +383,9 @@
// wxMimeTypesManager class
#define wxUSE_MIMETYPE 1
// wxSystemOptions class
#define wxUSE_SYSTEM_OPTIONS 1
// ----------------------------------------------------------------------------
// Individual GUI controls
// ----------------------------------------------------------------------------
@@ -560,6 +563,9 @@
// wxValidator class and related methods
#define wxUSE_VALIDATORS 1
// wxDC cacheing implementation
#define wxUSE_DC_CACHEING 1
// ----------------------------------------------------------------------------
// common dialogs
// ----------------------------------------------------------------------------

View File

@@ -250,6 +250,8 @@ protected:
,wxCoord vYsrc
,int nRop = wxCOPY
,bool bUseMask = FALSE
,wxCoord xsrcMask = -1
,wxCoord ysrcMask = -1
);
virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion);

View File

@@ -52,6 +52,8 @@ protected:
,wxCoord vYsrc
,int nRop = wxCOPY
,bool bUseMask = FALSE
,wxCoord xsrcMask = -1
,wxCoord ysrcMask = -1
);
// init the dc

44
include/wx/sysopt.h Normal file
View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sysopt.h
// Purpose: wxSystemOptions
// Author: Julian Smart
// Modified by:
// Created: 2001-07-10
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SYSOPT_H_
#define _WX_SYSOPT_H_
#include "wx/object.h"
#if wxUSE_SYSTEM_OPTIONS
// ----------------------------------------------------------------------------
// Enables an application to influence the wxWindows implementation
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSystemOptions : public wxObject
{
public:
wxSystemOptions() { }
// User-customizable hints to wxWindows or associated libraries
// These could also be used to influence GetSystem... calls, indeed
// to implement SetSystemColour/Font/Metric
static void SetOption(const wxString& name, const wxString& value);
static void SetOption(const wxString& name, int value);
static wxString GetOption(const wxString& name) ;
static int GetOptionInt(const wxString& name) ;
static bool HasOption(const wxString& name) ;
};
#endif
#endif
// _WX_SYSOPT_H_

View File

@@ -71,6 +71,7 @@
#define wxUSE_FONTMAP 0
#define wxUSE_MIMETYPE 0
#define wxUSE_IMAGE 1
#define wxUSE_SYSTEM_OPTIONS 1
#define wxUSE_CONTROLS 1
#define wxUSE_POPUPWIN 1
@@ -107,6 +108,7 @@
#define wxUSE_GRID 0
#define wxUSE_NEW_GRID 0
#define wxUSE_VALIDATORS 0
#define wxUSE_DC_CACHEING 0
#define wxUSE_ACCEL 1
#define wxUSE_GENERIC_DIALOGS_IN_MSW 0
#define wxUSE_COMMON_DIALOGS 0
@@ -221,6 +223,7 @@
#define wxUSE_FONTMAP 0
#define wxUSE_MIMETYPE 0
#define wxUSE_IMAGE 1
#define wxUSE_SYSTEM_OPTIONS 1
#define wxUSE_CONTROLS 1
#define wxUSE_POPUPWIN 1
@@ -257,6 +260,7 @@
#define wxUSE_GRID 0
#define wxUSE_NEW_GRID 0
#define wxUSE_VALIDATORS 0
#define wxUSE_DC_CACHEING 1
#define wxUSE_ACCEL 1
#define wxUSE_GENERIC_DIALOGS_IN_MSW 0
#define wxUSE_COMMON_DIALOGS 0