summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp77
-rw-r--r--core/fxge/win32/cfx_psrenderer.h7
2 files changed, 41 insertions, 43 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 0cd24faf83..c0d7557541 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -16,6 +16,7 @@
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/ge/fx_text_int.h"
#include "core/fxge/win32/cpsoutput.h"
+#include "third_party/base/ptr_util.h"
struct PSGlyph {
CFX_Font* m_pFont;
@@ -36,12 +37,7 @@ CFX_PSRenderer::CFX_PSRenderer() {
m_bInited = false;
}
-CFX_PSRenderer::~CFX_PSRenderer() {
- for (int i = 0; i < static_cast<int>(m_PSFontList.GetSize()); i++) {
- CPSFont* pFont = m_PSFontList[i];
- delete pFont;
- }
-}
+CFX_PSRenderer::~CFX_PSRenderer() {}
#define OUTPUT_PS(str) m_pOutput->OutputPS(str, sizeof str - 1)
@@ -84,32 +80,31 @@ bool CFX_PSRenderer::StartRendering() {
void CFX_PSRenderer::EndRendering() {
if (m_bInited) {
OUTPUT_PS("\nrestore\n");
+ m_bInited = false;
}
- m_bInited = false;
}
void CFX_PSRenderer::SaveState() {
StartRendering();
OUTPUT_PS("q\n");
- m_ClipBoxStack.Add(m_ClipBox);
+ m_ClipBoxStack.push_back(m_ClipBox);
}
void CFX_PSRenderer::RestoreState(bool bKeepSaved) {
StartRendering();
- if (bKeepSaved) {
+ if (bKeepSaved)
OUTPUT_PS("Q\nq\n");
- } else {
+ else
OUTPUT_PS("Q\n");
- }
+
m_bColorSet = false;
m_bGraphStateSet = false;
- int size = m_ClipBoxStack.GetSize();
- if (!size)
+ if (m_ClipBoxStack.empty())
return;
- m_ClipBox = m_ClipBoxStack.GetAt(size - 1);
+ m_ClipBox = m_ClipBoxStack.back();
if (!bKeepSaved)
- m_ClipBoxStack.RemoveAt(size - 1);
+ m_ClipBoxStack.pop_back();
}
void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
@@ -537,32 +532,31 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
const FXTEXT_CHARPOS& charpos,
int* ps_fontnum,
int* ps_glyphindex) {
- for (int i = 0; i < m_PSFontList.GetSize(); i++) {
- CPSFont* pPSFont = m_PSFontList[i];
- for (int j = 0; j < pPSFont->m_nGlyphs; j++)
+ int i = 0;
+ for (const auto& pPSFont : m_PSFontList) {
+ for (int j = 0; j < pPSFont->m_nGlyphs; j++) {
if (pPSFont->m_Glyphs[j].m_pFont == pFont &&
- pPSFont->m_Glyphs[j].m_GlyphIndex == charpos.m_GlyphIndex) {
- if ((!pPSFont->m_Glyphs[j].m_bGlyphAdjust && !charpos.m_bGlyphAdjust) ||
- (pPSFont->m_Glyphs[j].m_bGlyphAdjust && charpos.m_bGlyphAdjust &&
- (FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[0] -
- charpos.m_AdjustMatrix[0]) < 0.01 &&
- FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[1] -
- charpos.m_AdjustMatrix[1]) < 0.01 &&
- FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[2] -
- charpos.m_AdjustMatrix[2]) < 0.01 &&
- FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[3] -
- charpos.m_AdjustMatrix[3]) < 0.01))) {
- *ps_fontnum = i;
- *ps_glyphindex = j;
- return;
- }
+ pPSFont->m_Glyphs[j].m_GlyphIndex == charpos.m_GlyphIndex &&
+ ((!pPSFont->m_Glyphs[j].m_bGlyphAdjust && !charpos.m_bGlyphAdjust) ||
+ (pPSFont->m_Glyphs[j].m_bGlyphAdjust && charpos.m_bGlyphAdjust &&
+ (FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[0] -
+ charpos.m_AdjustMatrix[0]) < 0.01 &&
+ FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[1] -
+ charpos.m_AdjustMatrix[1]) < 0.01 &&
+ FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[2] -
+ charpos.m_AdjustMatrix[2]) < 0.01 &&
+ FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[3] -
+ charpos.m_AdjustMatrix[3]) < 0.01)))) {
+ *ps_fontnum = i;
+ *ps_glyphindex = j;
+ return;
}
+ }
+ ++i;
}
- if (m_PSFontList.GetSize() == 0 ||
- m_PSFontList[m_PSFontList.GetSize() - 1]->m_nGlyphs == 256) {
- CPSFont* pPSFont = new CPSFont;
- pPSFont->m_nGlyphs = 0;
- m_PSFontList.Add(pPSFont);
+ if (m_PSFontList.empty() || m_PSFontList.back()->m_nGlyphs == 256) {
+ m_PSFontList.push_back(pdfium::MakeUnique<CPSFont>());
+ m_PSFontList.back()->m_nGlyphs = 0;
CFX_ByteTextBuf buf;
buf << "8 dict begin/FontType 3 def/FontMatrix[1 0 0 1 0 0]def\n"
"/FontBBox[0 0 0 0]def/Encoding 256 array def 0 1 255{Encoding "
@@ -573,12 +567,13 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
"/BuildChar{1 index/Encoding get exch get 1 index/BuildGlyph get "
"exec}bind def\n"
"currentdict end\n";
- buf << "/X" << m_PSFontList.GetSize() - 1 << " exch definefont pop\n";
+ buf << "/X" << static_cast<uint32_t>(m_PSFontList.size() - 1)
+ << " exch definefont pop\n";
m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize());
buf.Clear();
}
- *ps_fontnum = m_PSFontList.GetSize() - 1;
- CPSFont* pPSFont = m_PSFontList[*ps_fontnum];
+ *ps_fontnum = m_PSFontList.size() - 1;
+ CPSFont* pPSFont = m_PSFontList[*ps_fontnum].get();
int glyphindex = pPSFont->m_nGlyphs;
*ps_glyphindex = glyphindex;
pPSFont->m_Glyphs[glyphindex].m_GlyphIndex = charpos.m_GlyphIndex;
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index c70708a5a4..e941739f44 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXGE_WIN32_CFX_PSRENDERER_H_
#define CORE_FXGE_WIN32_CFX_PSRENDERER_H_
+#include <memory>
+#include <vector>
+
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_graphstatedata.h"
@@ -90,8 +93,8 @@ class CFX_PSRenderer {
bool m_bColorSet;
uint32_t m_LastColor;
FX_RECT m_ClipBox;
- CFX_ArrayTemplate<CPSFont*> m_PSFontList;
- CFX_ArrayTemplate<FX_RECT> m_ClipBoxStack;
+ std::vector<std::unique_ptr<CPSFont>> m_PSFontList;
+ std::vector<FX_RECT> m_ClipBoxStack;
bool m_bInited;
};