summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/fde_gedevice.cpp2
-rw-r--r--xfa/fde/fde_gedevice.h2
-rw-r--r--xfa/fde/tto/fde_textout.cpp2
-rw-r--r--xfa/fde/tto/fde_textout.h2
-rw-r--r--xfa/fwl/cfwl_themebackground.h11
-rw-r--r--xfa/fxbarcode/BC_TwoDimWriter.cpp13
-rw-r--r--xfa/fxbarcode/BC_TwoDimWriter.h4
-rw-r--r--xfa/fxbarcode/BC_Writer.cpp6
-rw-r--r--xfa/fxbarcode/BC_Writer.h2
-rw-r--r--xfa/fxbarcode/cbc_codabar.cpp3
-rw-r--r--xfa/fxbarcode/cbc_codabar.h3
-rw-r--r--xfa/fxbarcode/cbc_code128.cpp7
-rw-r--r--xfa/fxbarcode/cbc_code128.h3
-rw-r--r--xfa/fxbarcode/cbc_code39.cpp7
-rw-r--r--xfa/fxbarcode/cbc_code39.h3
-rw-r--r--xfa/fxbarcode/cbc_codebase.h3
-rw-r--r--xfa/fxbarcode/cbc_datamatrix.cpp7
-rw-r--r--xfa/fxbarcode/cbc_datamatrix.h3
-rw-r--r--xfa/fxbarcode/cbc_ean13.cpp7
-rw-r--r--xfa/fxbarcode/cbc_ean13.h3
-rw-r--r--xfa/fxbarcode/cbc_ean8.cpp7
-rw-r--r--xfa/fxbarcode/cbc_ean8.h3
-rw-r--r--xfa/fxbarcode/cbc_pdf417i.cpp7
-rw-r--r--xfa/fxbarcode/cbc_pdf417i.h3
-rw-r--r--xfa/fxbarcode/cbc_qrcode.cpp7
-rw-r--r--xfa/fxbarcode/cbc_qrcode.h3
-rw-r--r--xfa/fxbarcode/cbc_upca.cpp7
-rw-r--r--xfa/fxbarcode/cbc_upca.h3
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp35
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.h6
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp16
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN13Writer.h2
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp17
-rw-r--r--xfa/fxbarcode/oned/BC_OnedEAN8Writer.h2
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp17
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.h2
-rw-r--r--xfa/fxfa/app/xfa_ffimage.cpp2
-rw-r--r--xfa/fxfa/app/xfa_ffimageedit.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp15
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h27
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp91
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h14
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp58
-rw-r--r--xfa/fxfa/cxfa_widgetacc.h8
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp74
-rw-r--r--xfa/fxgraphics/cfx_graphics.h7
46 files changed, 261 insertions, 267 deletions
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index 8af769aae5..3c6ca9b37e 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -82,7 +82,7 @@ float CFDE_RenderDevice::GetDpiY() const {
return 96;
}
-bool CFDE_RenderDevice::DrawImage(const CFX_RetainPtr<CFX_DIBSource>& pDib,
+bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
const CFX_RectF* pSrcRect,
const CFX_RectF& dstRect,
const CFX_Matrix* pImgMatrix,
diff --git a/xfa/fde/fde_gedevice.h b/xfa/fde/fde_gedevice.h
index a3a1eaf111..976e1bde6f 100644
--- a/xfa/fde/fde_gedevice.h
+++ b/xfa/fde/fde_gedevice.h
@@ -34,7 +34,7 @@ class CFDE_RenderDevice {
float GetDpiX() const;
float GetDpiY() const;
- bool DrawImage(const CFX_RetainPtr<CFX_DIBSource>& pDib,
+ bool DrawImage(CFX_DIBSource* pDib,
const CFX_RectF* pSrcRect,
const CFX_RectF& dstRect,
const CFX_Matrix* pImgMatrix = nullptr,
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index c06a12fedf..7f6eddd9ce 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -112,7 +112,7 @@ void CFDE_TextOut::SetLineSpace(float fLineSpace) {
m_fLineSpace = fLineSpace;
}
-void CFDE_TextOut::SetDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIB) {
+void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
ASSERT(pDIB);
m_pRenderDevice.reset();
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index e48e25567e..6883a5701f 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -87,7 +87,7 @@ class CFDE_TextOut {
void SetParagraphBreakChar(wchar_t wch);
void SetAlignment(int32_t iAlignment);
void SetLineSpace(float fLineSpace);
- void SetDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIB);
+ void SetDIBitmap(CFX_DIBitmap* pDIB);
void SetRenderDevice(CFX_RenderDevice* pDevice);
void SetClipRect(const CFX_Rect& rtClip);
void SetClipRect(const CFX_RectF& rtClip);
diff --git a/xfa/fwl/cfwl_themebackground.h b/xfa/fwl/cfwl_themebackground.h
index f23f26e229..3f20488830 100644
--- a/xfa/fwl/cfwl_themebackground.h
+++ b/xfa/fwl/cfwl_themebackground.h
@@ -16,17 +16,12 @@ class CFX_Path;
class CFWL_ThemeBackground : public CFWL_ThemePart {
public:
- CFWL_ThemeBackground();
- ~CFWL_ThemeBackground();
+ CFWL_ThemeBackground()
+ : m_pGraphics(nullptr), m_pImage(nullptr), m_pPath(nullptr) {}
CFX_Graphics* m_pGraphics;
+ CFX_DIBitmap* m_pImage;
CFX_Path* m_pPath;
- CFX_RetainPtr<CFX_DIBitmap> m_pImage;
};
-inline CFWL_ThemeBackground::CFWL_ThemeBackground()
- : m_pGraphics(nullptr), m_pPath(nullptr) {}
-
-inline CFWL_ThemeBackground::~CFWL_ThemeBackground() {}
-
#endif // XFA_FWL_CFWL_THEMEBACKGROUND_H_
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<CFX_DIBitmap>& 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<CFX_DIBitmap> 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<CFX_DIBitmap>& 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<CFX_DIBitmap> CBC_Writer::CreateDIBitmap(int32_t width,
- int32_t height) {
- auto pDIBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+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<CFX_DIBitmap> 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString renderCon =
static_cast<CBC_OnedCodaBarWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_OneDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString renderCon =
static_cast<CBC_OnedCode39Writer*>(m_pBCWriter.get())
->encodedContents(m_renderContents.AsStringC(), e);
static_cast<CBC_OneDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_TwoDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_EAN13::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_OneDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_OneDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_TwoDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_TwoDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pOutBitmap,
- int32_t& e) {
+bool CBC_UPCA::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
static_cast<CBC_OneDimWriter*>(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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<CFX_DIBitmap> 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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<CFX_DIBitmap>& 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<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,
+ 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<float>(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<CFX_DIBitmap>& 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<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,
+ 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<float>(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<CFX_DIBitmap>& 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<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,
+ 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<float>(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<CFX_DIBitmap>& pOutBitmap,
+ CFX_DIBitmap* pOutBitmap,
CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t barWidth,
diff --git a/xfa/fxfa/app/xfa_ffimage.cpp b/xfa/fxfa/app/xfa_ffimage.cpp
index 23ed88616d..81188c14d1 100644
--- a/xfa/fxfa/app/xfa_ffimage.cpp
+++ b/xfa/fxfa/app/xfa_ffimage.cpp
@@ -43,7 +43,7 @@ void CXFA_FFImage::RenderWidget(CFX_Graphics* pGS,
CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus);
- CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = GetDataAcc()->GetImageImage();
+ CFX_DIBitmap* pDIBitmap = GetDataAcc()->GetImageImage();
if (!pDIBitmap)
return;
diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp
index 624ef3f442..b776579152 100644
--- a/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -60,7 +60,7 @@ void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS,
CXFA_Border borderUI = m_pDataAcc->GetUIBorder();
DrawBorder(pGS, borderUI, m_rtUI, &mtRotate);
RenderCaption(pGS, &mtRotate);
- CFX_RetainPtr<CFX_DIBitmap> pDIBitmap = m_pDataAcc->GetImageEditImage();
+ CFX_DIBitmap* pDIBitmap = m_pDataAcc->GetImageEditImage();
if (!pDIBitmap)
return;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index e14500a725..fdeacf7f0f 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -332,6 +332,10 @@ bool CXFA_FFDoc::CloseDoc() {
m_DocView.reset();
m_pNotify.reset(nullptr);
m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this);
+
+ for (const auto& pair : m_HashToDibDpiMap)
+ delete pair.second.pDibSource;
+
m_HashToDibDpiMap.clear();
m_pApp->ClearEventTargets();
return true;
@@ -341,10 +345,9 @@ CPDF_Document* CXFA_FFDoc::GetPDFDoc() {
return m_pPDFDoc;
}
-CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
- const CFX_WideStringC& wsName,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi) {
+CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi) {
if (!m_pPDFDoc)
return nullptr;
@@ -353,7 +356,7 @@ CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
if (it != m_HashToDibDpiMap.end()) {
iImageXDpi = it->second.iImageXDpi;
iImageYDpi = it->second.iImageYDpi;
- return it->second.pDibSource.As<CFX_DIBitmap>();
+ return static_cast<CFX_DIBitmap*>(it->second.pDibSource);
}
CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
@@ -393,7 +396,7 @@ CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(),
streamAcc.GetSize());
- CFX_RetainPtr<CFX_DIBitmap> pDibSource = XFA_LoadImageFromBuffer(
+ CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer(
pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi};
return pDibSource;
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 80dafba029..1d46387a5e 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -20,30 +20,11 @@ class CXFA_FFNotify;
class CXFA_FFDocView;
struct FX_IMAGEDIB_AND_DPI {
- FX_IMAGEDIB_AND_DPI();
- FX_IMAGEDIB_AND_DPI(const FX_IMAGEDIB_AND_DPI& that);
- FX_IMAGEDIB_AND_DPI(const CFX_RetainPtr<CFX_DIBSource>& pDib,
- int32_t xDpi,
- int32_t yDpi);
- ~FX_IMAGEDIB_AND_DPI();
-
- CFX_RetainPtr<CFX_DIBSource> pDibSource;
+ CFX_DIBSource* pDibSource;
int32_t iImageXDpi;
int32_t iImageYDpi;
};
-inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI() = default;
-inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
- const FX_IMAGEDIB_AND_DPI& that) = default;
-
-inline FX_IMAGEDIB_AND_DPI::FX_IMAGEDIB_AND_DPI(
- const CFX_RetainPtr<CFX_DIBSource>& pDib,
- int32_t xDpi,
- int32_t yDpi)
- : pDibSource(pDib), iImageXDpi(xDpi), iImageYDpi(yDpi) {}
-
-inline FX_IMAGEDIB_AND_DPI::~FX_IMAGEDIB_AND_DPI() = default;
-
class CXFA_FFDoc {
public:
CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment);
@@ -67,9 +48,9 @@ class CXFA_FFDoc {
CXFA_FFDocView* GetDocView(CXFA_LayoutProcessor* pLayout);
CXFA_FFDocView* GetDocView();
CPDF_Document* GetPDFDoc();
- CFX_RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const CFX_WideStringC& wsName,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi);
+ CFX_DIBitmap* GetPDFNamedImage(const CFX_WideStringC& wsName,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi);
bool SavePackage(XFA_HashCode code,
const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile,
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 2e9c9a6ac8..504ce70ad9 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -558,7 +558,7 @@ class CXFA_ImageRenderer {
~CXFA_ImageRenderer();
bool Start(CFX_RenderDevice* pDevice,
- const CFX_RetainPtr<CFX_DIBSource>& pDIBSource,
+ CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
int bitmap_alpha,
const CFX_Matrix* pImage2Device,
@@ -568,7 +568,7 @@ class CXFA_ImageRenderer {
protected:
bool StartDIBSource();
- void CompositeDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap,
+ void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
int left,
int top,
FX_ARGB mask_argb,
@@ -579,8 +579,8 @@ class CXFA_ImageRenderer {
CFX_RenderDevice* m_pDevice;
int m_Status;
CFX_Matrix m_ImageMatrix;
- CFX_RetainPtr<CFX_DIBSource> m_pDIBSource;
- CFX_RetainPtr<CFX_DIBitmap> m_pCloneConvert;
+ CFX_DIBSource* m_pDIBSource;
+ std::unique_ptr<CFX_DIBitmap> m_pCloneConvert;
int m_BitmapAlpha;
FX_ARGB m_FillArgb;
uint32_t m_Flags;
@@ -594,6 +594,7 @@ class CXFA_ImageRenderer {
CXFA_ImageRenderer::CXFA_ImageRenderer()
: m_pDevice(nullptr),
m_Status(0),
+ m_pDIBSource(nullptr),
m_BitmapAlpha(255),
m_FillArgb(0),
m_Flags(0),
@@ -608,7 +609,7 @@ CXFA_ImageRenderer::~CXFA_ImageRenderer() {
}
bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
- const CFX_RetainPtr<CFX_DIBSource>& pDIBSource,
+ CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
int bitmap_alpha,
const CFX_Matrix* pImage2Device,
@@ -644,7 +645,7 @@ bool CXFA_ImageRenderer::StartDIBSource() {
m_Result = false;
return false;
}
- CFX_RetainPtr<CFX_DIBSource> pDib = m_pDIBSource;
+ CFX_DIBSource* pDib = m_pDIBSource;
if (m_pDIBSource->HasAlpha() &&
!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) &&
!(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
@@ -653,13 +654,13 @@ bool CXFA_ImageRenderer::StartDIBSource() {
m_Result = false;
return false;
}
- pDib = m_pCloneConvert;
+ pDib = m_pCloneConvert.get();
}
FX_RECT clip_box = m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
- pDib, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pTransformer.reset(
+ new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box));
m_pTransformer->Start();
return true;
}
@@ -699,11 +700,11 @@ bool CXFA_ImageRenderer::StartDIBSource() {
FX_RECT dest_clip(
dest_rect.left - image_rect.left, dest_rect.top - image_rect.top,
dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
- CFX_RetainPtr<CFX_DIBitmap> pStretched =
- m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip);
+ std::unique_ptr<CFX_DIBitmap> pStretched(
+ m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip));
if (pStretched) {
- CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb,
- m_BitmapAlpha, m_BlendType, false);
+ CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top,
+ m_FillArgb, m_BitmapAlpha, m_BlendType, false);
}
return false;
}
@@ -713,7 +714,7 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_pTransformer->Continue(pPause))
return true;
- CFX_RetainPtr<CFX_DIBitmap> pBitmap = m_pTransformer->DetachBitmap();
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
if (!pBitmap)
return false;
@@ -721,14 +722,14 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
m_Result =
- m_pDevice->SetBitMask(pBitmap, m_pTransformer->result().left,
+ m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left,
m_pTransformer->result().top, m_FillArgb);
} else {
if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
m_Result = m_pDevice->SetDIBitsWithBlend(
- pBitmap, m_pTransformer->result().left, m_pTransformer->result().top,
- m_BlendType);
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
return false;
}
@@ -738,14 +739,13 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
return false;
}
-void CXFA_ImageRenderer::CompositeDIBitmap(
- const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap,
- int left,
- int top,
- FX_ARGB mask_argb,
- int bitmap_alpha,
- int blend_mode,
- int Transparency) {
+void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
+ int left,
+ int top,
+ FX_ARGB mask_argb,
+ int bitmap_alpha,
+ int blend_mode,
+ int Transparency) {
if (!pDIBitmap) {
return;
}
@@ -785,10 +785,10 @@ void CXFA_ImageRenderer::CompositeDIBitmap(
FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
top + pDIBitmap->GetHeight());
rect.Intersect(m_pDevice->GetClipBox());
- CFX_RetainPtr<CFX_DIBitmap> pClone;
+ CFX_MaybeOwned<CFX_DIBitmap> pClone;
if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) {
pClone = m_pDevice->GetBackDrop()->Clone(&rect);
- CFX_RetainPtr<CFX_DIBitmap> pForeBitmap = m_pDevice->GetBitmap();
+ CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap();
pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
pForeBitmap, rect.left, rect.top);
left = left >= 0 ? 0 : left;
@@ -803,7 +803,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap(
pClone = pDIBitmap;
}
if (m_pDevice->GetBackDrop()) {
- m_pDevice->SetDIBits(pClone, rect.left, rect.top);
+ m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top);
} else {
if (pDIBitmap->IsAlphaMask())
return;
@@ -817,14 +817,14 @@ void CXFA_ImageRenderer::CompositeDIBitmap(
(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) {
return;
}
- CFX_RetainPtr<CFX_DIBitmap> pCloneConvert =
+ std::unique_ptr<CFX_DIBitmap> pCloneConvert =
pDIBitmap->CloneConvert(FXDIB_Rgb);
if (!pCloneConvert)
return;
CXFA_ImageRenderer imageRender;
- if (!imageRender.Start(m_pDevice, pCloneConvert, m_FillArgb, m_BitmapAlpha,
- &m_ImageMatrix, m_Flags)) {
+ if (!imageRender.Start(m_pDevice, pCloneConvert.get(), m_FillArgb,
+ m_BitmapAlpha, &m_ImageMatrix, m_Flags)) {
return;
}
while (imageRender.Continue(nullptr))
@@ -834,7 +834,7 @@ void CXFA_ImageRenderer::CompositeDIBitmap(
void XFA_DrawImage(CFX_Graphics* pGS,
const CFX_RectF& rtImage,
CFX_Matrix* pMatrix,
- const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap,
+ CFX_DIBitmap* pDIBitmap,
int32_t iAspect,
int32_t iImageXDpi,
int32_t iImageYDpi,
@@ -1034,19 +1034,18 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const CFX_WideString& wsType) {
return FXCODEC_IMAGE_TIF;
return FXCODEC_IMAGE_UNKNOWN;
}
-
-CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
- CXFA_Image* pImage,
- bool& bNameImage,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi) {
+CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc,
+ CXFA_Image* pImage,
+ bool& bNameImage,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi) {
CFX_WideString wsHref;
- CFX_WideString wsImage;
pImage->GetHref(wsHref);
+ CFX_WideString wsImage;
pImage->GetContent(wsImage);
- if (wsHref.IsEmpty() && wsImage.IsEmpty())
+ if (wsHref.IsEmpty() && wsImage.IsEmpty()) {
return nullptr;
-
+ }
CFX_WideString wsContentType;
pImage->GetContentType(wsContentType);
FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType);
@@ -1072,7 +1071,7 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
} else {
CFX_WideString wsURL = wsHref;
if (wsURL.Left(7) != L"http://" && wsURL.Left(6) != L"ftp://") {
- CFX_RetainPtr<CFX_DIBitmap> pBitmap =
+ CFX_DIBitmap* pBitmap =
pDoc->GetPDFNamedImage(wsURL.AsStringC(), iImageXDpi, iImageYDpi);
if (pBitmap) {
bNameImage = true;
@@ -1086,7 +1085,7 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
return nullptr;
}
bNameImage = false;
- CFX_RetainPtr<CFX_DIBitmap> pBitmap =
+ CFX_DIBitmap* pBitmap =
XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi);
FX_Free(pImageBuffer);
return pBitmap;
@@ -1112,7 +1111,7 @@ static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type,
return dibFormat;
}
-CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
+CFX_DIBitmap* XFA_LoadImageFromBuffer(
const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
@@ -1126,7 +1125,7 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
return nullptr;
CFX_DIBAttribute dibAttr;
- CFX_RetainPtr<CFX_DIBitmap> pBitmap;
+ CFX_DIBitmap* pBitmap = nullptr;
std::unique_ptr<CCodec_ProgressiveDecoder> pProgressiveDecoder =
pCodecMgr->CreateProgressiveDecoder();
pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr, false);
@@ -1150,7 +1149,7 @@ CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
int32_t iComponents = pProgressiveDecoder->GetNumComponents();
int32_t iBpc = pProgressiveDecoder->GetBPC();
FXDIB_Format dibFormat = XFA_GetDIBFormat(type, iComponents, iBpc);
- pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+ pBitmap = new CFX_DIBitmap();
pBitmap->Create(pProgressiveDecoder->GetWidth(),
pProgressiveDecoder->GetHeight(), dibFormat);
pBitmap->Clear(0xffffffff);
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 8c83c4cf4c..02a7b21b15 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -41,20 +41,20 @@ CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap);
void XFA_DrawImage(CFX_Graphics* pGS,
const CFX_RectF& rtImage,
CFX_Matrix* pMatrix,
- const CFX_RetainPtr<CFX_DIBitmap>& pDIBitmap,
+ CFX_DIBitmap* pDIBitmap,
int32_t iAspect,
int32_t iImageXDpi,
int32_t iImageYDpi,
int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left,
int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top);
-CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
- CXFA_Image* pImage,
- bool& bNameImage,
- int32_t& iImageXDpi,
- int32_t& iImageYDpi);
+CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc,
+ CXFA_Image* pImage,
+ bool& bNameImage,
+ int32_t& iImageXDpi,
+ int32_t& iImageYDpi);
-CFX_RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
+CFX_DIBitmap* XFA_LoadImageFromBuffer(
const CFX_RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 6e76119115..4c8e37291a 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -67,9 +67,15 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
public:
CXFA_ImageLayoutData()
- : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {}
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
- ~CXFA_ImageLayoutData() override {}
+ ~CXFA_ImageLayoutData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
bool LoadImageData(CXFA_WidgetAcc* pAcc) {
if (m_pDIBitmap)
@@ -89,7 +95,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
return !!m_pDIBitmap;
}
- CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap;
+ CFX_DIBitmap* m_pDIBitmap;
bool m_bNamedImage;
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
@@ -126,9 +132,15 @@ class CXFA_TextEditData : public CXFA_FieldLayoutData {
class CXFA_ImageEditData : public CXFA_FieldLayoutData {
public:
CXFA_ImageEditData()
- : m_bNamedImage(false), m_iImageXDpi(0), m_iImageYDpi(0) {}
+ : m_pDIBitmap(nullptr),
+ m_bNamedImage(false),
+ m_iImageXDpi(0),
+ m_iImageYDpi(0) {}
- ~CXFA_ImageEditData() override {}
+ ~CXFA_ImageEditData() override {
+ if (m_pDIBitmap && !m_bNamedImage)
+ delete m_pDIBitmap;
+ }
bool LoadImageData(CXFA_WidgetAcc* pAcc) {
if (m_pDIBitmap)
@@ -145,7 +157,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData {
return !!m_pDIBitmap;
}
- CFX_RetainPtr<CFX_DIBitmap> m_pDIBitmap;
+ CFX_DIBitmap* m_pDIBitmap;
bool m_bNamedImage;
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
@@ -917,8 +929,7 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) {
LoadImageImage();
size.clear();
- CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageImage();
- if (pBitmap) {
+ if (CFX_DIBitmap* pBitmap = GetImageImage()) {
int32_t iImageXDpi = 0;
int32_t iImageYDpi = 0;
GetImageDpi(iImageXDpi, iImageYDpi);
@@ -947,8 +958,7 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) {
LoadImageEditImage();
size.clear();
- CFX_RetainPtr<CFX_DIBitmap> pBitmap = GetImageEditImage();
- if (pBitmap) {
+ if (CFX_DIBitmap* pBitmap = GetImageEditImage()) {
int32_t iImageXDpi = 0;
int32_t iImageYDpi = 0;
GetImageEditDpi(iImageXDpi, iImageYDpi);
@@ -1457,34 +1467,42 @@ CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
: nullptr;
}
-CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageImage() {
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageImage() {
return m_pLayoutData
? static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get())
->m_pDIBitmap
: nullptr;
}
-CFX_RetainPtr<CFX_DIBitmap> CXFA_WidgetAcc::GetImageEditImage() {
+CFX_DIBitmap* CXFA_WidgetAcc::GetImageEditImage() {
return m_pLayoutData
? static_cast<CXFA_ImageEditData*>(m_pLayoutData.get())
->m_pDIBitmap
: nullptr;
}
-void CXFA_WidgetAcc::SetImageImage(
- const CFX_RetainPtr<CFX_DIBitmap>& newImage) {
+void CXFA_WidgetAcc::SetImageImage(CFX_DIBitmap* newImage) {
CXFA_ImageLayoutData* pData =
static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap != newImage)
- pData->m_pDIBitmap = newImage;
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
}
-void CXFA_WidgetAcc::SetImageEditImage(
- const CFX_RetainPtr<CFX_DIBitmap>& newImage) {
+void CXFA_WidgetAcc::SetImageEditImage(CFX_DIBitmap* newImage) {
CXFA_ImageEditData* pData =
static_cast<CXFA_ImageEditData*>(m_pLayoutData.get());
- if (pData->m_pDIBitmap != newImage)
- pData->m_pDIBitmap = newImage;
+ if (pData->m_pDIBitmap == newImage)
+ return;
+
+ if (pData->m_pDIBitmap && !pData->m_bNamedImage)
+ delete pData->m_pDIBitmap;
+
+ pData->m_pDIBitmap = newImage;
}
CXFA_WidgetLayoutData* CXFA_WidgetAcc::GetWidgetLayoutData() {
diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h
index c08aa1d587..8a7a7eb73d 100644
--- a/xfa/fxfa/cxfa_widgetacc.h
+++ b/xfa/fxfa/cxfa_widgetacc.h
@@ -69,10 +69,10 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi);
CXFA_TextLayout* GetCaptionTextLayout();
CXFA_TextLayout* GetTextLayout();
- CFX_RetainPtr<CFX_DIBitmap> GetImageImage();
- CFX_RetainPtr<CFX_DIBitmap> GetImageEditImage();
- void SetImageImage(const CFX_RetainPtr<CFX_DIBitmap>& newImage);
- void SetImageEditImage(const CFX_RetainPtr<CFX_DIBitmap>& newImage);
+ CFX_DIBitmap* GetImageImage();
+ CFX_DIBitmap* GetImageEditImage();
+ void SetImageImage(CFX_DIBitmap* newImage);
+ void SetImageEditImage(CFX_DIBitmap* newImage);
void UpdateUIDisplay(CXFA_FFWidget* pExcept = nullptr);
CXFA_Node* GetDatasets();
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 3cfe2d0192..48d8f6f80f 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -198,7 +198,7 @@ void CFX_Graphics::FillPath(CFX_Path* path,
RenderDeviceFillPath(path, fillMode, matrix);
}
-void CFX_Graphics::StretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
+void CFX_Graphics::StretchImage(CFX_DIBSource* source,
const CFX_RectF& rect,
CFX_Matrix* matrix) {
if (!source)
@@ -318,49 +318,48 @@ void CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
}
}
-void CFX_Graphics::RenderDeviceStretchImage(
- const CFX_RetainPtr<CFX_DIBSource>& source,
- const CFX_RectF& rect,
- CFX_Matrix* matrix) {
+void CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
+ const CFX_RectF& rect,
+ CFX_Matrix* matrix) {
CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d,
m_info.CTM.e, m_info.CTM.f);
if (matrix) {
m1.Concat(*matrix);
}
- CFX_RetainPtr<CFX_DIBitmap> bmp1 =
+ std::unique_ptr<CFX_DIBitmap> bmp1 =
source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height());
CFX_Matrix m2(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top);
m2.Concat(m1);
int32_t left;
int32_t top;
- CFX_RetainPtr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true);
- CFX_RetainPtr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top);
+ std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true);
+ std::unique_ptr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top);
CFX_RectF r = GetClipRect();
- CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
+ CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top),
- FXSYS_round(r.Width()), FXSYS_round(r.Height()), bmp3,
- FXSYS_round(r.left - left), FXSYS_round(r.top - top));
+ FXSYS_round(r.Width()), FXSYS_round(r.Height()),
+ bmp3.get(), FXSYS_round(r.left - left),
+ FXSYS_round(r.top - top));
}
void CFX_Graphics::FillPathWithPattern(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix) {
CFX_Pattern* pattern = m_info.fillColor->m_info.pattern;
- CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
+ CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
- auto bmp = pdfium::MakeRetain<CFX_DIBitmap>();
- bmp->Create(width, height, FXDIB_Argb);
- m_renderDevice->GetDIBits(bmp, 0, 0);
+ CFX_DIBitmap bmp;
+ bmp.Create(width, height, FXDIB_Argb);
+ m_renderDevice->GetDIBits(&bmp, 0, 0);
FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle;
const FX_HATCHDATA& data = hatchBitmapData[static_cast<int>(hatchStyle)];
- auto mask = pdfium::MakeRetain<CFX_DIBitmap>();
- mask->Create(data.width, data.height, FXDIB_1bppMask);
- FXSYS_memcpy(mask->GetBuffer(), data.maskBits,
- mask->GetPitch() * data.height);
+ CFX_DIBitmap mask;
+ mask.Create(data.width, data.height, FXDIB_1bppMask);
+ FXSYS_memcpy(mask.GetBuffer(), data.maskBits, mask.GetPitch() * data.height);
CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox();
if (matrix)
matrix->TransformRect(rectf);
@@ -368,35 +367,35 @@ void 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, false, nullptr, false);
+ 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()) {
- device.SetBitMask(mask, i, j,
+ for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) {
+ for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) {
+ device.SetBitMask(&mask, i, j,
m_info.fillColor->m_info.pattern->m_foreArgb);
}
}
m_renderDevice->SaveState();
m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode);
- SetDIBitsWithMatrix(bmp, &pattern->m_matrix);
+ SetDIBitsWithMatrix(&bmp, &pattern->m_matrix);
m_renderDevice->RestoreState(false);
}
void CFX_Graphics::FillPathWithShading(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix) {
- CFX_RetainPtr<CFX_DIBitmap> bitmap = m_renderDevice->GetBitmap();
+ CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
float start_x = m_info.fillColor->m_shading->m_beginPoint.x;
float start_y = m_info.fillColor->m_shading->m_beginPoint.y;
float end_x = m_info.fillColor->m_shading->m_endPoint.x;
float end_y = m_info.fillColor->m_shading->m_endPoint.y;
- auto bmp = pdfium::MakeRetain<CFX_DIBitmap>();
- bmp->Create(width, height, FXDIB_Argb);
- m_renderDevice->GetDIBits(bmp, 0, 0);
- int32_t pitch = bmp->GetPitch();
+ CFX_DIBitmap bmp;
+ bmp.Create(width, height, FXDIB_Argb);
+ m_renderDevice->GetDIBits(&bmp, 0, 0);
+ int32_t pitch = bmp.GetPitch();
bool result = false;
switch (m_info.fillColor->m_shading->m_type) {
case FX_SHADING_Axial: {
@@ -404,7 +403,7 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
float y_span = end_y - start_y;
float axis_len_square = (x_span * x_span) + (y_span * y_span);
for (int32_t row = 0; row < height; row++) {
- uint32_t* dib_buf = (uint32_t*)(bmp->GetBuffer() + row * pitch);
+ uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
for (int32_t column = 0; column < width; column++) {
float x = (float)(column);
float y = (float)(row);
@@ -435,7 +434,7 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
((start_y - end_y) * (start_y - end_y)) -
((start_r - end_r) * (start_r - end_r));
for (int32_t row = 0; row < height; row++) {
- uint32_t* dib_buf = (uint32_t*)(bmp->GetBuffer() + row * pitch);
+ uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
for (int32_t column = 0; column < width; column++) {
float x = (float)(column);
float y = (float)(row);
@@ -497,14 +496,13 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
if (result) {
m_renderDevice->SaveState();
m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode);
- SetDIBitsWithMatrix(bmp, matrix);
+ SetDIBitsWithMatrix(&bmp, matrix);
m_renderDevice->RestoreState(false);
}
}
-void CFX_Graphics::SetDIBitsWithMatrix(
- const CFX_RetainPtr<CFX_DIBSource>& source,
- CFX_Matrix* matrix) {
+void CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
+ CFX_Matrix* matrix) {
if (matrix->IsIdentity()) {
m_renderDevice->SetDIBits(source, 0, 0);
} else {
@@ -513,9 +511,9 @@ void CFX_Graphics::SetDIBitsWithMatrix(
m.Concat(*matrix);
int32_t left;
int32_t top;
- CFX_RetainPtr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true);
- CFX_RetainPtr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top);
- m_renderDevice->SetDIBits(bmp2, left, top);
+ std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true);
+ std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top);
+ m_renderDevice->SetDIBits(bmp2.get(), left, top);
}
}
diff --git a/xfa/fxgraphics/cfx_graphics.h b/xfa/fxgraphics/cfx_graphics.h
index 264ec94d53..c360813401 100644
--- a/xfa/fxgraphics/cfx_graphics.h
+++ b/xfa/fxgraphics/cfx_graphics.h
@@ -64,7 +64,7 @@ class CFX_Graphics {
void FillPath(CFX_Path* path,
FX_FillMode fillMode = FXFILL_WINDING,
CFX_Matrix* matrix = nullptr);
- void StretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
+ void StretchImage(CFX_DIBSource* source,
const CFX_RectF& rect,
CFX_Matrix* matrix = nullptr);
void ConcatMatrix(const CFX_Matrix* matrix);
@@ -90,7 +90,7 @@ class CFX_Graphics {
void RenderDeviceFillPath(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix);
- void RenderDeviceStretchImage(const CFX_RetainPtr<CFX_DIBSource>& source,
+ void RenderDeviceStretchImage(CFX_DIBSource* source,
const CFX_RectF& rect,
CFX_Matrix* matrix);
@@ -101,8 +101,7 @@ class CFX_Graphics {
FX_FillMode fillMode,
CFX_Matrix* matrix);
- void SetDIBitsWithMatrix(const CFX_RetainPtr<CFX_DIBSource>& source,
- CFX_Matrix* matrix);
+ void SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix);
CFX_RenderDevice* m_renderDevice;
std::vector<std::unique_ptr<TInfo>> m_infoStack;