summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-21 14:11:26 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-21 21:42:11 +0000
commit1629f609d3722f25491bbbb53b2cce97a03a5867 (patch)
tree20aad3c57a05c85d378a04e6e89897e35819c3a0 /core/fxge
parent0748d3cb67926bfd38d3d67901fdda87109c6895 (diff)
downloadpdfium-1629f609d3722f25491bbbb53b2cce97a03a5867.tar.xz
Add CFX_RenderDevice::AutoRestorer()chromium/3078
Avoid cleanup on every return path. Change-Id: I6978adb6f31020d812ac88c5d46c703d1461d373 Reviewed-on: https://pdfium-review.googlesource.com/4435 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/cfx_renderdevice.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 794c2fec6b..6aa4528f05 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -83,6 +83,17 @@ class FXTEXT_CHARPOS {
class CFX_RenderDevice {
public:
+ class StateRestorer {
+ public:
+ explicit StateRestorer(CFX_RenderDevice* pDevice) : m_pDevice(pDevice) {
+ m_pDevice->SaveState();
+ }
+ ~StateRestorer() { m_pDevice->RestoreState(false); }
+
+ private:
+ CFX_RenderDevice* m_pDevice;
+ };
+
CFX_RenderDevice();
virtual ~CFX_RenderDevice();