summaryrefslogtreecommitdiff
path: root/core/fxge/win32/cfx_psrenderer.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-10 13:40:26 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-10 13:40:26 -0800
commit6c0c48227aa024aa6e188ed7adf4d7c3d410cff9 (patch)
tree92868db030219d25fd74c75a77893c8ddf8d0048 /core/fxge/win32/cfx_psrenderer.cpp
parent29a9f87a8bcd1b6913bb070c5a1514af41fab3ef (diff)
downloadpdfium-6c0c48227aa024aa6e188ed7adf4d7c3d410cff9.tar.xz
Remove CFX_ArrayTemplate in cfx_psrender.
Use unique_ptr while we're at it. Review-Url: https://codereview.chromium.org/2618373003
Diffstat (limited to 'core/fxge/win32/cfx_psrenderer.cpp')
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp77
1 files changed, 36 insertions, 41 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;