From 426b85af0f780e312221b061e2699c31821872f9 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 4 May 2017 15:11:01 -0700 Subject: Reduce 1D barcode DrawPath calls. Draw vertical 1D barcodes as segments of lines, instead of as individual pixels. Change-Id: Ic260118660994514ce9023aacf13b16adfc8d362 Reviewed-on: https://pdfium-review.googlesource.com/4595 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- fxbarcode/oned/BC_OneDimWriter.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp index 14c5911f95..71f440faf1 100644 --- a/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/fxbarcode/oned/BC_OneDimWriter.cpp @@ -268,21 +268,39 @@ bool CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, CFX_GraphStateData stateData; CFX_PathData path; - path.AppendRect(0, 0, (float)m_Width, (float)m_Height); + path.AppendRect(0, 0, static_cast(m_Width), + static_cast(m_Height)); device->DrawPath(&path, matrix, &stateData, m_backgroundColor, m_backgroundColor, FXFILL_ALTERNATE); - CFX_Matrix matri(m_outputHScale, 0.0, 0.0, (float)m_Height, 0.0, 0.0); + CFX_Matrix matri(m_outputHScale, 0.0, 0.0, static_cast(m_Height), 0.0, + 0.0); matri.Concat(*matrix); for (int32_t x = 0; x < m_output->GetWidth(); x++) { + int32_t yStart = 0; + bool drawing = false; for (int32_t y = 0; y < m_output->GetHeight(); y++) { - CFX_PathData rect; - rect.AppendRect((float)x, (float)y, (float)(x + 1), (float)(y + 1)); - if (m_output->Get(x, y)) { - CFX_GraphStateData data; - device->DrawPath(&rect, &matri, &data, m_barColor, 0, FXFILL_WINDING); + bool draw = m_output->Get(x, y); + if (!drawing) { + if (draw) { + drawing = true; + yStart = y; + } + continue; } + + if (draw && y != m_output->GetHeight() - 1) + continue; + + drawing = false; + int32_t yEnd = draw ? y + 1 : y; + CFX_PathData rect; + rect.AppendRect(static_cast(x), static_cast(yStart), + static_cast((x + 1)), static_cast(yEnd)); + CFX_GraphStateData data; + device->DrawPath(&rect, &matri, &data, m_barColor, 0, FXFILL_WINDING); } } + return m_locTextLoc == BC_TEXT_LOC_NONE || contents.Find(' ') == -1 || ShowChars(contents, device, matrix, m_barWidth, m_multiple); } -- cgit v1.2.3