From befa4506dc9d2a679c526aff96c09bcb0e9daecb Mon Sep 17 00:00:00 2001 From: thestig Date: Thu, 26 May 2016 20:15:19 -0700 Subject: Remove default arguments from CFX_FxgeDevice. Remove unused dithering code. Review-Url: https://codereview.chromium.org/2010813003 --- xfa/fde/tto/fde_textout.cpp | 3 ++- xfa/fwl/theme/cfwl_formtp.cpp | 4 ++-- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 10 ++++++---- xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp | 22 ++++++++++++---------- xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp | 21 ++++++++++++--------- xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp | 29 +++++++++++++++-------------- xfa/fxgraphics/cagg_graphics.cpp | 2 +- xfa/fxgraphics/cfx_graphics.cpp | 2 +- 8 files changed, 51 insertions(+), 42 deletions(-) (limited to 'xfa') diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index 3e14b9bf38..c7d82ac0f4 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -125,12 +125,13 @@ void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) { ASSERT(fLineSpace > 1.0f); m_fLineSpace = fLineSpace; } + void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) { ASSERT(pDIB); m_pRenderDevice.reset(); CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Attach(pDIB, 0, FALSE); + device->Attach(pDIB, false, nullptr, false); m_pRenderDevice.reset(new CFDE_RenderDevice(device, FALSE)); } diff --git a/xfa/fwl/theme/cfwl_formtp.cpp b/xfa/fwl/theme/cfwl_formtp.cpp index 75244373d4..971e738765 100644 --- a/xfa/fwl/theme/cfwl_formtp.cpp +++ b/xfa/fwl/theme/cfwl_formtp.cpp @@ -844,7 +844,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { delete m_pActiveBitmap; m_pActiveBitmap = new CFX_DIBitmap; m_pActiveBitmap->Create(1, kCYCaption, FXDIB_Argb); - dev.Attach(m_pActiveBitmap); + dev.Attach(m_pActiveBitmap, false, nullptr, false); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], @@ -865,7 +865,7 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) { delete m_pDeactivebitmap; m_pDeactivebitmap = new CFX_DIBitmap; m_pDeactivebitmap->Create(1, kCYCaption, FXDIB_Argb); - dev.Attach(m_pDeactivebitmap); + dev.Attach(m_pDeactivebitmap, false, nullptr, false); gs.Create(&dev); path.AddRectangle(0, 0, 1, 5); DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index ae1b237957..7b1cc50d72 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -201,6 +201,7 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); } + void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, const CFX_ByteString str, FX_FLOAT geWidth, @@ -211,7 +212,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_FxgeDevice ge; - ge.Create((int)geWidth, iTextHeight, m_colorSpace); + ge.Create((int)geWidth, iTextHeight, m_colorSpace, nullptr); FX_RECT geRect(0, 0, (int)geWidth, iTextHeight); ge.FillRect(&geRect, m_backgroundColor); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); @@ -219,9 +220,10 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, (CFX_Matrix*)&affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); CFX_FxgeDevice geBitmap; - geBitmap.Attach(pOutBitmap); + geBitmap.Attach(pOutBitmap, false, nullptr, false); geBitmap.SetDIBits(ge.GetBitmap(), (int)locX, (int)locY); } + void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -229,11 +231,11 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } - if (m_pFont == NULL) { + if (!m_pFont) { e = BCExceptionNullPointer; return; } diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index bdc5e1f2c7..20b52774e8 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -153,6 +153,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, } return result; } + void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -160,7 +161,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } @@ -171,14 +172,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_ByteString tempStr = str.Mid(1, 6); int32_t strWidth = multiple * 42; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -208,7 +209,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } FX_FLOAT blank = 0.0; iLen = tempStr.GetLength(); - if (pOutBitmap == NULL) { + if (!pOutBitmap) { strWidth = (int32_t)(strWidth * m_outputHScale); } CalcTextInfo(tempStr, pCharPos + 1, m_pFont, (FX_FLOAT)strWidth, iFontSize, @@ -216,7 +217,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); FX_RECT rect(0, 0, strWidth, iTextHeight); ge.FillRect(&rect, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, @@ -265,14 +266,14 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = multiple * 7; - if (pOutBitmap == NULL) { + if (!pOutBitmap) strWidth = (int32_t)(strWidth * m_outputHScale); - } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -292,6 +293,7 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedEAN13Writer::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 4427cb8970..2aa57d18d1 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -158,6 +158,7 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, } return result; } + void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -165,10 +166,11 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } + int32_t leftPosition = 3 * multiple; CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLength = str.GetLength(); @@ -179,12 +181,12 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, int32_t strWidth = 7 * multiple * 4; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -204,16 +206,16 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, re = rect1.GetOutterRect(); device->FillRect(&re, m_backgroundColor); } - if (pOutBitmap == NULL) { + if (!pOutBitmap) strWidth = (int32_t)(strWidth * m_outputHScale); - } + CalcTextInfo(tempStr, pCharPos, m_pFont, (FX_FLOAT)strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -236,7 +238,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create(strWidth, iTextHeight, FXDIB_Argb); + ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -259,6 +261,7 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 943384d55c..f7900d4195 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -36,18 +36,16 @@ void CBC_OnedUPCAWriter::Init() { CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() { delete m_subWriter; } + FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity( const CFX_WideStringC& contents) { - int32_t i = 0; - for (i = 0; i < contents.GetLength(); i++) { - if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { - continue; - } else { + for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) { + if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9') return FALSE; - } } return TRUE; } + CFX_WideString CBC_OnedUPCAWriter::FilterContents( const CFX_WideStringC& contents) { CFX_WideString filtercontents; @@ -106,6 +104,7 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, BC_EXCEPTION_CHECK_ReturnValue(e, NULL); return ret; } + void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, @@ -113,10 +112,11 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, int32_t barWidth, int32_t multiple, int32_t& e) { - if (device == NULL && pOutBitmap == NULL) { + if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } + int32_t leftPadding = 7 * multiple; int32_t leftPosition = 10 * multiple + leftPadding; CFX_ByteString str = FX_UTF8Encode(contents); @@ -127,13 +127,13 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; - if (pOutBitmap) { - geBitmap.Attach(pOutBitmap); - } + if (pOutBitmap) + geBitmap.Attach(pOutBitmap, false, nullptr, false); + iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; - if (pOutBitmap == NULL) { + if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), @@ -178,7 +178,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -231,7 +231,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -254,7 +254,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); - ge.Create((int)strWidth, iTextHeight, FXDIB_Argb); + ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, @@ -277,6 +277,7 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, } FX_Free(pCharPos); } + void CBC_OnedUPCAWriter::RenderResult(const CFX_WideStringC& contents, uint8_t* code, int32_t codeLength, diff --git a/xfa/fxgraphics/cagg_graphics.cpp b/xfa/fxgraphics/cagg_graphics.cpp index 564a2b14cc..5d1f563613 100644 --- a/xfa/fxgraphics/cagg_graphics.cpp +++ b/xfa/fxgraphics/cagg_graphics.cpp @@ -18,7 +18,7 @@ FWL_Error CAGG_Graphics::Create(CFX_Graphics* owner, return FWL_Error::PropertyInvalid; CFX_FxgeDevice* device = new CFX_FxgeDevice; - device->Create(width, height, format); + device->Create(width, height, format, nullptr); m_owner = owner; m_owner->m_renderDevice = device; m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF); diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 8de0def44f..755bc1eff1 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -1343,7 +1343,7 @@ FWL_Error CFX_Graphics::FillPathWithPattern(CFX_Path* path, FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); CFX_FxgeDevice device; - device.Attach(&bmp); + device.Attach(&bmp, false, nullptr, false); device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb); for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { -- cgit v1.2.3