зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1401069 - Part 2. Implement ReleaseAllResource to make WindowsEMF::InitForDrawing reusable. r=fatseng
Currently, WindowsEMF::InitForDrawing can be used once. With the change in this patch, we can call WindowsEMF::InitForDrawing and Playback/SaveToFile in pair as many times as we want. MozReview-Commit-ID: 4fbY4Q6i9v5 --HG-- extra : rebase_source : 4df3fc7d8663d7f552c96204a16d73261bfc9dd7
This commit is contained in:
Родитель
cbacd9e2bd
Коммит
7a420a808c
|
@ -17,15 +17,13 @@ WindowsEMF::WindowsEMF()
|
|||
|
||||
WindowsEMF::~WindowsEMF()
|
||||
{
|
||||
FinishDocument();
|
||||
ReleaseEMFHandle();
|
||||
ReleaseAllResource();
|
||||
}
|
||||
|
||||
bool
|
||||
WindowsEMF::InitForDrawing(const wchar_t* aMetafilePath /* = nullptr */)
|
||||
{
|
||||
MOZ_ASSERT(!mDC && !mEmf, "InitForDrawing and InitFromFileContents is"
|
||||
" designed to be used either one at once.");
|
||||
ReleaseAllResource();
|
||||
|
||||
mDC = ::CreateEnhMetaFile(nullptr, aMetafilePath, nullptr, nullptr);
|
||||
return !!mDC;
|
||||
|
@ -35,8 +33,7 @@ bool
|
|||
WindowsEMF::InitFromFileContents(const wchar_t* aMetafilePath)
|
||||
{
|
||||
MOZ_ASSERT(aMetafilePath);
|
||||
MOZ_ASSERT(!mDC && !mEmf, "InitForDrawing and InitFromFileContents is"
|
||||
" designed to be used either one at once.");
|
||||
ReleaseAllResource();
|
||||
|
||||
mEmf = ::GetEnhMetaFileW(aMetafilePath);
|
||||
return !!mEmf;
|
||||
|
@ -61,6 +58,13 @@ WindowsEMF::ReleaseEMFHandle()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
WindowsEMF::ReleaseAllResource()
|
||||
{
|
||||
FinishDocument();
|
||||
ReleaseEMFHandle();
|
||||
}
|
||||
|
||||
bool
|
||||
WindowsEMF::Playback(HDC aDeviceContext, const RECT* aRect)
|
||||
{
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
WindowsEMF(const WindowsEMF& aEMF) = delete;
|
||||
bool FinishDocument();
|
||||
void ReleaseEMFHandle();
|
||||
void ReleaseAllResource();
|
||||
|
||||
/* Compiled EMF data handle. */
|
||||
HENHMETAFILE mEmf;
|
||||
|
|
Загрузка…
Ссылка в новой задаче