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

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

Issue 2010813003: Remove default arguments from CFX_FxgeDevice. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@fxgeclean2_textrenderer
Patch Set: rebase Created 4 years, 6 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/cagg_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 18 matching lines...) Expand all
29 m_subWriter = NULL; 29 m_subWriter = NULL;
30 m_bLeftPadding = TRUE; 30 m_bLeftPadding = TRUE;
31 m_bRightPadding = TRUE; 31 m_bRightPadding = TRUE;
32 } 32 }
33 void CBC_OnedUPCAWriter::Init() { 33 void CBC_OnedUPCAWriter::Init() {
34 m_subWriter = new CBC_OnedEAN13Writer; 34 m_subWriter = new CBC_OnedEAN13Writer;
35 } 35 }
36 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { 36 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {
37 delete m_subWriter; 37 delete m_subWriter;
38 } 38 }
39
39 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( 40 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity(
40 const CFX_WideStringC& contents) { 41 const CFX_WideStringC& contents) {
41 int32_t i = 0; 42 for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) {
42 for (i = 0; i < contents.GetLength(); i++) { 43 if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9')
43 if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') {
44 continue;
45 } else {
46 return FALSE; 44 return FALSE;
47 }
48 } 45 }
49 return TRUE; 46 return TRUE;
50 } 47 }
48
51 CFX_WideString CBC_OnedUPCAWriter::FilterContents( 49 CFX_WideString CBC_OnedUPCAWriter::FilterContents(
52 const CFX_WideStringC& contents) { 50 const CFX_WideStringC& contents) {
53 CFX_WideString filtercontents; 51 CFX_WideString filtercontents;
54 FX_WCHAR ch; 52 FX_WCHAR ch;
55 for (int32_t i = 0; i < contents.GetLength(); i++) { 53 for (int32_t i = 0; i < contents.GetLength(); i++) {
56 ch = contents.GetAt(i); 54 ch = contents.GetAt(i);
57 if (ch > 175) { 55 if (ch > 175) {
58 i++; 56 i++;
59 continue; 57 continue;
60 } 58 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 e = BCExceptionOnlyEncodeUPC_A; 97 e = BCExceptionOnlyEncodeUPC_A;
100 return NULL; 98 return NULL;
101 } 99 }
102 CFX_ByteString toEAN13String = '0' + contents; 100 CFX_ByteString toEAN13String = '0' + contents;
103 m_iDataLenth = 13; 101 m_iDataLenth = 13;
104 uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, 102 uint8_t* ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth,
105 outHeight, hints, e); 103 outHeight, hints, e);
106 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 104 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
107 return ret; 105 return ret;
108 } 106 }
107
109 void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, 108 void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
110 CFX_DIBitmap* pOutBitmap, 109 CFX_DIBitmap* pOutBitmap,
111 CFX_RenderDevice* device, 110 CFX_RenderDevice* device,
112 const CFX_Matrix* matrix, 111 const CFX_Matrix* matrix,
113 int32_t barWidth, 112 int32_t barWidth,
114 int32_t multiple, 113 int32_t multiple,
115 int32_t& e) { 114 int32_t& e) {
116 if (device == NULL && pOutBitmap == NULL) { 115 if (!device && !pOutBitmap) {
117 e = BCExceptionIllegalArgument; 116 e = BCExceptionIllegalArgument;
118 return; 117 return;
119 } 118 }
119
120 int32_t leftPadding = 7 * multiple; 120 int32_t leftPadding = 7 * multiple;
121 int32_t leftPosition = 10 * multiple + leftPadding; 121 int32_t leftPosition = 10 * multiple + leftPadding;
122 CFX_ByteString str = FX_UTF8Encode(contents); 122 CFX_ByteString str = FX_UTF8Encode(contents);
123 int32_t iLen = str.GetLength(); 123 int32_t iLen = str.GetLength();
124 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); 124 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen);
125 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); 125 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen);
126 CFX_ByteString tempStr = str.Mid(1, 5); 126 CFX_ByteString tempStr = str.Mid(1, 5);
127 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; 127 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple;
128 FX_FLOAT blank = 0.0; 128 FX_FLOAT blank = 0.0;
129 CFX_FxgeDevice geBitmap; 129 CFX_FxgeDevice geBitmap;
130 if (pOutBitmap) { 130 if (pOutBitmap)
131 geBitmap.Attach(pOutBitmap); 131 geBitmap.Attach(pOutBitmap, false, nullptr, false);
132 } 132
133 iLen = tempStr.GetLength(); 133 iLen = tempStr.GetLength();
134 int32_t iFontSize = (int32_t)fabs(m_fFontSize); 134 int32_t iFontSize = (int32_t)fabs(m_fFontSize);
135 int32_t iTextHeight = iFontSize + 1; 135 int32_t iTextHeight = iFontSize + 1;
136 if (pOutBitmap == NULL) { 136 if (!pOutBitmap) {
137 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 137 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
138 CFX_FloatRect rect( 138 CFX_FloatRect rect(
139 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), 139 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
140 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); 140 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height);
141 matr.Concat(*matrix); 141 matr.Concat(*matrix);
142 matr.TransformRect(rect); 142 matr.TransformRect(rect);
143 FX_RECT re = rect.GetOutterRect(); 143 FX_RECT re = rect.GetOutterRect();
144 device->FillRect(&re, m_backgroundColor); 144 device->FillRect(&re, m_backgroundColor);
145 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 145 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
146 CFX_FloatRect rect1( 146 CFX_FloatRect rect1(
(...skipping 24 matching lines...) Expand all
171 re = rect3.GetOutterRect(); 171 re = rect3.GetOutterRect();
172 device->FillRect(&re, m_backgroundColor); 172 device->FillRect(&re, m_backgroundColor);
173 } 173 }
174 if (pOutBitmap == NULL) { 174 if (pOutBitmap == NULL) {
175 strWidth = strWidth * m_outputHScale; 175 strWidth = strWidth * m_outputHScale;
176 } 176 }
177 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); 177 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank);
178 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); 178 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
179 CFX_FxgeDevice ge; 179 CFX_FxgeDevice ge;
180 if (pOutBitmap) { 180 if (pOutBitmap) {
181 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); 181 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
182 ge.GetBitmap()->Clear(m_backgroundColor); 182 ge.GetBitmap()->Clear(m_backgroundColor);
183 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, 183 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
184 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, 184 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
185 (CFX_Matrix*)&affine_matrix, m_fontColor, 185 (CFX_Matrix*)&affine_matrix, m_fontColor,
186 FXTEXT_CLEARTYPE); 186 FXTEXT_CLEARTYPE);
187 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); 187 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
188 } else { 188 } else {
189 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 189 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
190 (FX_FLOAT)leftPosition * m_outputHScale, 190 (FX_FLOAT)leftPosition * m_outputHScale,
191 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 191 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 224 }
225 tempStr = str.Mid(0, 1); 225 tempStr = str.Mid(0, 1);
226 iLen = tempStr.GetLength(); 226 iLen = tempStr.GetLength();
227 strWidth = (FX_FLOAT)multiple * 7; 227 strWidth = (FX_FLOAT)multiple * 7;
228 if (pOutBitmap == NULL) { 228 if (pOutBitmap == NULL) {
229 strWidth = strWidth * m_outputHScale; 229 strWidth = strWidth * m_outputHScale;
230 } 230 }
231 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); 231 CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank);
232 if (pOutBitmap) { 232 if (pOutBitmap) {
233 delete ge.GetBitmap(); 233 delete ge.GetBitmap();
234 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); 234 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
235 ge.GetBitmap()->Clear(m_backgroundColor); 235 ge.GetBitmap()->Clear(m_backgroundColor);
236 ge.DrawNormalText(iLen, pCharPos, m_pFont, 236 ge.DrawNormalText(iLen, pCharPos, m_pFont,
237 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, 237 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
238 (CFX_Matrix*)&affine_matrix, m_fontColor, 238 (CFX_Matrix*)&affine_matrix, m_fontColor,
239 FXTEXT_CLEARTYPE); 239 FXTEXT_CLEARTYPE);
240 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); 240 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
241 } else { 241 } else {
242 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,
243 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 243 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
244 if (matrix) { 244 if (matrix) {
245 affine_matrix1.Concat(*matrix); 245 affine_matrix1.Concat(*matrix);
246 } 246 }
247 device->DrawNormalText(iLen, pCharPos, m_pFont, 247 device->DrawNormalText(iLen, pCharPos, m_pFont,
248 CFX_GEModule::Get()->GetFontCache(), 248 CFX_GEModule::Get()->GetFontCache(),
249 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, 249 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1,
250 m_fontColor, FXTEXT_CLEARTYPE); 250 m_fontColor, FXTEXT_CLEARTYPE);
251 } 251 }
252 tempStr = str.Mid(11, 1); 252 tempStr = str.Mid(11, 1);
253 iLen = tempStr.GetLength(); 253 iLen = tempStr.GetLength();
254 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); 254 CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank);
255 if (pOutBitmap) { 255 if (pOutBitmap) {
256 delete ge.GetBitmap(); 256 delete ge.GetBitmap();
257 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); 257 ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr);
258 ge.GetBitmap()->Clear(m_backgroundColor); 258 ge.GetBitmap()->Clear(m_backgroundColor);
259 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, 259 ge.DrawNormalText(iLen, pCharPos + 11, m_pFont,
260 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, 260 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
261 (CFX_Matrix*)&affine_matrix, m_fontColor, 261 (CFX_Matrix*)&affine_matrix, m_fontColor,
262 FXTEXT_CLEARTYPE); 262 FXTEXT_CLEARTYPE);
263 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, 263 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple,
264 m_Height - iTextHeight); 264 m_Height - iTextHeight);
265 } else { 265 } else {
266 CFX_Matrix affine_matrix1( 266 CFX_Matrix affine_matrix1(
267 1.0, 0.0, 0.0, -1.0, 267 1.0, 0.0, 0.0, -1.0,
268 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, 268 (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale,
269 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 269 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
270 if (matrix) { 270 if (matrix) {
271 affine_matrix1.Concat(*matrix); 271 affine_matrix1.Concat(*matrix);
272 } 272 }
273 device->DrawNormalText(iLen, pCharPos + 11, m_pFont, 273 device->DrawNormalText(iLen, pCharPos + 11, m_pFont,
274 CFX_GEModule::Get()->GetFontCache(), 274 CFX_GEModule::Get()->GetFontCache(),
275 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, 275 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1,
276 m_fontColor, FXTEXT_CLEARTYPE); 276 m_fontColor, FXTEXT_CLEARTYPE);
277 } 277 }
278 FX_Free(pCharPos); 278 FX_Free(pCharPos);
279 } 279 }
280
280 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, 281 void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents,
281 uint8_t* code, 282 uint8_t* code,
282 int32_t codeLength, 283 int32_t codeLength,
283 FX_BOOL isDevice, 284 FX_BOOL isDevice,
284 int32_t& e) { 285 int32_t& e) {
285 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); 286 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e);
286 } 287 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp ('k') | xfa/fxgraphics/cagg_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698