summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorart-snake <art-snake@yandex-team.ru>2016-09-15 14:11:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-15 14:11:10 -0700
commitcde5101eb15b24519e89fa500fe37038bc8e2201 (patch)
treece3f6e9215769e4e1494479740cc4eaf957a109b /xfa
parentd9871435eb7cea00a173baf780934f9d3525329a (diff)
downloadpdfium-cde5101eb15b24519e89fa500fe37038bc8e2201.tar.xz
Fix memory leaking on ClosePage.chromium/2862
CFX_FontCache refactoring: after this CL: Only one global CFX_FontCache used. Any cached items from it, are released, when its are not used. BUG=79367,48791 The fonts was not cleared after unloading pages. Test pdf: http://www.nasa.gov/pdf/750614main_NASA_FY_2014_Budget_Estimates-508.pdf For this file, we have ~5 fonts per page, which equal ~1 Mb per page. In this PDF we have 670 pages, as result after slow scrolling(reading) full document we have ~600 Mb fonts data in memory. memory usage of PDF Plugin: before this CL: ~660 Mb after this CL: ~100 Mb Review-Url: https://codereview.chromium.org/2158023002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/fde_gedevice.cpp20
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp9
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp24
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp16
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp32
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp5
6 files changed, 42 insertions, 64 deletions
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index 8279e777b0..15c849f71f 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -8,7 +8,6 @@
#include <algorithm>
-#include "core/fxge/include/cfx_fontcache.h"
#include "core/fxge/include/cfx_gemodule.h"
#include "core/fxge/include/cfx_graphstatedata.h"
#include "core/fxge/include/cfx_renderdevice.h"
@@ -113,7 +112,6 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
FX_FLOAT fFontSize,
const CFX_Matrix* pMatrix) {
ASSERT(pBrush && pFont && pCharPos && iCount > 0);
- CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache();
CFX_Font* pFxFont = pFont->GetDevFont();
FX_ARGB argb = pBrush->GetColor();
if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
@@ -154,12 +152,12 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
pFxFont = pCurFont->GetDevFont();
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
FxFont.SetFace(pFxFont->GetFace());
- m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix, argb,
+ m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, -fFontSize,
+ (const CFX_Matrix*)pMatrix, argb,
FXTEXT_CLEARTYPE);
#else
- m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix, argb,
+ m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize,
+ (const CFX_Matrix*)pMatrix, argb,
FXTEXT_CLEARTYPE);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
}
@@ -176,14 +174,14 @@ FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
FxFont.SetFace(pFxFont->GetFace());
FX_BOOL bRet = m_pDevice->DrawNormalText(
- iCurCount, pCurCP, &FxFont, pCache, -fFontSize,
- (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE);
+ iCurCount, pCurCP, &FxFont, -fFontSize, (const CFX_Matrix*)pMatrix,
+ argb, FXTEXT_CLEARTYPE);
FxFont.SetFace(nullptr);
return bRet;
#else
- return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix,
- argb, FXTEXT_CLEARTYPE);
+ return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize,
+ (const CFX_Matrix*)pMatrix, argb,
+ FXTEXT_CLEARTYPE);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
}
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index 5f10e842ac..80f76fba9f 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -219,9 +219,9 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
if (matrix) {
affine_matrix.Concat(*matrix);
}
- device->DrawNormalText(
- str.GetLength(), pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(str.GetLength(), pCharPos, m_pFont,
+ (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor,
+ FXTEXT_CLEARTYPE);
}
void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
@@ -238,8 +238,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap,
FX_RECT geRect(0, 0, (int)geWidth, iTextHeight);
ge.FillRect(&geRect, m_backgroundColor);
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
- ge.DrawNormalText(str.GetLength(), pCharPos, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(str.GetLength(), pCharPos, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
CFX_FxgeDevice geBitmap;
geBitmap.Attach(pOutBitmap, false, nullptr, false);
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index e2bbfd5726..632738779a 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -231,8 +231,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
FX_RECT rect(0, 0, strWidth, iTextHeight);
ge.FillRect(&rect, m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
} else {
@@ -242,9 +241,8 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(7, 6);
iLen = tempStr.GetLength();
@@ -253,8 +251,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
if (pOutBitmap) {
FX_RECT rect1(0, 0, strWidth, iTextHeight);
ge.FillRect(&rect1, m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 7, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 7, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 47 * multiple,
m_Height - iTextHeight);
@@ -266,9 +263,8 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 7, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 7, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(0, 1);
iLen = tempStr.GetLength();
@@ -282,8 +278,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
} else {
@@ -292,9 +287,8 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
FX_Free(pCharPos);
}
diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 0a7f3a8a50..fb95f264a0 100644
--- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -222,8 +222,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
} else {
@@ -231,9 +230,8 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
(FX_FLOAT)leftPosition * m_outputHScale,
(FX_FLOAT)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(
- iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(4, 4);
iLen = tempStr.GetLength();
@@ -243,8 +241,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
delete ge.GetBitmap();
ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 4, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 33 * multiple,
m_Height - iTextHeight);
@@ -256,9 +253,8 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 4, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 4, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
FX_Free(pCharPos);
}
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 01660b75c7..12acb5280b 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -190,8 +190,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (pOutBitmap) {
ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
} else {
@@ -201,9 +200,8 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(6, 5);
iLen = tempStr.GetLength();
@@ -211,8 +209,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (pOutBitmap) {
FX_RECT rect2(0, 0, (int)strWidth, iTextHeight);
ge.FillRect(&rect2, m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 6, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple,
m_Height - iTextHeight);
@@ -224,9 +221,8 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 6, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(0, 1);
iLen = tempStr.GetLength();
@@ -239,8 +235,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
delete ge.GetBitmap();
ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
} else {
@@ -249,9 +244,8 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(11, 1);
iLen = tempStr.GetLength();
@@ -260,8 +254,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
delete ge.GetBitmap();
ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
ge.GetBitmap()->Clear(m_backgroundColor);
- ge.DrawNormalText(iLen, pCharPos + 11, m_pFont,
- CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
+ ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, (FX_FLOAT)iFontSize,
&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple,
m_Height - iTextHeight);
@@ -273,9 +266,8 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
if (matrix) {
affine_matrix1.Concat(*matrix);
}
- device->DrawNormalText(
- iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(),
- (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
+ device->DrawNormalText(iLen, pCharPos + 11, m_pFont, (FX_FLOAT)iFontSize,
+ &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
}
FX_Free(pCharPos);
}
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 068ed015f4..b9f8287ae4 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -1294,9 +1294,8 @@ FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
m.Concat(*matrix);
}
FX_BOOL result = m_renderDevice->DrawNormalText(
- length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(),
- -m_info.fontSize * m_info.fontHScale, &m, m_info.fillColor->m_info.argb,
- FXTEXT_CLEARTYPE);
+ length, charPos, m_info.font, -m_info.fontSize * m_info.fontHScale, &m,
+ m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE);
if (!result)
return FWL_Error::Indefinite;
FX_Free(charPos);