From 30dc6aaf878b2c55efcf7598fdb8886e06d14e01 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 25 Sep 2018 20:06:50 +0000 Subject: 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 Reviewed-by: Lei Zhang --- core/fxge/win32/fx_win32_gdipext.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/fxge/win32') 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 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(); 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) { -- cgit v1.2.3