summaryrefslogtreecommitdiff
path: root/fxbarcode/oned
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-04 15:11:01 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-04 22:39:23 +0000
commit426b85af0f780e312221b061e2699c31821872f9 (patch)
tree6b1a9ea33c4cd0b3decec47c12ef617d754e5ce3 /fxbarcode/oned
parentb8a8c43f394277d1f87320a4f01b4d5c38e81113 (diff)
downloadpdfium-426b85af0f780e312221b061e2699c31821872f9.tar.xz
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 <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/oned')
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.cpp32
1 files 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<float>(m_Width),
+ static_cast<float>(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<float>(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<float>(x), static_cast<float>(yStart),
+ static_cast<float>((x + 1)), static_cast<float>(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);
}