summaryrefslogtreecommitdiff
path: root/core/fxge
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 /core/fxge
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>
Diffstat (limited to 'core/fxge')
-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
11 files changed, 45 insertions, 64 deletions
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,