summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-04-04 13:38:29 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-04 18:21:06 +0000
commitc3202a95773d7a2c95038ad45c5ba2c9e095e67b (patch)
tree4742e65e173bbfec56a10b249abee6d9934047bd
parent6088612c21898eb79cfbde401984176dd94c385c (diff)
downloadpdfium-c3202a95773d7a2c95038ad45c5ba2c9e095e67b.tar.xz
Let CPDF_ImageRenderer own the CFX_ImageRenderer
This CL avoids some void* usage and removes CancelDIBits after making a CPDF_ImageRenderer own its CFX_ImageRenderer. Bug: pdfium:686 Change-Id: Ied205c57a858cc14d8e2c592db3444ed465b2796 Reviewed-on: https://pdfium-review.googlesource.com/3673 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp36
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.h3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp4
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp21
-rw-r--r--core/fxge/agg/fx_agg_driver.h5
-rw-r--r--core/fxge/cfx_renderdevice.h8
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp10
-rw-r--r--core/fxge/ifx_renderdevicedriver.cpp5
-rw-r--r--core/fxge/ifx_renderdevicedriver.h8
-rw-r--r--core/fxge/skia/fx_skia_device.cpp29
-rw-r--r--core/fxge/skia/fx_skia_device.h6
-rw-r--r--core/fxge/win32/fx_win32_device.cpp3
-rw-r--r--core/fxge/win32/fx_win32_print.cpp7
-rw-r--r--core/fxge/win32/win32_int.h7
-rw-r--r--xfa/fde/cfde_renderdevice.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp12
16 files changed, 74 insertions, 98 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 8c3cd6a23a..b4cc36f6c3 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -40,23 +40,18 @@
#include "core/fxge/skia/fx_skia_device.h"
#endif
-CPDF_ImageRenderer::CPDF_ImageRenderer() {
- m_pRenderStatus = nullptr;
- m_pImageObject = nullptr;
- m_Result = true;
- m_Status = 0;
- m_DeviceHandle = nullptr;
- m_bStdCS = false;
- m_bPatternColor = false;
- m_BlendType = FXDIB_BLEND_NORMAL;
- m_pPattern = nullptr;
- m_pObj2Device = nullptr;
-}
-
-CPDF_ImageRenderer::~CPDF_ImageRenderer() {
- if (m_DeviceHandle)
- m_pRenderStatus->m_pDevice->CancelDIBits(m_DeviceHandle);
-}
+CPDF_ImageRenderer::CPDF_ImageRenderer()
+ : m_pRenderStatus(nullptr),
+ m_pImageObject(nullptr),
+ m_Status(0),
+ m_pObj2Device(nullptr),
+ m_bPatternColor(false),
+ m_pPattern(nullptr),
+ m_bStdCS(false),
+ m_BlendType(FXDIB_BLEND_NORMAL),
+ m_Result(true) {}
+
+CPDF_ImageRenderer::~CPDF_ImageRenderer() {}
bool CPDF_ImageRenderer::StartLoadDIBSource() {
CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
@@ -413,7 +408,7 @@ bool CPDF_ImageRenderer::StartDIBSource() {
CFX_SkiaDeviceDriver::PreMultiply(premultiplied);
if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
premultiplied, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
- m_DeviceHandle, m_BlendType)) {
+ &m_DeviceHandle, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return true;
@@ -423,7 +418,7 @@ bool CPDF_ImageRenderer::StartDIBSource() {
#else
if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend(
m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
- m_DeviceHandle, m_BlendType)) {
+ &m_DeviceHandle, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return true;
@@ -564,7 +559,8 @@ bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
return false;
}
if (m_Status == 3)
- return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
+ return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle.get(),
+ pPause);
if (m_Status == 4) {
if (m_Loader.Continue(pPause))
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h
index 00b5d41601..79bb018886 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.h
+++ b/core/fpdfapi/render/cpdf_imagerenderer.h
@@ -11,6 +11,7 @@
#include "core/fpdfapi/render/cpdf_imageloader.h"
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
class CFX_DIBitmap;
class CFX_DIBSource;
@@ -74,7 +75,7 @@ class CPDF_ImageRenderer {
FX_ARGB m_FillArgb;
uint32_t m_Flags;
std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
- void* m_DeviceHandle;
+ std::unique_ptr<CFX_ImageRenderer> m_DeviceHandle;
bool m_bStdCS;
int m_BlendType;
bool m_Result;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 09e5bc1433..985d6ce8c5 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2424,10 +2424,10 @@ void CPDF_RenderStatus::CompositeDIBitmap(
if (!pDIBitmap->IsAlphaMask()) {
if (bitmap_alpha < 255) {
#ifdef _SKIA_SUPPORT_
- void* dummy;
+ std::unique_ptr<CFX_ImageRenderer> dummy;
CFX_Matrix m(pDIBitmap->GetWidth(), 0, 0, -pDIBitmap->GetHeight(), left,
top + pDIBitmap->GetHeight());
- m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, dummy);
+ m_pDevice->StartDIBits(pDIBitmap, bitmap_alpha, 0, &m, 0, &dummy);
return;
#else
pDIBitmap->MultiplyAlpha(bitmap_alpha);
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 031246b494..a04d716b8f 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1650,29 +1650,20 @@ bool CFX_AggDeviceDriver::StartDIBits(
uint32_t argb,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) {
if (!m_pBitmap->GetBuffer())
return true;
- CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
- pRenderer->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb,
+ *handle = pdfium::MakeUnique<CFX_ImageRenderer>();
+ (*handle)->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb,
pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr);
- handle = pRenderer;
return true;
}
-bool CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
- return m_pBitmap->GetBuffer()
- ? reinterpret_cast<CFX_ImageRenderer*>(pHandle)->Continue(pPause)
- : true;
-}
-
-void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) {
- if (!m_pBitmap->GetBuffer())
- return;
-
- delete reinterpret_cast<CFX_ImageRenderer*>(pHandle);
+bool CFX_AggDeviceDriver::ContinueDIBits(CFX_ImageRenderer* pHandle,
+ IFX_Pause* pPause) {
+ return m_pBitmap->GetBuffer() ? pHandle->Continue(pPause) : true;
}
#ifndef _SKIA_SUPPORT_
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 723ed6d98a..3eb56c507e 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -87,10 +87,9 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) override;
- bool ContinueDIBits(void* handle, IFX_Pause* pPause) override;
- void CancelDIBits(void* handle) override;
+ bool ContinueDIBits(CFX_ImageRenderer* handle, IFX_Pause* pPause) override;
bool DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index d56c2ecb9a..794c2fec6b 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -15,6 +15,7 @@
class CFX_Font;
class CFX_GraphStateData;
+class CFX_ImageRenderer;
class IFX_RenderDeviceDriver;
#define FXDC_DEVICE_CLASS 1
@@ -193,7 +194,7 @@ class CFX_RenderDevice {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle) {
+ std::unique_ptr<CFX_ImageRenderer>* handle) {
return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags,
handle, FXDIB_BLEND_NORMAL);
}
@@ -202,10 +203,9 @@ class CFX_RenderDevice {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type);
- bool ContinueDIBits(void* handle, IFX_Pause* pPause);
- void CancelDIBits(void* handle);
+ bool ContinueDIBits(CFX_ImageRenderer* handle, IFX_Pause* pPause);
bool DrawNormalText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 521ba4c65d..b100f4d2f9 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -16,6 +16,7 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_pathdata.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
#include "core/fxge/ifx_renderdevicedriver.h"
#if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_
@@ -825,20 +826,17 @@ bool CFX_RenderDevice::StartDIBitsWithBlend(
uint32_t argb,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_mode) {
return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix,
flags, handle, blend_mode);
}
-bool CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) {
+bool CFX_RenderDevice::ContinueDIBits(CFX_ImageRenderer* handle,
+ IFX_Pause* pPause) {
return m_pDeviceDriver->ContinueDIBits(handle, pPause);
}
-void CFX_RenderDevice::CancelDIBits(void* handle) {
- m_pDeviceDriver->CancelDIBits(handle);
-}
-
#ifdef _SKIA_SUPPORT_
void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const {
SkASSERT(0);
diff --git a/core/fxge/ifx_renderdevicedriver.cpp b/core/fxge/ifx_renderdevicedriver.cpp
index 35cd4e221d..fae86cbfc6 100644
--- a/core/fxge/ifx_renderdevicedriver.cpp
+++ b/core/fxge/ifx_renderdevicedriver.cpp
@@ -59,12 +59,11 @@ CFX_RetainPtr<CFX_DIBitmap> IFX_RenderDeviceDriver::GetBackDrop() {
return CFX_RetainPtr<CFX_DIBitmap>();
}
-bool IFX_RenderDeviceDriver::ContinueDIBits(void* handle, IFX_Pause* pPause) {
+bool IFX_RenderDeviceDriver::ContinueDIBits(CFX_ImageRenderer* handle,
+ IFX_Pause* pPause) {
return false;
}
-void IFX_RenderDeviceDriver::CancelDIBits(void* handle) {}
-
bool IFX_RenderDeviceDriver::DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h
index 87e38fa5f0..97f35b641b 100644
--- a/core/fxge/ifx_renderdevicedriver.h
+++ b/core/fxge/ifx_renderdevicedriver.h
@@ -7,6 +7,8 @@
#ifndef CORE_FXGE_IFX_RENDERDEVICEDRIVER_H_
#define CORE_FXGE_IFX_RENDERDEVICEDRIVER_H_
+#include <memory>
+
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_system.h"
@@ -14,6 +16,7 @@ class CFX_DIBitmap;
class CFX_DIBSource;
class CFX_Font;
class CFX_GraphStateData;
+class CFX_ImageRenderer;
class CFX_Matrix;
class CFX_PathData;
class CPDF_ShadingPattern;
@@ -82,10 +85,9 @@ class IFX_RenderDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) = 0;
- virtual bool ContinueDIBits(void* handle, IFX_Pause* pPause);
- virtual void CancelDIBits(void* handle);
+ virtual bool ContinueDIBits(CFX_ImageRenderer* handle, IFX_Pause* pPause);
virtual bool DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 81ca95fbe8..429510d30e 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1884,8 +1884,8 @@ bool CFX_SkiaDeviceDriver::SetDIBits(
#ifdef _SKIA_SUPPORT_
CFX_Matrix m(pBitmap->GetWidth(), 0, 0, -pBitmap->GetHeight(), left,
top + pBitmap->GetHeight());
- void* dummy;
- return StartDIBits(pBitmap, 0xFF, argb, &m, 0, dummy, blend_type);
+ std::unique_ptr<CFX_ImageRenderer> dummy;
+ return StartDIBits(pBitmap, 0xFF, argb, &m, 0, &dummy, blend_type);
#endif // _SKIA_SUPPORT_
#ifdef _SKIA_SUPPORT_PATHS_
@@ -1923,8 +1923,8 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(
SkRect skClipRect = SkRect::MakeLTRB(pClipRect->left, pClipRect->bottom,
pClipRect->right, pClipRect->top);
m_pCanvas->clipRect(skClipRect, SkClipOp::kIntersect, true);
- void* dummy;
- bool result = StartDIBits(pSource, 0xFF, argb, &m, 0, dummy, blend_type);
+ std::unique_ptr<CFX_ImageRenderer> dummy;
+ bool result = StartDIBits(pSource, 0xFF, argb, &m, 0, &dummy, blend_type);
m_pCanvas->restore();
return result;
@@ -1960,7 +1960,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits(
uint32_t argb,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) {
#ifdef _SKIA_SUPPORT_
m_pCache->FlushForDraw();
@@ -2009,24 +2009,15 @@ bool CFX_SkiaDeviceDriver::StartDIBits(
if (!m_pBitmap->GetBuffer())
return true;
m_pBitmap->UnPreMultiply();
- CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
- pRenderer->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb,
+ *handle = pdfium::MakeUnique<CFX_ImageRenderer>();
+ (*handle)->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb,
pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr);
- handle = pRenderer;
#endif // _SKIA_SUPPORT_PATHS_
return true;
}
-void CFX_SkiaDeviceDriver::CancelDIBits(void* handle) {
-#ifdef _SKIA_SUPPORT_PATHS_
- if (!m_pBitmap->GetBuffer())
- return;
-
- delete reinterpret_cast<CFX_ImageRenderer*>(handle);
-#endif // _SKIA_SUPPORT_PATHS_
-}
-
-bool CFX_SkiaDeviceDriver::ContinueDIBits(void* handle, IFX_Pause* pPause) {
+bool CFX_SkiaDeviceDriver::ContinueDIBits(CFX_ImageRenderer* handle,
+ IFX_Pause* pPause) {
#ifdef _SKIA_SUPPORT_
m_pCache->FlushForDraw();
return false;
@@ -2037,7 +2028,7 @@ bool CFX_SkiaDeviceDriver::ContinueDIBits(void* handle, IFX_Pause* pPause) {
if (!m_pBitmap->GetBuffer()) {
return true;
}
- return static_cast<CFX_ImageRenderer*>(handle)->Continue(pPause);
+ return handle->Continue(pPause);
#endif // _SKIA_SUPPORT_PATHS_
}
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index 9b5e4b06fa..cde05eba67 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -119,12 +119,10 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) override;
- bool ContinueDIBits(void* handle, IFX_Pause* pPause) override;
-
- void CancelDIBits(void* handle) override;
+ bool ContinueDIBits(CFX_ImageRenderer* handle, IFX_Pause* pPause) override;
bool DrawBitsWithMask(const CFX_RetainPtr<CFX_DIBSource>& pBitmap,
const CFX_RetainPtr<CFX_DIBSource>& pMask,
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index a27ac6fbd2..811ca11c07 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -16,6 +16,7 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_windowsdevice.h"
#include "core/fxge/dib/cfx_dibextractor.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/fx_freetype.h"
@@ -1356,7 +1357,7 @@ bool CGdiDisplayDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap,
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) {
return false;
}
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 868c113880..084a136d4d 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_windowsdevice.h"
#include "core/fxge/dib/cfx_dibextractor.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/fx_freetype.h"
#include "core/fxge/ge/fx_text_int.h"
@@ -164,7 +165,7 @@ bool CGdiPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource,
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) {
if (bitmap_alpha < 255 || pSource->HasAlpha() ||
(pSource->IsAlphaMask() && (pSource->GetBPP() != 1))) {
@@ -469,7 +470,7 @@ bool CPSPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap,
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) {
if (blend_type != FXDIB_BLEND_NORMAL)
return false;
@@ -477,7 +478,7 @@ bool CPSPrinterDriver::StartDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap,
if (bitmap_alpha < 255)
return false;
- handle = nullptr;
+ *handle = nullptr;
return m_PSRenderer.DrawDIBits(pBitmap, color, pMatrix, render_flags);
}
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 35521d0096..a5fc853de5 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -17,6 +17,7 @@
#include "core/fxge/win32/cpsoutput.h"
#include "core/fxge/win32/dwrite_int.h"
+class CFX_ImageRenderer;
class FXTEXT_CHARPOS;
struct WINDIB_Open_Args_;
@@ -215,7 +216,7 @@ class CGdiDisplayDriver : public CGdiDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) override;
bool UseFoxitStretchEngine(const CFX_RetainPtr<CFX_DIBSource>& pSource,
uint32_t color,
@@ -254,7 +255,7 @@ class CGdiPrinterDriver : public CGdiDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) override;
bool DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
@@ -313,7 +314,7 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver {
uint32_t color,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
- void*& handle,
+ std::unique_ptr<CFX_ImageRenderer>* handle,
int blend_type) override;
bool DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp
index 6f2431737b..839ffac019 100644
--- a/xfa/fde/cfde_renderdevice.cpp
+++ b/xfa/fde/cfde_renderdevice.cpp
@@ -13,6 +13,7 @@
#include "core/fxge/cfx_graphstatedata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/cfx_substfont.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
#include "xfa/fde/cfde_brush.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/cfde_pen.h"
@@ -111,12 +112,11 @@ bool CFDE_RenderDevice::DrawImage(const CFX_RetainPtr<CFX_DIBSource>& pDib,
if (pDevMatrix) {
dib2fxdev.Concat(*pDevMatrix);
}
- void* handle = nullptr;
+ std::unique_ptr<CFX_ImageRenderer> handle;
m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0,
- handle);
- while (m_pDevice->ContinueDIBits(handle, nullptr)) {
+ &handle);
+ while (m_pDevice->ContinueDIBits(handle.get(), nullptr)) {
}
- m_pDevice->CancelDIBits(handle);
return !!handle;
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 1ebc6da353..18d6f94bc7 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -17,6 +17,7 @@
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "core/fxge/dib/cfx_imagerenderer.h"
#include "core/fxge/dib/cfx_imagetransformer.h"
#include "xfa/fwl/fwl_widgethit.h"
#include "xfa/fxfa/app/cxfa_textlayout.h"
@@ -587,7 +588,7 @@ class CXFA_ImageRenderer {
FX_ARGB m_FillArgb;
uint32_t m_Flags;
std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
- void* m_DeviceHandle;
+ std::unique_ptr<CFX_ImageRenderer> m_DeviceHandle;
int32_t m_BlendType;
bool m_Result;
bool m_bPrint;
@@ -604,10 +605,7 @@ CXFA_ImageRenderer::CXFA_ImageRenderer()
m_Result(true),
m_bPrint(false) {}
-CXFA_ImageRenderer::~CXFA_ImageRenderer() {
- if (m_DeviceHandle)
- m_pDevice->CancelDIBits(m_DeviceHandle);
-}
+CXFA_ImageRenderer::~CXFA_ImageRenderer() {}
bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
const CFX_RetainPtr<CFX_DIBSource>& pDIBSource,
@@ -628,7 +626,7 @@ bool CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
bool CXFA_ImageRenderer::StartDIBSource() {
if (m_pDevice->StartDIBitsWithBlend(m_pDIBSource, m_BitmapAlpha, m_FillArgb,
- &m_ImageMatrix, m_Flags, m_DeviceHandle,
+ &m_ImageMatrix, m_Flags, &m_DeviceHandle,
m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
@@ -735,7 +733,7 @@ bool CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
return false;
}
if (m_Status == 3)
- return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
+ return m_pDevice->ContinueDIBits(m_DeviceHandle.get(), pPause);
return false;
}