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

Side by Side Diff: xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp

Issue 2350243002: Make CFX_FontCache global (Closed)
Patch Set: Remove fix leaks code. Created 4 years, 3 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
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp ('k') | xfa/fxgraphics/cfx_graphics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2010 ZXing authors 8 * Copyright 2010 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 if (!pOutBitmap) 184 if (!pOutBitmap)
185 strWidth = strWidth * m_outputHScale; 185 strWidth = strWidth * m_outputHScale;
186 186
187 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); 187 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank);
188 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); 188 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
189 CFX_FxgeDevice ge; 189 CFX_FxgeDevice ge;
190 if (pOutBitmap) { 190 if (pOutBitmap) {
191 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); 191 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
192 ge.GetBitmap()->Clear(m_backgroundColor); 192 ge.GetBitmap()->Clear(m_backgroundColor);
193 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, 193 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
194 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
195 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); 194 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
196 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); 195 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
197 } else { 196 } else {
198 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 197 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
199 (FX_FLOAT)leftPosition * m_outputHScale, 198 (FX_FLOAT)leftPosition * m_outputHScale,
200 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 199 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
201 if (matrix) { 200 if (matrix) {
202 affine_matrix1.Concat(*matrix); 201 affine_matrix1.Concat(*matrix);
203 } 202 }
204 device->DrawNormalText( 203 device->DrawNormalText(iLen, pCharPos + 1, m_pFont, (FX_FLOAT)iFontSize,
205 iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), 204 &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
206 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
207 } 205 }
208 tempStr = str.Mid(6, 5); 206 tempStr = str.Mid(6, 5);
209 iLen = tempStr.GetLength(); 207 iLen = tempStr.GetLength();
210 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); 208 CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank);
211 if (pOutBitmap) { 209 if (pOutBitmap) {
212 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); 210 FX_RECT rect2(0, 0, (int)strWidth, iTextHeight);
213 ge.FillRect(&rect2, m_backgroundColor); 211 ge.FillRect(&rect2, m_backgroundColor);
214 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, 212 ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, (FX_FLOAT)iFontSize,
215 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
216 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); 213 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
217 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, 214 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple,
218 m_Height - iTextHeight); 215 m_Height - iTextHeight);
219 } else { 216 } else {
220 CFX_Matrix affine_matrix1( 217 CFX_Matrix affine_matrix1(
221 1.0, 0.0, 0.0, -1.0, 218 1.0, 0.0, 0.0, -1.0,
222 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, 219 (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale,
223 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 220 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
224 if (matrix) { 221 if (matrix) {
225 affine_matrix1.Concat(*matrix); 222 affine_matrix1.Concat(*matrix);
226 } 223 }
227 device->DrawNormalText( 224 device->DrawNormalText(iLen, pCharPos + 6, m_pFont, (FX_FLOAT)iFontSize,
228 iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), 225 &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
229 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
230 } 226 }
231 tempStr = str.Mid(0, 1); 227 tempStr = str.Mid(0, 1);
232 iLen = tempStr.GetLength(); 228 iLen = tempStr.GetLength();
233 strWidth = (FX_FLOAT)multiple * 7; 229 strWidth = (FX_FLOAT)multiple * 7;
234 if (!pOutBitmap) 230 if (!pOutBitmap)
235 strWidth = strWidth * m_outputHScale; 231 strWidth = strWidth * m_outputHScale;
236 232
237 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); 233 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank);
238 if (pOutBitmap) { 234 if (pOutBitmap) {
239 delete ge.GetBitmap(); 235 delete ge.GetBitmap();
240 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); 236 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
241 ge.GetBitmap()->Clear(m_backgroundColor); 237 ge.GetBitmap()->Clear(m_backgroundColor);
242 ge.DrawNormalText(iLen, pCharPos, m_pFont, 238 ge.DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
243 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
244 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); 239 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
245 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); 240 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
246 } else { 241 } else {
247 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, 242 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0,
248 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 243 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
249 if (matrix) { 244 if (matrix) {
250 affine_matrix1.Concat(*matrix); 245 affine_matrix1.Concat(*matrix);
251 } 246 }
252 device->DrawNormalText( 247 device->DrawNormalText(iLen, pCharPos, m_pFont, (FX_FLOAT)iFontSize,
253 iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), 248 &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
254 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
255 } 249 }
256 tempStr = str.Mid(11, 1); 250 tempStr = str.Mid(11, 1);
257 iLen = tempStr.GetLength(); 251 iLen = tempStr.GetLength();
258 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); 252 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank);
259 if (pOutBitmap) { 253 if (pOutBitmap) {
260 delete ge.GetBitmap(); 254 delete ge.GetBitmap();
261 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); 255 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
262 ge.GetBitmap()->Clear(m_backgroundColor); 256 ge.GetBitmap()->Clear(m_backgroundColor);
263 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, 257 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, (FX_FLOAT)iFontSize,
264 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
265 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); 258 &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE);
266 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, 259 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple,
267 m_Height - iTextHeight); 260 m_Height - iTextHeight);
268 } else { 261 } else {
269 CFX_Matrix affine_matrix1( 262 CFX_Matrix affine_matrix1(
270 1.0, 0.0, 0.0, -1.0, 263 1.0, 0.0, 0.0, -1.0,
271 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, 264 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale,
272 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 265 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
273 if (matrix) { 266 if (matrix) {
274 affine_matrix1.Concat(*matrix); 267 affine_matrix1.Concat(*matrix);
275 } 268 }
276 device->DrawNormalText( 269 device->DrawNormalText(iLen, pCharPos + 11, m_pFont, (FX_FLOAT)iFontSize,
277 iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), 270 &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
278 (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE);
279 } 271 }
280 FX_Free(pCharPos); 272 FX_Free(pCharPos);
281 } 273 }
282 274
283 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, 275 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents,
284 uint8_t* code, 276 uint8_t* code,
285 int32_t codeLength, 277 int32_t codeLength,
286 FX_BOOL isDevice, 278 FX_BOOL isDevice,
287 int32_t& e) { 279 int32_t& e) {
288 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); 280 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e);
289 } 281 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp ('k') | xfa/fxgraphics/cfx_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698