Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: xfa/fde/fde_render.cpp

Issue 2609423003: Properly ref-count CFGAS_GEFont with CFX_RetainPtr. (Closed)
Patch Set: comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fde/fde_render.h" 7 #include "xfa/fde/fde_render.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fde/fde_gedevice.h" 10 #include "xfa/fde/fde_gedevice.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 m_pIterator.reset(); 101 m_pIterator.reset();
102 m_pBrush.reset(); 102 m_pBrush.reset();
103 m_CharPos.clear(); 103 m_CharPos.clear();
104 } 104 }
105 105
106 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, 106 void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
107 FDE_TEXTEDITPIECE* pText) { 107 FDE_TEXTEDITPIECE* pText) {
108 ASSERT(m_pRenderDevice); 108 ASSERT(m_pRenderDevice);
109 ASSERT(pTextSet && pText); 109 ASSERT(pTextSet && pText);
110 110
111 CFGAS_GEFont* pFont = pTextSet->GetFont(); 111 CFX_RetainPtr<CFGAS_GEFont> pFont = pTextSet->GetFont();
112 if (!pFont) 112 if (!pFont)
113 return; 113 return;
114 114
115 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false); 115 int32_t iCount = pTextSet->GetDisplayPos(pText, nullptr, false);
116 if (iCount < 1) 116 if (iCount < 1)
117 return; 117 return;
118 118
119 if (!m_pBrush) 119 if (!m_pBrush)
120 m_pBrush = pdfium::MakeUnique<CFDE_Brush>(); 120 m_pBrush = pdfium::MakeUnique<CFDE_Brush>();
121 121
122 if (m_CharPos.size() < static_cast<size_t>(iCount)) 122 if (m_CharPos.size() < static_cast<size_t>(iCount))
123 m_CharPos.resize(iCount, FXTEXT_CHARPOS()); 123 m_CharPos.resize(iCount, FXTEXT_CHARPOS());
124 124
125 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false); 125 iCount = pTextSet->GetDisplayPos(pText, m_CharPos.data(), false);
126 FX_FLOAT fFontSize = pTextSet->GetFontSize(); 126 FX_FLOAT fFontSize = pTextSet->GetFontSize();
127 FX_ARGB dwColor = pTextSet->GetFontColor(); 127 FX_ARGB dwColor = pTextSet->GetFontColor();
128 m_pBrush->SetColor(dwColor); 128 m_pBrush->SetColor(dwColor);
129 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount, 129 m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_CharPos.data(), iCount,
130 fFontSize, &m_Transform); 130 fFontSize, &m_Transform);
131 } 131 }
132 132
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698