From 31b08d4cdaa17d7a03f35e087096a77036af98ec Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 28 Mar 2017 15:47:47 +0000 Subject: Revert "Refcount all CFX_DIBSources (and subclasses) all the time." This reverts commit 0004f29bf6ee3c6060a272c79f14993e92e053c7. Reason for revert: Breaks build with skia_paths enabled (which will break the chrome roll). ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1858:38: error: no member named 'get' in 'CFX_RetainPtr' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:1861:42: error: no member named 'get' in 'CFX_RetainPtr' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2987:15: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2991:18: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:2999:17: error: no viable overloaded '=' ../../third_party/pdfium/core/fxge/skia/fx_skia_device.cpp:3001:43: error: no member named 'GetObject' in 'CFX_RetainPtr' Original change's description: > Refcount all CFX_DIBSources (and subclasses) all the time. > > There are currently several ownership models for these objects, > including ad-hoc logic for sharing and deletion, and the > now-redundant CFX_DIBitmapRef externally-counted handle to the DIBs. > > Replace them all with the internal refcount scheme. > > Change-Id: I2db399dfc19219eda384f94cc989353b78ce2872 > Reviewed-on: https://pdfium-review.googlesource.com/3166 > Reviewed-by: dsinclair > Commit-Queue: dsinclair > TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I678b1fbc5e666cf7a19372ebaff3270fb115ba5e Reviewed-on: https://pdfium-review.googlesource.com/3243 Reviewed-by: dsinclair Commit-Queue: 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, 106 insertions(+), 105 deletions(-) (limited to 'xfa/fxbarcode') diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp index 9c9427aaa5..328352c6c1 100644 --- a/xfa/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp @@ -57,9 +57,8 @@ int32_t CBC_TwoDimWriter::GetErrorCorrectionLevel() const { return m_iCorrectLevel; } -void CBC_TwoDimWriter::RenderBitmapResult( - CFX_RetainPtr& pOutBitmap, - int32_t& e) { +void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + int32_t& e) { if (m_bFixedSize) { pOutBitmap = CreateDIBitmap(m_Width, m_Height); } else { @@ -83,8 +82,12 @@ void CBC_TwoDimWriter::RenderBitmapResult( } } } - if (!m_bFixedSize) - pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); + if (!m_bFixedSize) { + std::unique_ptr pStretchBitmap = + pOutBitmap->StretchTo(m_Width, m_Height); + delete pOutBitmap; + pOutBitmap = pStretchBitmap.release(); + } } void CBC_TwoDimWriter::RenderResult(uint8_t* code, diff --git a/xfa/fxbarcode/BC_TwoDimWriter.h b/xfa/fxbarcode/BC_TwoDimWriter.h index c6e0495aec..ad4658b008 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_RetainPtr& pOutBitmap, - int32_t& e); + virtual void RenderBitmapResult(CFX_DIBitmap*& 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 69f34148f4..73163522cb 100644 --- a/xfa/fxbarcode/BC_Writer.cpp +++ b/xfa/fxbarcode/BC_Writer.cpp @@ -49,10 +49,8 @@ void CBC_Writer::SetBackgroundColor(FX_ARGB backgroundColor) { void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { m_barColor = foregroundColor; } - -CFX_RetainPtr CBC_Writer::CreateDIBitmap(int32_t width, - int32_t height) { - auto pDIBitmap = pdfium::MakeRetain(); +CFX_DIBitmap* CBC_Writer::CreateDIBitmap(int32_t width, int32_t height) { + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; pDIBitmap->Create(width, height, m_colorSpace); return pDIBitmap; } diff --git a/xfa/fxbarcode/BC_Writer.h b/xfa/fxbarcode/BC_Writer.h index 8dd03ead58..90ea06a397 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_RetainPtr CreateDIBitmap(int32_t width, int32_t height); + CFX_DIBitmap* 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 c49fe95948..53e351d5a2 100644 --- a/xfa/fxbarcode/cbc_codabar.cpp +++ b/xfa/fxbarcode/cbc_codabar.cpp @@ -93,8 +93,7 @@ bool CBC_Codabar::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Codabar::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_Codabar::RenderBitmap(CFX_DIBitmap*& 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 f00c295f44..43f1a010c0 100644 --- a/xfa/fxbarcode/cbc_codabar.h +++ b/xfa/fxbarcode/cbc_codabar.h @@ -24,8 +24,7 @@ class CBC_Codabar : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 ea0bc56fce..35bd136fd0 100644 --- a/xfa/fxbarcode/cbc_code128.cpp +++ b/xfa/fxbarcode/cbc_code128.cpp @@ -78,11 +78,12 @@ bool CBC_Code128::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code128::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_Code128::GetType() { diff --git a/xfa/fxbarcode/cbc_code128.h b/xfa/fxbarcode/cbc_code128.h index d8505760a6..0dd9c84f68 100644 --- a/xfa/fxbarcode/cbc_code128.h +++ b/xfa/fxbarcode/cbc_code128.h @@ -24,8 +24,7 @@ class CBC_Code128 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 e3cfccbd90..af45ad4063 100644 --- a/xfa/fxbarcode/cbc_code39.cpp +++ b/xfa/fxbarcode/cbc_code39.cpp @@ -70,14 +70,15 @@ bool CBC_Code39::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_Code39::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_Code39::RenderBitmap(CFX_DIBitmap*& 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); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_Code39::GetType() { diff --git a/xfa/fxbarcode/cbc_code39.h b/xfa/fxbarcode/cbc_code39.h index 0320211631..7f5c627c6c 100644 --- a/xfa/fxbarcode/cbc_code39.h +++ b/xfa/fxbarcode/cbc_code39.h @@ -24,8 +24,7 @@ class CBC_Code39 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 37a65d2cf6..c28c08b7e7 100644 --- a/xfa/fxbarcode/cbc_codebase.h +++ b/xfa/fxbarcode/cbc_codebase.h @@ -30,8 +30,7 @@ class CBC_CodeBase { virtual bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) = 0; - virtual bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) = 0; + virtual bool RenderBitmap(CFX_DIBitmap*& 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 ebfa8b9901..6122368e84 100644 --- a/xfa/fxbarcode/cbc_datamatrix.cpp +++ b/xfa/fxbarcode/cbc_datamatrix.cpp @@ -53,11 +53,12 @@ bool CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_DataMatrix::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_DataMatrix::GetType() { diff --git a/xfa/fxbarcode/cbc_datamatrix.h b/xfa/fxbarcode/cbc_datamatrix.h index ebca372f3f..661b48d744 100644 --- a/xfa/fxbarcode/cbc_datamatrix.h +++ b/xfa/fxbarcode/cbc_datamatrix.h @@ -24,8 +24,7 @@ class CBC_DataMatrix : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override; BC_TYPE GetType() override; }; diff --git a/xfa/fxbarcode/cbc_ean13.cpp b/xfa/fxbarcode/cbc_ean13.cpp index afe52db9dd..abd5f198a3 100644 --- a/xfa/fxbarcode/cbc_ean13.cpp +++ b/xfa/fxbarcode/cbc_ean13.cpp @@ -83,11 +83,12 @@ bool CBC_EAN13::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN13::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_EAN13::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_EAN13::GetType() { diff --git a/xfa/fxbarcode/cbc_ean13.h b/xfa/fxbarcode/cbc_ean13.h index 5f23855ead..f0e7940a04 100644 --- a/xfa/fxbarcode/cbc_ean13.h +++ b/xfa/fxbarcode/cbc_ean13.h @@ -24,8 +24,7 @@ class CBC_EAN13 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 408b43a608..bfb458521e 100644 --- a/xfa/fxbarcode/cbc_ean8.cpp +++ b/xfa/fxbarcode/cbc_ean8.cpp @@ -82,11 +82,12 @@ bool CBC_EAN8::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_EAN8::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_EAN8::GetType() { diff --git a/xfa/fxbarcode/cbc_ean8.h b/xfa/fxbarcode/cbc_ean8.h index 478a67405c..6a475cb795 100644 --- a/xfa/fxbarcode/cbc_ean8.h +++ b/xfa/fxbarcode/cbc_ean8.h @@ -24,8 +24,7 @@ class CBC_EAN8 : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 a5e210757a..1c5547d445 100644 --- a/xfa/fxbarcode/cbc_pdf417i.cpp +++ b/xfa/fxbarcode/cbc_pdf417i.cpp @@ -63,11 +63,12 @@ bool CBC_PDF417I::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_PDF417I::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_PDF417I::GetType() { diff --git a/xfa/fxbarcode/cbc_pdf417i.h b/xfa/fxbarcode/cbc_pdf417i.h index c26dceeebd..70ea929820 100644 --- a/xfa/fxbarcode/cbc_pdf417i.h +++ b/xfa/fxbarcode/cbc_pdf417i.h @@ -24,8 +24,7 @@ class CBC_PDF417I : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 e046857b6b..26b74ca400 100644 --- a/xfa/fxbarcode/cbc_qrcode.cpp +++ b/xfa/fxbarcode/cbc_qrcode.cpp @@ -69,11 +69,12 @@ bool CBC_QRCode::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_QRCode::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_QRCode::GetType() { diff --git a/xfa/fxbarcode/cbc_qrcode.h b/xfa/fxbarcode/cbc_qrcode.h index 05f3f6c415..ac2d93d915 100644 --- a/xfa/fxbarcode/cbc_qrcode.h +++ b/xfa/fxbarcode/cbc_qrcode.h @@ -24,8 +24,7 @@ class CBC_QRCode : public CBC_CodeBase { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 915a6aead5..87f58093ae 100644 --- a/xfa/fxbarcode/cbc_upca.cpp +++ b/xfa/fxbarcode/cbc_upca.cpp @@ -86,11 +86,12 @@ bool CBC_UPCA::RenderDevice(CFX_RenderDevice* device, return true; } -bool CBC_UPCA::RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) { +bool CBC_UPCA::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { static_cast(m_pBCWriter.get()) ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e); - return e == BCExceptionNO; + if (e != BCExceptionNO) + return false; + return true; } BC_TYPE CBC_UPCA::GetType() { diff --git a/xfa/fxbarcode/cbc_upca.h b/xfa/fxbarcode/cbc_upca.h index 4015a3143d..bf90b922b5 100644 --- a/xfa/fxbarcode/cbc_upca.h +++ b/xfa/fxbarcode/cbc_upca.h @@ -24,8 +24,7 @@ class CBC_UPCA : public CBC_OneCode { bool RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t& e) override; - bool RenderBitmap(CFX_RetainPtr& pOutBitmap, - int32_t& e) override; + bool RenderBitmap(CFX_DIBitmap*& 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 16eba2df10..02ae58dc84 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -224,14 +224,13 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, m_fontColor, FXTEXT_CLEARTYPE); } -void CBC_OneDimWriter::ShowBitmapChars( - const CFX_RetainPtr& pOutBitmap, - const CFX_ByteString str, - float geWidth, - FXTEXT_CHARPOS* pCharPos, - float locX, - float locY, - int32_t barWidth) { +void CBC_OneDimWriter::ShowBitmapChars(CFX_DIBitmap* 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; @@ -249,7 +248,7 @@ void CBC_OneDimWriter::ShowBitmapChars( } void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, - const CFX_RetainPtr& pOutBitmap, + CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, @@ -317,10 +316,9 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents, FX_Free(pCharPos); } -void CBC_OneDimWriter::RenderBitmapResult( - CFX_RetainPtr& pOutBitmap, - const CFX_WideStringC& contents, - int32_t& e) { +void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap, + const CFX_WideStringC& contents, + int32_t& e) { if (!m_output) if (e != BCExceptionNO) return; @@ -339,17 +337,20 @@ void CBC_OneDimWriter::RenderBitmapResult( } } 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; } - pOutBitmap = pOutBitmap->StretchTo(m_Width, m_Height); + std::unique_ptr pStretchBitmap = + pOutBitmap->StretchTo(m_Width, m_Height); + delete pOutBitmap; + pOutBitmap = pStretchBitmap.release(); } void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device, diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.h b/xfa/fxbarcode/oned/BC_OneDimWriter.h index 4892889ddb..b2447cffb7 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_RetainPtr& pOutBitmap, + virtual void RenderBitmapResult(CFX_DIBitmap*& 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, - const CFX_RetainPtr& pOutBitmap, + CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e); - virtual void ShowBitmapChars(const CFX_RetainPtr& pOutBitmap, + virtual void ShowBitmapChars(CFX_DIBitmap* 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 dcea777089..555b58643d 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -167,14 +167,13 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents, return result; } -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) { +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) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -279,6 +278,7 @@ void CBC_OnedEAN13Writer::ShowChars( 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 8336259568..5775f89046 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, - const CFX_RetainPtr& pOutBitmap, + CFX_DIBitmap* 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 a7fa30c811..5f571c2a30 100644 --- a/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -165,14 +165,13 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, return result; } -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) { +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) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -218,6 +217,7 @@ void CBC_OnedEAN8Writer::ShowChars( 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,6 +237,7 @@ void CBC_OnedEAN8Writer::ShowChars( 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 b9921babc3..844fc33afa 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, - const CFX_RetainPtr& pOutBitmap, + CFX_DIBitmap* 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 540e852d5d..cefae97d8d 100644 --- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -117,14 +117,13 @@ uint8_t* CBC_OnedUPCAWriter::Encode(const CFX_ByteString& contents, return nullptr; } -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) { +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) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; @@ -236,6 +235,7 @@ void CBC_OnedUPCAWriter::ShowChars( 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,6 +255,7 @@ void CBC_OnedUPCAWriter::ShowChars( 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 6c0929a051..6b786ce3b8 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, - const CFX_RetainPtr& pOutBitmap, + CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, -- cgit v1.2.3