Minor tweaks and fixes

This commit is contained in:
Birunthan Mohanathas 2013-03-27 18:14:27 +02:00
parent f16224793e
commit c6374f7c12
6 changed files with 30 additions and 34 deletions

View File

@ -69,7 +69,7 @@ CanvasD2D::CanvasD2D() : Canvas(),
CanvasD2D::~CanvasD2D()
{
DiscardDeviceResources();
Dispose();
Finalize();
}
@ -118,7 +118,7 @@ void CanvasD2D::Finalize()
}
}
void CanvasD2D::DiscardDeviceResources()
void CanvasD2D::Dispose()
{
SafeRelease(&m_Target);
@ -133,7 +133,7 @@ void CanvasD2D::Resize(int w, int h)
{
__super::Resize(w, h);
DiscardDeviceResources();
Dispose();
m_Bitmap.Resize(w, h);

View File

@ -74,7 +74,7 @@ private:
static bool Initialize();
static void Finalize();
void DiscardDeviceResources();
void Dispose();
bool BeginTargetDraw();
void EndTargetDraw();

View File

@ -22,7 +22,7 @@ namespace Gfx {
CanvasGDIP::CanvasGDIP() : Canvas(),
m_Graphics(),
m_DoubleBuffer(),
m_Bitmap(),
m_DIBSectionBuffer(),
m_DIBSectionBufferPixels()
{
@ -30,22 +30,30 @@ CanvasGDIP::CanvasGDIP() : Canvas(),
CanvasGDIP::~CanvasGDIP()
{
delete m_DoubleBuffer;
if (m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
Dispose();
}
void CanvasGDIP::Dispose()
{
delete m_Graphics;
m_Graphics = nullptr;
delete m_Bitmap;
m_Bitmap = nullptr;
if (m_DIBSectionBuffer)
{
DeleteObject(m_DIBSectionBuffer);
m_DIBSectionBuffer = nullptr;
m_DIBSectionBufferPixels = nullptr;
}
}
void CanvasGDIP::Resize(int w, int h)
{
__super::Resize(w, h);
delete m_Graphics;
if (m_DIBSectionBuffer)
{
delete m_DoubleBuffer;
DeleteObject(m_DIBSectionBuffer);
m_DIBSectionBufferPixels = nullptr;
}
Dispose();
BITMAPV4HEADER bh = {sizeof(BITMAPV4HEADER)};
bh.bV4Width = w;
@ -67,14 +75,14 @@ void CanvasGDIP::Resize(int w, int h)
0);
// Create GDI+ bitmap from the DIBSection pixels
m_DoubleBuffer = new Gdiplus::Bitmap(
m_Bitmap = new Gdiplus::Bitmap(
w,
h,
w * 4,
PixelFormat32bppPARGB,
(BYTE*)m_DIBSectionBufferPixels);
m_Graphics = new Gdiplus::Graphics(m_DoubleBuffer);
m_Graphics = new Gdiplus::Graphics(m_Bitmap);
}
bool CanvasGDIP::BeginDraw()

View File

@ -64,8 +64,10 @@ public:
private:
CanvasGDIP(const CanvasGDIP& other) {}
void Dispose();
Gdiplus::Graphics* m_Graphics;
Gdiplus::Bitmap* m_DoubleBuffer;
Gdiplus::Bitmap* m_Bitmap;
HBITMAP m_DIBSectionBuffer;
LPDWORD m_DIBSectionBufferPixels;

View File

@ -432,15 +432,12 @@ bool CMeterString::DrawString(Gfx::Canvas& canvas, RectF* rect)
canvas.SetTextAntiAliasing(m_AntiAlias);
//CharacterRange range(0, stringLen);
//stringFormat.SetMeasurableCharacterRanges(1, &range);
m_TextFormat->SetTrimming(
m_ClipType == CLIP_ON ||
(m_ClipType == CLIP_AUTO && (m_NeedsClipping || (m_WDefined && m_HDefined))));
REAL x = (REAL)GetX();
REAL y = (REAL)GetY();
const REAL x = (REAL)GetX();
const REAL y = (REAL)GetY();
if (rect)
{
@ -598,15 +595,6 @@ void CMeterString::BindMeasures(CConfigParser& parser, const WCHAR* section)
}
}
/*
** Static function which frees the font cache.
** If collection is not NULL, frees the private font cache.
**
*/
void CMeterString::FreeFontCache(PrivateFontCollection* collection)
{
}
/*
** Static helper to log all installed font families.
**
@ -674,5 +662,4 @@ void CMeterString::InitializeStatic()
void CMeterString::FinalizeStatic()
{
FreeFontCache();
}

View File

@ -40,7 +40,6 @@ public:
virtual bool Draw(Gfx::Canvas& canvas);
Gdiplus::RectF GetRect() { return m_Rect; }
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
static void EnumerateInstalledFontFamilies();
static void InitializeStatic();