From f0799fe84df4d86f25d342b03525f3016d674f86 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 28 Mar 2017 09:31:32 -0700 Subject: Revert "Revert "Refcount all CFX_DIBSources (and subclasses) all the time."" This reverts commit 31b08d4cdaa17d7a03f35e087096a77036af98ec. Re-landing the patch after fixing skia build issue. Change-Id: Ie7039890088b803a6ec5ce365d70f57277459b48 Reviewed-on: https://pdfium-review.googlesource.com/3245 Commit-Queue: Tom Sepez Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fxbarcode/BC_TwoDimWriter.cpp | 13 +++++------- xfa/fxbarcode/BC_TwoDimWriter.h | 4 ++-- xfa/fxbarcode/BC_Writer.cpp | 6 ++++-- xfa/fxbarcode/BC_Writer.h | 2 +- xfa/fxbarcode/cbc_codabar.cpp | 3 ++- xfa/fxbarcode/cbc_codabar.h | 3 ++- xfa/fxbarcode/cbc_code128.cpp | 7 +++---- xfa/fxbarcode/cbc_code128.h | 3 ++- xfa/fxbarcode/cbc_code39.cpp | 7 +++---- xfa/fxbarcode/cbc_code39.h | 3 ++- xfa/fxbarcode/cbc_codebase.h | 3 ++- xfa/fxbarcode/cbc_datamatrix.cpp | 7 +++---- xfa/fxbarcode/cbc_datamatrix.h | 3 ++- xfa/fxbarcode/cbc_ean13.cpp | 7 +++---- xfa/fxbarcode/cbc_ean13.h | 3 ++- xfa/fxbarcode/cbc_ean8.cpp | 7 +++---- xfa/fxbarcode/cbc_ean8.h | 3 ++- xfa/fxbarcode/cbc_pdf417i.cpp | 7 +++---- xfa/fxbarcode/cbc_pdf417i.h | 3 ++- xfa/fxbarcode/cbc_qrcode.cpp | 7 +++---- xfa/fxbarcode/cbc_qrcode.h | 3 ++- xfa/fxbarcode/cbc_upca.cpp | 7 +++---- xfa/fxbarcode/cbc_upca.h | 3 ++- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 35 +++++++++++++++---------------- xfa/fxbarcode/oned/BC_OneDimWriter.h | 6 +++--- xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp | 16 +++++++------- xfa/fxbarcode/oned/BC_OnedEAN13Writer.h | 2 +- xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp | 17 +++++++-------- xfa/fxbarcode/oned/BC_OnedEAN8Writer.h | 2 +- xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp | 17 +++++++-------- xfa/fxbarcode/oned/BC_OnedUPCAWriter.h | 2 +- 31 files changed, 105 insertions(+), 106 deletions(-) (limited to 'xfa/fxbarcode') diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index 328352c6c1..9c9427aaa5 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -57,8 +57,9 @@ int32_t CBC_TwoDimWriter::GetErrorCorrectionLevel() const { return m_iCorrectLevel; } -void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, - int32_t& e) { +void CBC_TwoDimWriter::RenderBitmapResult( + CFX_RetainPtr& pOutBitmap, + int32_t& e) { if (m_bFixedSize) { pOutBitmap = CreateDIBitmap(m_Width, m_Height); } else { @@ -82,12 +83,8 @@ void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, } } } - if (!m_bFixedSize) { - std::unique_ptr pStretchBitmap = - pOutBitmap->StretchTo(m_Width, m_Height); - delete pOutBitmap; - pOutBitmap = pStretchBitmap.release(); - } + if (!m_bFixedSize) + pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); } void CBC_TwoDimWriter::RenderResult(uint8_t* code, diff --git a/xfa/fxbarcode/BC_TwoDimWriter.h b/xfa/fxbarcode/BC_TwoDimWriter.h index ad4658b008..c6e0495aec 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.h +++ b/xfa/fxbarcode/BC_TwoDimWriter.h @@ -23,11 +23,11 @@ class CBC_TwoDimWriter : public CBC_Writer { int32_t codeWidth, int32_t codeHeight, int32_t& e); - virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, int32_t& e); + virtual void RenderBitmapResult(CFX_RetainPtr& pOutBitmap, + int32_t& e); virtual void RenderDeviceResult(CFX_RenderDevice* device, const CFX_Matrix* matrix); virtual bool SetErrorCorrectionLevel(int32_t level) = 0; - int32_t GetErrorCorrectionLevel() const; protected: diff --git a/xfa/fxbarcode/BC_Writer.cpp b/xfa/fxbarcode/BC_Writer.cpp index 73163522cb..69f34148f4 100644 --- a/xfa/fxbarcode/BC_Writer.cpp +++ b/xfa/fxbarcode/BC_Writer.cpp @@ -49,8 +49,10 @@ void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) { void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { m_barColor = foregroundColor; } -CFX_DIBitmap* CBC_Writer::CreateDIBitmap(int32_t width, int32_t height) { - CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; + +CFX_RetainPtr CBC_Writer::CreateDIBitmap(int32_t width, + int32_t height) { + auto pDIBitmap = pdfium::MakeRetain(); pDIBitmap->Create(width, height, m_colorSpace); return pDIBitmap; } diff --git a/xfa/fxbarcode/BC_Writer.h b/xfa/fxbarcode/BC_Writer.h index 90ea06a397..8dd03ead58 100644 --- a/xfa/fxbarcode/BC_Writer.h +++ b/xfa/fxbarcode/BC_Writer.h @@ -24,7 +24,7 @@ class CBC_Writer { virtual void SetBarcodeColor(FX_ARGB foregroundColor); protected: - CFX_DIBitmap* CreateDIBitmap(int32_t width, int32_t height); + CFX_RetainPtr CreateDIBitmap(int32_t width, int32_t height); int32_t m_CharEncoding; int32_t m_ModuleHeight; int32_t m_ModuleWidth; diff --git a/xfa/fxbarcode/cbc_codabar.cpp b/xfa/fxbarcode/cbc_codabar.cpp index 53e351d5a2..c49fe95948 100644 --- a/xfa/fxbarcode/cbc_codabar.cpp +++ b/xfa/fxbarcode/cbc_codabar.cpp @@ -93,7 +93,8 @@ bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_Codabar::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { CFX_WideString renderCon = static_cast(m_pBCWriter.get()) ->encodedContents(m_renderContents.AsStringC()); diff --git a/xfa/fxbarcode/cbc_codabar.h b/xfa/fxbarcode/cbc_codabar.h index 43f1a010c0..f00c295f44 100644 --- a/xfa/fxbarcode/cbc_codabar.h +++ b/xfa/fxbarcode/cbc_codabar.h @@ -24,7 +24,8 @@ class CBC_Codabar : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; bool SetStartChar(char start); diff --git a/xfa/fxbarcode/cbc_code128.cpp b/xfa/fxbarcode/cbc_code128.cpp index 35bd136fd0..ea0bc56fce 100644 --- a/xfa/fxbarcode/cbc_code128.cpp +++ b/xfa/fxbarcode/cbc_code128.cpp @@ -78,12 +78,11 @@ bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_Code128::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_Code128::GetType() { diff --git a/xfa/fxbarcode/cbc_code128.h b/xfa/fxbarcode/cbc_code128.h index 0dd9c84f68..d8505760a6 100644 --- a/xfa/fxbarcode/cbc_code128.h +++ b/xfa/fxbarcode/cbc_code128.h @@ -24,7 +24,8 @@ class CBC_Code128 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; bool SetTextLocation(BC_TEXT_LOC loction); diff --git a/xfa/fxbarcode/cbc_code39.cpp b/xfa/fxbarcode/cbc_code39.cpp index af45ad4063..e3cfccbd90 100644 --- a/xfa/fxbarcode/cbc_code39.cpp +++ b/xfa/fxbarcode/cbc_code39.cpp @@ -70,15 +70,14 @@ bool CBC_Code39::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_Code39::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { CFX_WideString renderCon = static_cast(m_pBCWriter.get()) ->encodedContents(m_renderContents.AsStringC(), e); static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_Code39::GetType() { diff --git a/xfa/fxbarcode/cbc_code39.h b/xfa/fxbarcode/cbc_code39.h index 7f5c627c6c..0320211631 100644 --- a/xfa/fxbarcode/cbc_code39.h +++ b/xfa/fxbarcode/cbc_code39.h @@ -24,7 +24,8 @@ class CBC_Code39 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; bool SetTextLocation(BC_TEXT_LOC location); diff --git a/xfa/fxbarcode/cbc_codebase.h b/xfa/fxbarcode/cbc_codebase.h index c28c08b7e7..37a65d2cf6 100644 --- a/xfa/fxbarcode/cbc_codebase.h +++ b/xfa/fxbarcode/cbc_codebase.h @@ -30,7 +30,8 @@ class CBC_CodeBase { virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) = 0; - virtual bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) = 0; + virtual bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) = 0; bool SetCharEncoding(int32_t encoding); bool SetModuleHeight(int32_t moduleHeight); diff --git a/xfa/fxbarcode/cbc_datamatrix.cpp b/xfa/fxbarcode/cbc_datamatrix.cpp index 6122368e84..ebfa8b9901 100644 --- a/xfa/fxbarcode/cbc_datamatrix.cpp +++ b/xfa/fxbarcode/cbc_datamatrix.cpp @@ -53,12 +53,11 @@ bool CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_DataMatrix::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_DataMatrix::GetType() { diff --git a/xfa/fxbarcode/cbc_datamatrix.h b/xfa/fxbarcode/cbc_datamatrix.h index 661b48d744..ebca372f3f 100644 --- a/xfa/fxbarcode/cbc_datamatrix.h +++ b/xfa/fxbarcode/cbc_datamatrix.h @@ -24,7 +24,8 @@ class CBC_DataMatrix : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; }; diff --git a/xfa/fxbarcode/cbc_ean13.cpp b/xfa/fxbarcode/cbc_ean13.cpp index abd5f198a3..afe52db9dd 100644 --- a/xfa/fxbarcode/cbc_ean13.cpp +++ b/xfa/fxbarcode/cbc_ean13.cpp @@ -83,12 +83,11 @@ bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN13::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_EAN13::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_EAN13::GetType() { diff --git a/xfa/fxbarcode/cbc_ean13.h b/xfa/fxbarcode/cbc_ean13.h index f0e7940a04..5f23855ead 100644 --- a/xfa/fxbarcode/cbc_ean13.h +++ b/xfa/fxbarcode/cbc_ean13.h @@ -24,7 +24,8 @@ class CBC_EAN13 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/xfa/fxbarcode/cbc_ean8.cpp b/xfa/fxbarcode/cbc_ean8.cpp index bfb458521e..408b43a608 100644 --- a/xfa/fxbarcode/cbc_ean8.cpp +++ b/xfa/fxbarcode/cbc_ean8.cpp @@ -82,12 +82,11 @@ bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_EAN8::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_EAN8::GetType() { diff --git a/xfa/fxbarcode/cbc_ean8.h b/xfa/fxbarcode/cbc_ean8.h index 6a475cb795..478a67405c 100644 --- a/xfa/fxbarcode/cbc_ean8.h +++ b/xfa/fxbarcode/cbc_ean8.h @@ -24,7 +24,8 @@ class CBC_EAN8 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/xfa/fxbarcode/cbc_pdf417i.cpp b/xfa/fxbarcode/cbc_pdf417i.cpp index 1c5547d445..a5e210757a 100644 --- a/xfa/fxbarcode/cbc_pdf417i.cpp +++ b/xfa/fxbarcode/cbc_pdf417i.cpp @@ -63,12 +63,11 @@ bool CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_PDF417I::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_PDF417I::GetType() { diff --git a/xfa/fxbarcode/cbc_pdf417i.h b/xfa/fxbarcode/cbc_pdf417i.h index 70ea929820..c26dceeebd 100644 --- a/xfa/fxbarcode/cbc_pdf417i.h +++ b/xfa/fxbarcode/cbc_pdf417i.h @@ -24,7 +24,8 @@ class CBC_PDF417I : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; bool SetErrorCorrectionLevel(int32_t level); diff --git a/xfa/fxbarcode/cbc_qrcode.cpp b/xfa/fxbarcode/cbc_qrcode.cpp index 26b74ca400..e046857b6b 100644 --- a/xfa/fxbarcode/cbc_qrcode.cpp +++ b/xfa/fxbarcode/cbc_qrcode.cpp @@ -69,12 +69,11 @@ bool CBC_QRCode::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_QRCode::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_QRCode::GetType() { diff --git a/xfa/fxbarcode/cbc_qrcode.h b/xfa/fxbarcode/cbc_qrcode.h index ac2d93d915..05f3f6c415 100644 --- a/xfa/fxbarcode/cbc_qrcode.h +++ b/xfa/fxbarcode/cbc_qrcode.h @@ -24,7 +24,8 @@ class CBC_QRCode : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; bool SetVersion(int32_t version); diff --git a/xfa/fxbarcode/cbc_upca.cpp b/xfa/fxbarcode/cbc_upca.cpp index 87f58093ae..915a6aead5 100644 --- a/xfa/fxbarcode/cbc_upca.cpp +++ b/xfa/fxbarcode/cbc_upca.cpp @@ -86,12 +86,11 @@ bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_UPCA::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { +bool CBC_UPCA::RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - if (e != BCExceptionNO) - return false; - return true; + return e == BCExceptionNO; } BC_TYPE CBC_UPCA::GetType() { diff --git a/xfa/fxbarcode/cbc_upca.h b/xfa/fxbarcode/cbc_upca.h index bf90b922b5..4015a3143d 100644 --- a/xfa/fxbarcode/cbc_upca.h +++ b/xfa/fxbarcode/cbc_upca.h @@ -24,7 +24,8 @@ class CBC_UPCA : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; + bool RenderBitmap(CFX_RetainPtr& pOutBitmap, + int32_t& e) override; BC_TYPE GetType() override; private: diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 02ae58dc84..16eba2df10 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -224,13 +224,14 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, m_fontColor, FXTEXT_CLEARTYPE); } -void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, - const CFX_ByteString str, - float geWidth, - FXTEXT_CHARPOS* pCharPos, - float locX, - float locY, - int32_t barWidth) { +void CBC_OneDimWriter::ShowBitmapChars( + const CFX_RetainPtr& pOutBitmap, + const CFX_ByteString str, + float geWidth, + FXTEXT_CHARPOS* pCharPos, + float locX, + float locY, + int32_t barWidth) { int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; CFX_FxgeDevice ge; @@ -248,7 +249,7 @@ void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* pOutBitmap, } void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, + const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, @@ -316,9 +317,10 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, FX_Free(pCharPos); } -void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e) { +void CBC_OneDimWriter::RenderBitmapResult( + CFX_RetainPtr& pOutBitmap, + const CFX_WideStringC& contents, + int32_t& e) { if (!m_output) if (e != BCExceptionNO) return; @@ -337,20 +339,17 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, } } int32_t i = 0; - for (; i < contents.GetLength(); i++) - if (contents.GetAt(i) != ' ') { + for (; i < contents.GetLength(); i++) { + if (contents.GetAt(i) != ' ') break; - } + } if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) { ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple, e); if (e != BCExceptionNO) return; } - std::unique_ptr pStretchBitmap = - pOutBitmap->StretchTo(m_Width, m_Height); - delete pOutBitmap; - pOutBitmap = pStretchBitmap.release(); + pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); } void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h index b2447cffb7..4892889ddb 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.h +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.h @@ -42,7 +42,7 @@ class CBC_OneDimWriter : public CBC_Writer { int32_t codeLength, bool isDevice, int32_t& e); - virtual void RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + virtual void RenderBitmapResult(CFX_RetainPtr& pOutBitmap, const CFX_WideStringC& contents, int32_t& e); virtual void RenderDeviceResult(CFX_RenderDevice* device, @@ -68,13 +68,13 @@ class CBC_OneDimWriter : public CBC_Writer { int32_t fontSize, float& charsLen); virtual void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, + const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e); - virtual void ShowBitmapChars(CFX_DIBitmap* pOutBitmap, + virtual void ShowBitmapChars(const CFX_RetainPtr& pOutBitmap, const CFX_ByteString str, float geWidth, FXTEXT_CHARPOS* pCharPos, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 555b58643d..dcea777089 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -167,13 +167,14 @@ 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, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { +void CBC_OnedEAN13Writer::ShowChars( + const CFX_WideStringC& contents, + const CFX_RetainPtr& pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -278,7 +279,6 @@ void CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos, m_pFont, (float)strWidth, iFontSize, blank); if (pOutBitmap) { - delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), diff --git a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h index 5775f89046..8336259568 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.h @@ -46,7 +46,7 @@ class CBC_OnedEAN13Writer : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, + const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 5f571c2a30..a7fa30c811 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -165,13 +165,14 @@ 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, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { +void CBC_OnedEAN8Writer::ShowChars( + const CFX_WideStringC& contents, + const CFX_RetainPtr& pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -217,7 +218,6 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (float)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { - delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), @@ -237,7 +237,6 @@ void CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, CalcTextInfo(tempStr, pCharPos + 4, m_pFont, (float)strWidth, iFontSize, blank); if (pOutBitmap) { - delete ge.GetBitmap(); ge.Create(strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 4, m_pFont, diff --git a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h index 844fc33afa..b9921babc3 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.h @@ -50,7 +50,7 @@ class CBC_OnedEAN8Writer : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, + const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp index cefae97d8d..540e852d5d 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -117,13 +117,14 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, return nullptr; } -void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, - CFX_RenderDevice* device, - const CFX_Matrix* matrix, - int32_t barWidth, - int32_t multiple, - int32_t& e) { +void CBC_OnedUPCAWriter::ShowChars( + const CFX_WideStringC& contents, + const CFX_RetainPtr& pOutBitmap, + CFX_RenderDevice* device, + const CFX_Matrix* matrix, + int32_t barWidth, + int32_t multiple, + int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -235,7 +236,6 @@ 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, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, static_cast(iFontSize), @@ -255,7 +255,6 @@ void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { - delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h index 6b786ce3b8..6c0929a051 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.h @@ -52,7 +52,7 @@ class CBC_OnedUPCAWriter : public CBC_OneDimWriter { protected: void ShowChars(const CFX_WideStringC& contents, - CFX_DIBitmap* pOutBitmap, + const CFX_RetainPtr& pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, -- cgit v1.2.3