summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@collabora.co.uk>2023-04-12 13:46:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-13 10:04:42 +0200
commit209e859c3e78d5818df3e3f84669aaa2a3810c01 (patch)
treee6ebfb69fd72263118802b1cdf0241256f1985c5 /vcl
parent17367a67cd39109006060176b04bc2b174a17e48 (diff)
no need to allocate these separately
Change-Id: Icc24e0aaf1762e5b318b8364dd9fdb496edfb77c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150279 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/win/saldata.hxx33
-rw-r--r--vcl/win/app/salinst.cxx1
-rw-r--r--vcl/win/gdi/salgdi.cxx11
3 files changed, 20 insertions, 25 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index c391086b30a1..b5740d5670a4 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -21,6 +21,7 @@
#include <config_features.h>
+#include <array>
#include <memory>
#include <osl/module.h>
@@ -53,6 +54,21 @@ class SkiaControlsCache;
#define MAX_STOCKBRUSH 4
#define SAL_CLIPRECT_COUNT 16
+#define CACHESIZE_HDC 3
+#define CACHED_HDC_1 0
+#define CACHED_HDC_2 1
+#define CACHED_HDC_DRAW 2
+#define CACHED_HDC_DEFEXT 64
+
+struct HDCCache
+{
+ HDC mhDC = 0;
+ HPALETTE mhDefPal = 0;
+ HBITMAP mhDefBmp = 0;
+ HBITMAP mhSelBmp = 0;
+ HBITMAP mhActBmp = 0;
+};
+
struct SalIcon
{
int nId;
@@ -96,7 +112,7 @@ public:
WinSalObject* mpFirstObject; // pointer of first object window
WinSalVirtualDevice* mpFirstVD; // first VirDev
WinSalPrinter* mpFirstPrinter; // first printing printer
- HDCCache* mpHDCCache; // Cache for three DC's
+ std::array<HDCCache, CACHESIZE_HDC> maHDCCache; // Cache for three DC's
HBITMAP mh50Bmp; // 50% Bitmap
HBRUSH mh50Brush; // 50% Brush
COLORREF maStockPenColorAry[MAX_STOCKPEN];
@@ -139,21 +155,6 @@ struct SalShlData
extern SalShlData aSalShlData;
-#define CACHESIZE_HDC 3
-#define CACHED_HDC_1 0
-#define CACHED_HDC_2 1
-#define CACHED_HDC_DRAW 2
-#define CACHED_HDC_DEFEXT 64
-
-struct HDCCache
-{
- HDC mhDC;
- HPALETTE mhDefPal;
- HBITMAP mhDefBmp;
- HBITMAP mhSelBmp;
- HBITMAP mhActBmp;
-};
-
void ImplClearHDCCache( SalData* pData );
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
void ImplReleaseCachedDC( sal_uLong nID );
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 3e2cc7a04754..a2aabbab2870 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -261,7 +261,6 @@ SalData::SalData()
mpFirstObject = nullptr; // pointer of first object window
mpFirstVD = nullptr; // first VirDev
mpFirstPrinter = nullptr; // first printing printer
- mpHDCCache = nullptr; // Cache for three DC's
mh50Bmp = nullptr; // 50% Bitmap
mh50Brush = nullptr; // 50% Brush
int i;
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 8a38a684ca35..cb3cad6508ed 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -134,10 +134,6 @@ void ImplInitSalGDI()
pSalData->mhStockBrushAry[3] = CreateSolidBrush( pSalData->maStockBrushColorAry[3] );
pSalData->mnStockBrushCount = 4;
- // initialize cache of device contexts
- pSalData->mpHDCCache = new HDCCache[ CACHESIZE_HDC ];
- memset( pSalData->mpHDCCache, 0, CACHESIZE_HDC * sizeof( HDCCache ) );
-
// initialize temporary font lists
pSalData->mpSharedTempFontItem = nullptr;
pSalData->mpOtherTempFontItem = nullptr;
@@ -318,7 +314,6 @@ void ImplFreeSalGDI()
}
ImplClearHDCCache( pSalData );
- delete[] pSalData->mpHDCCache;
// delete Ditherpalette, if existing
if ( pSalData->mhDitherPal )
@@ -511,7 +506,7 @@ void WinSalGraphics::setHDC(HDC aNew)
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
{
SalData* pSalData = GetSalData();
- HDCCache* pC = &pSalData->mpHDCCache[ nID ];
+ HDCCache* pC = &pSalData->maHDCCache[ nID ];
if( !pC->mhDC )
{
@@ -543,7 +538,7 @@ HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
void ImplReleaseCachedDC( sal_uLong nID )
{
SalData* pSalData = GetSalData();
- HDCCache* pC = &pSalData->mpHDCCache[ nID ];
+ HDCCache* pC = &pSalData->maHDCCache[ nID ];
if ( pC->mhActBmp )
SelectObject( pC->mhDC, pC->mhSelBmp );
@@ -553,7 +548,7 @@ void ImplClearHDCCache( SalData* pData )
{
for( sal_uLong i = 0; i < CACHESIZE_HDC; i++ )
{
- HDCCache* pC = &pData->mpHDCCache[ i ];
+ HDCCache* pC = &pData->maHDCCache[ i ];
if( pC->mhDC )
{