summaryrefslogtreecommitdiff
path: root/core/fxge/apple
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-07-21 14:44:17 -0700
committerCommit bot <commit-bot@chromium.org>2016-07-21 14:44:17 -0700
commitc38cd6eb274429a5755e04d2e22a606375851717 (patch)
tree158c1e58b7d66a715cd7ba1459c55d329f08c49d /core/fxge/apple
parent1d3348ce0092d6d2a40de5f8433c0d0c16a1e12e (diff)
downloadpdfium-c38cd6eb274429a5755e04d2e22a606375851717.tar.xz
Use smart pointers for graphics device classes
Use unique_ptr for class owned member variables. Also clean up some style issues such as removing unused functions and casting to raw pointer. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2163103002
Diffstat (limited to 'core/fxge/apple')
-rw-r--r--core/fxge/apple/fx_quartz_device.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index b3591a3da1..a9b9268ae6 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -10,6 +10,7 @@
#include "core/fxge/agg/fx_agg_driver.h"
#endif
+#include "core/fxcrt/include/fx_memory.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
#include "core/fxge/include/fx_freetype.h"
@@ -1018,34 +1019,32 @@ FX_BOOL CFX_QuartzDevice::Attach(CGContextRef context, int32_t nDeviceClass) {
}
m_pContext = context;
CGContextRetain(m_pContext);
- IFX_RenderDeviceDriver* pDriver =
- new CFX_QuartzDeviceDriver(m_pContext, nDeviceClass);
- SetDeviceDriver(pDriver);
+ SetDeviceDriver(
+ WrapUnique(new CFX_QuartzDeviceDriver(m_pContext, nDeviceClass)));
return TRUE;
}
+
FX_BOOL CFX_QuartzDevice::Attach(CFX_DIBitmap* pBitmap) {
SetBitmap(pBitmap);
m_pContext = createContextWithBitmap(pBitmap);
if (!m_pContext)
return FALSE;
- IFX_RenderDeviceDriver* pDriver =
- new CFX_QuartzDeviceDriver(m_pContext, FXDC_DISPLAY);
- SetDeviceDriver(pDriver);
+ SetDeviceDriver(
+ WrapUnique(new CFX_QuartzDeviceDriver(m_pContext, FXDC_DISPLAY)));
return TRUE;
}
+
FX_BOOL CFX_QuartzDevice::Create(int32_t width,
int32_t height,
FXDIB_Format format) {
if ((uint8_t)format < 32) {
return FALSE;
}
- CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
- if (!pBitmap->Create(width, height, format)) {
- delete pBitmap;
+ std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap);
+ if (!pBitmap->Create(width, height, format))
return FALSE;
- }
m_bOwnedBitmap = TRUE;
- return Attach(pBitmap);
+ return Attach(pBitmap.release());
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_