summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_renderdevice.cpp10
-rw-r--r--xfa/fde/cfde_renderdevice.h3
-rw-r--r--xfa/fde/cfde_textout.cpp11
-rw-r--r--xfa/fde/cfde_textout.h2
-rw-r--r--xfa/fwl/cfwl_edit.cpp5
-rw-r--r--xfa/fxfa/app/cxfa_textlayout.cpp2
-rw-r--r--xfa/fxgraphics/cfx_graphics.h2
7 files changed, 17 insertions, 18 deletions
diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp
index 7fb5b0352e..9236dc7800 100644
--- a/xfa/fde/cfde_renderdevice.cpp
+++ b/xfa/fde/cfde_renderdevice.cpp
@@ -22,9 +22,8 @@
#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fgas/font/cfgas_gefont.h"
-CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
- bool bOwnerDevice)
- : m_pDevice(pDevice), m_bOwnerDevice(bOwnerDevice), m_iCharCount(0) {
+CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice)
+ : m_pDevice(pDevice), m_iCharCount(0) {
ASSERT(pDevice);
FX_RECT rt = m_pDevice->GetClipBox();
@@ -33,10 +32,7 @@ CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
static_cast<float>(rt.Height()));
}
-CFDE_RenderDevice::~CFDE_RenderDevice() {
- if (m_bOwnerDevice)
- delete m_pDevice;
-}
+CFDE_RenderDevice::~CFDE_RenderDevice() {}
int32_t CFDE_RenderDevice::GetWidth() const {
return m_pDevice->GetWidth();
diff --git a/xfa/fde/cfde_renderdevice.h b/xfa/fde/cfde_renderdevice.h
index f429ac1703..d9f4ce0d34 100644
--- a/xfa/fde/cfde_renderdevice.h
+++ b/xfa/fde/cfde_renderdevice.h
@@ -19,7 +19,7 @@ class CFX_GraphStateData;
class CFDE_RenderDevice {
public:
- CFDE_RenderDevice(CFX_RenderDevice* pDevice, bool bOwnerDevice);
+ explicit CFDE_RenderDevice(CFX_RenderDevice* pDevice);
~CFDE_RenderDevice();
int32_t GetWidth() const;
@@ -120,7 +120,6 @@ class CFDE_RenderDevice {
CFX_RenderDevice* const m_pDevice;
CFX_RectF m_rtClip;
- bool m_bOwnerDevice;
int32_t m_iCharCount;
};
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index b41ee1fbd8..6d5ab2a980 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -7,6 +7,7 @@
#include "xfa/fde/cfde_textout.h"
#include <algorithm>
+#include <utility>
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -117,16 +118,16 @@ void CFDE_TextOut::SetLineSpace(float fLineSpace) {
void CFDE_TextOut::SetDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIB) {
ASSERT(pDIB);
-
m_pRenderDevice.reset();
- CFX_DefaultRenderDevice* device = new CFX_DefaultRenderDevice;
- device->Attach(pDIB, false, nullptr, false);
- m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(device, false);
+ m_pDefaultRenderDevice = pdfium::MakeUnique<CFX_DefaultRenderDevice>();
+ m_pDefaultRenderDevice->Attach(pDIB, false, nullptr, false);
+ m_pRenderDevice =
+ pdfium::MakeUnique<CFDE_RenderDevice>(m_pDefaultRenderDevice.get());
}
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
ASSERT(pDevice);
- m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pDevice, false);
+ m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pDevice);
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index 360c3051e9..a52814041b 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -167,6 +167,8 @@ class CFDE_TextOut {
int32_t m_iCurPiece;
int32_t m_iTotalLines;
std::vector<FXTEXT_CHARPOS> m_CharPos;
+ // NOTE: m_pDefaultRenderDevice must outlive m_pRenderDevice.
+ std::unique_ptr<CFX_DefaultRenderDevice> m_pDefaultRenderDevice;
std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
std::vector<int32_t> m_HotKeys;
std::vector<CFX_RectF> m_rectArray;
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 8c03402f23..28948cca21 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -566,9 +566,10 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics,
if (!pRenderDev)
return;
- auto pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pRenderDev, false);
- auto pRenderContext = pdfium::MakeUnique<CFDE_RenderContext>();
+ auto pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pRenderDev);
pRenderDevice->SetClipRect(rtClip);
+
+ auto pRenderContext = pdfium::MakeUnique<CFDE_RenderContext>();
pRenderContext->StartRender(pRenderDevice.get(), pPage, mt);
pRenderContext->DoRender();
diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp
index 686ad4ee0d..c43f7e3260 100644
--- a/xfa/fxfa/app/cxfa_textlayout.cpp
+++ b/xfa/fxfa/app/cxfa_textlayout.cpp
@@ -559,7 +559,7 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
if (!pFxDevice)
return false;
- auto pDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pFxDevice, false);
+ auto pDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pFxDevice);
pDevice->SaveState();
pDevice->SetClipRect(rtClip);
diff --git a/xfa/fxgraphics/cfx_graphics.h b/xfa/fxgraphics/cfx_graphics.h
index b2e2cd1c88..8785a387d6 100644
--- a/xfa/fxgraphics/cfx_graphics.h
+++ b/xfa/fxgraphics/cfx_graphics.h
@@ -104,7 +104,7 @@ class CFX_Graphics {
void SetDIBitsWithMatrix(const CFX_RetainPtr<CFX_DIBSource>& source,
CFX_Matrix* matrix);
- CFX_RenderDevice* m_renderDevice;
+ CFX_RenderDevice* const m_renderDevice; // Not owned.
std::vector<std::unique_ptr<TInfo>> m_infoStack;
};