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

Side by Side Diff: xfa/fxbarcode/oned/BC_OnedEAN13Writer.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_OneDimWriter.cpp ('k') | xfa/fxbarcode/oned/BC_OnedEAN8Writer.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 2009 ZXing authors 8 * Copyright 2009 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 } 147 }
148 pos += 148 pos +=
149 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); 149 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e);
150 if (e != BCExceptionNO) { 150 if (e != BCExceptionNO) {
151 FX_Free(result); 151 FX_Free(result);
152 return NULL; 152 return NULL;
153 } 153 }
154 return result; 154 return result;
155 } 155 }
156
156 void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, 157 void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
157 CFX_DIBitmap* pOutBitmap, 158 CFX_DIBitmap* pOutBitmap,
158 CFX_RenderDevice* device, 159 CFX_RenderDevice* device,
159 const CFX_Matrix* matrix, 160 const CFX_Matrix* matrix,
160 int32_t barWidth, 161 int32_t barWidth,
161 int32_t multiple, 162 int32_t multiple,
162 int32_t& e) { 163 int32_t& e) {
163 if (device == NULL && pOutBitmap == NULL) { 164 if (!device && !pOutBitmap) {
164 e = BCExceptionIllegalArgument; 165 e = BCExceptionIllegalArgument;
165 return; 166 return;
166 } 167 }
167 int32_t leftPadding = 7 * multiple; 168 int32_t leftPadding = 7 * multiple;
168 int32_t leftPosition = 3 * multiple + leftPadding; 169 int32_t leftPosition = 3 * multiple + leftPadding;
169 CFX_ByteString str = FX_UTF8Encode(contents); 170 CFX_ByteString str = FX_UTF8Encode(contents);
170 int32_t iLen = str.GetLength(); 171 int32_t iLen = str.GetLength();
171 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); 172 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen);
172 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); 173 FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen);
173 CFX_FxgeDevice geBitmap; 174 CFX_FxgeDevice geBitmap;
174 if (pOutBitmap) { 175 if (pOutBitmap)
175 geBitmap.Attach(pOutBitmap); 176 geBitmap.Attach(pOutBitmap, false, nullptr, false);
176 } 177
177 int32_t iFontSize = (int32_t)fabs(m_fFontSize); 178 int32_t iFontSize = (int32_t)fabs(m_fFontSize);
178 int32_t iTextHeight = iFontSize + 1; 179 int32_t iTextHeight = iFontSize + 1;
179 CFX_ByteString tempStr = str.Mid(1, 6); 180 CFX_ByteString tempStr = str.Mid(1, 6);
180 int32_t strWidth = multiple * 42; 181 int32_t strWidth = multiple * 42;
181 if (pOutBitmap == NULL) { 182 if (!pOutBitmap) {
182 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 183 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
183 CFX_FloatRect rect( 184 CFX_FloatRect rect(
184 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), 185 (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight),
185 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); 186 (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height);
186 matr.Concat(*matrix); 187 matr.Concat(*matrix);
187 matr.TransformRect(rect); 188 matr.TransformRect(rect);
188 FX_RECT re = rect.GetOutterRect(); 189 FX_RECT re = rect.GetOutterRect();
189 device->FillRect(&re, m_backgroundColor); 190 device->FillRect(&re, m_backgroundColor);
190 CFX_FloatRect rect1( 191 CFX_FloatRect rect1(
191 (FX_FLOAT)(leftPosition + 47 * multiple), 192 (FX_FLOAT)(leftPosition + 47 * multiple),
192 (FX_FLOAT)(m_Height - iTextHeight), 193 (FX_FLOAT)(m_Height - iTextHeight),
193 (FX_FLOAT)(leftPosition + 47 * multiple + strWidth - 0.5), 194 (FX_FLOAT)(leftPosition + 47 * multiple + strWidth - 0.5),
194 (FX_FLOAT)m_Height); 195 (FX_FLOAT)m_Height);
195 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 196 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
196 matr1.Concat(*matrix); 197 matr1.Concat(*matrix);
197 matr1.TransformRect(rect1); 198 matr1.TransformRect(rect1);
198 re = rect1.GetOutterRect(); 199 re = rect1.GetOutterRect();
199 device->FillRect(&re, m_backgroundColor); 200 device->FillRect(&re, m_backgroundColor);
200 int32_t strWidth1 = multiple * 7; 201 int32_t strWidth1 = multiple * 7;
201 CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); 202 CFX_Matrix matr2(m_outputHScale, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
202 CFX_FloatRect rect2(0.0f, (FX_FLOAT)(m_Height - iTextHeight), 203 CFX_FloatRect rect2(0.0f, (FX_FLOAT)(m_Height - iTextHeight),
203 (FX_FLOAT)strWidth1 - 0.5f, (FX_FLOAT)m_Height); 204 (FX_FLOAT)strWidth1 - 0.5f, (FX_FLOAT)m_Height);
204 matr2.Concat(*matrix); 205 matr2.Concat(*matrix);
205 matr2.TransformRect(rect2); 206 matr2.TransformRect(rect2);
206 re = rect2.GetOutterRect(); 207 re = rect2.GetOutterRect();
207 device->FillRect(&re, m_backgroundColor); 208 device->FillRect(&re, m_backgroundColor);
208 } 209 }
209 FX_FLOAT blank = 0.0; 210 FX_FLOAT blank = 0.0;
210 iLen = tempStr.GetLength(); 211 iLen = tempStr.GetLength();
211 if (pOutBitmap == NULL) { 212 if (!pOutBitmap) {
212 strWidth = (int32_t)(strWidth * m_outputHScale); 213 strWidth = (int32_t)(strWidth * m_outputHScale);
213 } 214 }
214 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, 215 CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize,
215 blank); 216 blank);
216 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); 217 CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize);
217 CFX_FxgeDevice ge; 218 CFX_FxgeDevice ge;
218 if (pOutBitmap) { 219 if (pOutBitmap) {
219 ge.Create(strWidth, iTextHeight, FXDIB_Argb); 220 ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
220 FX_RECT rect(0, 0, strWidth, iTextHeight); 221 FX_RECT rect(0, 0, strWidth, iTextHeight);
221 ge.FillRect(&rect, m_backgroundColor); 222 ge.FillRect(&rect, m_backgroundColor);
222 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, 223 ge.DrawNormalText(iLen, pCharPos + 1, m_pFont,
223 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, 224 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
224 (CFX_Matrix*)&affine_matrix, m_fontColor, 225 (CFX_Matrix*)&affine_matrix, m_fontColor,
225 FXTEXT_CLEARTYPE); 226 FXTEXT_CLEARTYPE);
226 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); 227 geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight);
227 } else { 228 } else {
228 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 229 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
229 (FX_FLOAT)leftPosition * m_outputHScale, 230 (FX_FLOAT)leftPosition * m_outputHScale,
(...skipping 28 matching lines...) Expand all
258 affine_matrix1.Concat(*matrix); 259 affine_matrix1.Concat(*matrix);
259 } 260 }
260 device->DrawNormalText(iLen, pCharPos + 7, m_pFont, 261 device->DrawNormalText(iLen, pCharPos + 7, m_pFont,
261 CFX_GEModule::Get()->GetFontCache(), 262 CFX_GEModule::Get()->GetFontCache(),
262 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, 263 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1,
263 m_fontColor, FXTEXT_CLEARTYPE); 264 m_fontColor, FXTEXT_CLEARTYPE);
264 } 265 }
265 tempStr = str.Mid(0, 1); 266 tempStr = str.Mid(0, 1);
266 iLen = tempStr.GetLength(); 267 iLen = tempStr.GetLength();
267 strWidth = multiple * 7; 268 strWidth = multiple * 7;
268 if (pOutBitmap == NULL) { 269 if (!pOutBitmap)
269 strWidth = (int32_t)(strWidth * m_outputHScale); 270 strWidth = (int32_t)(strWidth * m_outputHScale);
270 } 271
271 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, 272 CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize,
272 blank); 273 blank);
273 if (pOutBitmap) { 274 if (pOutBitmap) {
274 delete ge.GetBitmap(); 275 delete ge.GetBitmap();
275 ge.Create(strWidth, iTextHeight, FXDIB_Argb); 276 ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr);
276 ge.GetBitmap()->Clear(m_backgroundColor); 277 ge.GetBitmap()->Clear(m_backgroundColor);
277 ge.DrawNormalText(iLen, pCharPos, m_pFont, 278 ge.DrawNormalText(iLen, pCharPos, m_pFont,
278 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, 279 CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize,
279 (CFX_Matrix*)&affine_matrix, m_fontColor, 280 (CFX_Matrix*)&affine_matrix, m_fontColor,
280 FXTEXT_CLEARTYPE); 281 FXTEXT_CLEARTYPE);
281 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); 282 geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight);
282 } else { 283 } else {
283 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0, 284 CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0,
284 (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); 285 (FX_FLOAT)(m_Height - iTextHeight + iFontSize));
285 if (matrix) { 286 if (matrix) {
286 affine_matrix1.Concat(*matrix); 287 affine_matrix1.Concat(*matrix);
287 } 288 }
288 device->DrawNormalText(iLen, pCharPos, m_pFont, 289 device->DrawNormalText(iLen, pCharPos, m_pFont,
289 CFX_GEModule::Get()->GetFontCache(), 290 CFX_GEModule::Get()->GetFontCache(),
290 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1, 291 (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix1,
291 m_fontColor, FXTEXT_CLEARTYPE); 292 m_fontColor, FXTEXT_CLEARTYPE);
292 } 293 }
293 FX_Free(pCharPos); 294 FX_Free(pCharPos);
294 } 295 }
296
295 void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, 297 void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents,
296 uint8_t* code, 298 uint8_t* code,
297 int32_t codeLength, 299 int32_t codeLength,
298 FX_BOOL isDevice, 300 FX_BOOL isDevice,
299 int32_t& e) { 301 int32_t& e) {
300 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); 302 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e);
301 } 303 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.cpp ('k') | xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698