12#if defined(BI_MULTI_THREAD_RTL)
16#if defined(__BORLANDC__)
35#if defined(BI_MULTI_THREAD_RTL)
40 enum {MaxEntries = 16};
50 void Release(HDC hDC);
52#if defined(BI_MULTI_THREAD_RTL)
57 TEntry Entries[MaxEntries];
63static TMemDCCache& GetMemDCCache()
65#if defined(BI_MULTI_THREAD_RTL)
66 static TTlsContainer<TMemDCCache> memDCCache;
67 return memDCCache.Get();
69 static TMemDCCache memDCCache;
79 TMemDCCache& InitMemDCCache = GetMemDCCache();
82#if defined(BI_MULTI_THREAD_RTL)
91TMemDCCache::TMemDCCache()
94 for (
int i = 0; i < MaxEntries; i++) {
95 Entries[i].Handle =
nullptr;
96 Entries[i].Busy =
false;
103TMemDCCache::~TMemDCCache()
106 for (
int i = 0; i < MaxEntries && Entries[i].Handle; i++) {
107 WARNX(OwlGDI, Entries[i].Busy, 0,
_T(
"Unreleased DC ") <<
108 static_cast<void*
>(Entries[i].Handle) <<
_T(
" in MemDCCache at destruction"));
109 ::DeleteDC(Entries[i].Handle);
121 for (
int i = 0; i < MaxEntries; i++) {
122 if (!Entries[i].Handle) {
126 HDC sdc = ::GetWindowDC(
nullptr);
127 Entries[i].Handle = ::CreateCompatibleDC(sdc);
128 ::ReleaseDC(
nullptr, sdc);
130 if (!Entries[i].Busy) {
131 Entries[i].Busy =
true;
132 return Entries[i].Handle;
142TMemDCCache::Release(HDC hDC)
145 for (
int i = 0; i < MaxEntries && Entries[i].Handle; i++) {
146 if (Entries[i].Handle == hDC) {
147 WARNX(OwlGDI, !Entries[i].Busy, 0,
"Releasing non-busy DC " <<
148 static_cast<void*
>(Entries[i].Handle) <<
" in MemDCCache");
149 Entries[i].Busy =
false;
174 Handle = ::CreateCompatibleDC(dc);
213#if defined(OWL5_COMPAT)
219 LPCTSTR output,
const DEVMODE * initData)
230 TCreatedDC(driver, device, output, initData)
244 Handle = GetMemDCCache().Get();
249 Handle = ::CreateCompatibleDC(
nullptr);
260 GetMemDCCache().Release(
GetHDC());
#define WARNX(group, condition, level, message)
TBitmap is the GDI bitmap class derived from TGdiObject.
An abstract TDC class, TCreatedDC serves as the base for DCs that are created and deleted.
TCreatedDC(LPCTSTR driver, LPCTSTR device, const DEVMODE *initData=nullptr)
Creates a device context (DC) object for the device specified by driver (driver name) and device (dev...
TDC is the root class for GDI DC wrappers.
void Init()
Sets OrgBrush, OrgPen, OrgFont, OrgBitmap, and OrgPalette to 0, and sets ShouldDelete to true.
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
void CheckValid(uint resId=IDS_GDIFAILURE)
bool ShouldDelete
< The handle of this DC. Uses the base class's handle (TGdiBase::Handle.)
HANDLE Handle
< make this function available to derivatives
HDC GetHDC() const
Return the handle of the device context.
void CheckValid(uint resId=IDS_GDIFAILURE)
bool ShouldDelete
Should object delete GDI handle in dtor?
HANDLE Handle
GDI handle of this object.
TMemoryDC()
Constructs a screen-compatible memory DC.
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
Definition of abstract GDI object class and derived classes.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Object Windows Library (OWLNext Core).
DIAG_DECLARE_GROUP(OwlThread)