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

Side by Side Diff: xfa/fde/fde_gedevice.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_gedevice.h" 7 #include "xfa/fde/fde_gedevice.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 void* handle = nullptr; 99 void* handle = nullptr;
100 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, 100 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0,
101 handle); 101 handle);
102 while (m_pDevice->ContinueDIBits(handle, nullptr)) { 102 while (m_pDevice->ContinueDIBits(handle, nullptr)) {
103 } 103 }
104 m_pDevice->CancelDIBits(handle); 104 m_pDevice->CancelDIBits(handle);
105 return !!handle; 105 return !!handle;
106 } 106 }
107 bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, 107 bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
108 CFGAS_GEFont* pFont, 108 const CFX_RetainPtr<CFGAS_GEFont>& pFont,
109 const FXTEXT_CHARPOS* pCharPos, 109 const FXTEXT_CHARPOS* pCharPos,
110 int32_t iCount, 110 int32_t iCount,
111 FX_FLOAT fFontSize, 111 FX_FLOAT fFontSize,
112 const CFX_Matrix* pMatrix) { 112 const CFX_Matrix* pMatrix) {
113 ASSERT(pBrush && pFont && pCharPos && iCount > 0); 113 ASSERT(pBrush && pFont && pCharPos && iCount > 0);
114 CFX_Font* pFxFont = pFont->GetDevFont(); 114 CFX_Font* pFxFont = pFont->GetDevFont();
115 FX_ARGB argb = pBrush->GetColor(); 115 FX_ARGB argb = pBrush->GetColor();
116 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && 116 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
117 !pFxFont->IsItalic()) { 117 !pFxFont->IsItalic()) {
118 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; 118 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
119 FX_FLOAT* pAM; 119 FX_FLOAT* pAM;
120 for (int32_t i = 0; i < iCount; ++i) { 120 for (int32_t i = 0; i < iCount; ++i) {
121 static const FX_FLOAT mc = 0.267949f; 121 static const FX_FLOAT mc = 0.267949f;
122 pAM = pCP->m_AdjustMatrix; 122 pAM = pCP->m_AdjustMatrix;
123 pAM[2] = mc * pAM[0] + pAM[2]; 123 pAM[2] = mc * pAM[0] + pAM[2];
124 pAM[3] = mc * pAM[1] + pAM[3]; 124 pAM[3] = mc * pAM[1] + pAM[3];
125 pCP++; 125 pCP++;
126 } 126 }
127 } 127 }
128 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; 128 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
129 CFGAS_GEFont* pCurFont = nullptr; 129 CFX_RetainPtr<CFGAS_GEFont> pCurFont;
130 CFGAS_GEFont* pSTFont = nullptr; 130 CFX_RetainPtr<CFGAS_GEFont> pSTFont;
131 FXTEXT_CHARPOS* pCurCP = nullptr; 131 FXTEXT_CHARPOS* pCurCP = nullptr;
132 int32_t iCurCount = 0; 132 int32_t iCurCount = 0;
133 133
134 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 134 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
135 uint32_t dwFontStyle = pFont->GetFontStyles(); 135 uint32_t dwFontStyle = pFont->GetFontStyles();
136 CFX_Font FxFont; 136 CFX_Font FxFont;
137 CFX_SubstFont* SubstFxFont = new CFX_SubstFont(); 137 CFX_SubstFont* SubstFxFont = new CFX_SubstFont();
138 FxFont.SetSubstFont(std::unique_ptr<CFX_SubstFont>(SubstFxFont)); 138 FxFont.SetSubstFont(std::unique_ptr<CFX_SubstFont>(SubstFxFont));
139 SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; 139 SubstFxFont->m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
140 SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; 140 SubstFxFont->m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 const CFX_Matrix* pMatrix) { 321 const CFX_Matrix* pMatrix) {
322 CFDE_Path* pGePath = (CFDE_Path*)pPath; 322 CFDE_Path* pGePath = (CFDE_Path*)pPath;
323 if (!pGePath) 323 if (!pGePath)
324 return false; 324 return false;
325 if (!pBrush) 325 if (!pBrush)
326 return false; 326 return false;
327 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, 327 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr,
328 pBrush->GetColor(), 0, FXFILL_WINDING); 328 pBrush->GetColor(), 0, FXFILL_WINDING);
329 } 329 }
330 330
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698