summaryrefslogtreecommitdiff
path: root/core/fxge/win32
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-25 20:06:50 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-25 20:06:50 +0000
commit30dc6aaf878b2c55efcf7598fdb8886e06d14e01 (patch)
tree2de58de8c2eddd4efb5dc8a8c5b54cd3faad4972 /core/fxge/win32
parent958142efa4561b5efd52733ad6c3b889cf49b3ae (diff)
downloadpdfium-30dc6aaf878b2c55efcf7598fdb8886e06d14e01.tar.xz
Add FxAlignToBoundary<>() template helper function.
Because I nearly botched this trivial calculation in the previous CL. Change-Id: I7438f9d3476d93b7899c2d7d761234769f53f9e3 Reviewed-on: https://pdfium-review.googlesource.com/43010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/win32')
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 8d361e7c5e..57780344ab 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -525,7 +525,7 @@ RetainPtr<CFX_DIBitmap> StretchMonoToGray(
int result_width = pClipRect->Width();
int result_height = pClipRect->Height();
- int result_pitch = (result_width + 3) / 4 * 4;
+ int result_pitch = FxAlignToBoundary<4>(result_width);
auto pStretched = pdfium::MakeRetain<CFX_DIBitmap>();
if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb))
return nullptr;
@@ -620,10 +620,10 @@ void OutputImageMask(GpGraphics* pGraphics,
pBitmap->StretchTo(dest_width, dest_height, false, &image_clip);
}
GpBitmap* bitmap;
- CallFunc(GdipCreateBitmapFromScan0)(image_clip.Width(), image_clip.Height(),
- (image_clip.Width() + 3) / 4 * 4,
- PixelFormat8bppIndexed,
- pStretched->GetBuffer(), &bitmap);
+ CallFunc(GdipCreateBitmapFromScan0)(
+ image_clip.Width(), image_clip.Height(),
+ FxAlignToBoundary<4>(image_clip.Width()), PixelFormat8bppIndexed,
+ pStretched->GetBuffer(), &bitmap);
int a;
int r;
int g;
@@ -772,7 +772,7 @@ GpPen* GdipCreatePenImpl(const CFX_GraphStateData* pGraphState,
CallFunc(GdipSetPenLineJoin)(pPen, lineJoin);
if (!pGraphState->m_DashArray.empty()) {
float* pDashArray =
- FX_Alloc(float, (pGraphState->m_DashArray.size() + 1) & ~1);
+ FX_Alloc(float, FxAlignToBoundary<2>(pGraphState->m_DashArray.size()));
int nCount = 0;
float on_leftover = 0, off_leftover = 0;
for (size_t i = 0; i < pGraphState->m_DashArray.size(); i += 2) {