diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-21 14:11:26 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-21 21:42:11 +0000 |
commit | 1629f609d3722f25491bbbb53b2cce97a03a5867 (patch) | |
tree | 20aad3c57a05c85d378a04e6e89897e35819c3a0 /core/fpdfapi/render/cpdf_rendercontext.cpp | |
parent | 0748d3cb67926bfd38d3d67901fdda87109c6895 (diff) | |
download | pdfium-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/fpdfapi/render/cpdf_rendercontext.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_rendercontext.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index 07af2cc172..e4ef9af94d 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -64,34 +64,24 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_RenderOptions* pOptions, const CFX_Matrix* pLastMatrix) { for (auto& layer : m_Layers) { - pDevice->SaveState(); + CFX_RenderDevice::StateRestorer restorer(pDevice); + CPDF_RenderStatus status; if (pLastMatrix) { CFX_Matrix FinalMatrix = layer.m_Matrix; FinalMatrix.Concat(*pLastMatrix); - CPDF_RenderStatus status; status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr, pOptions, layer.m_pObjectHolder->m_Transparency, false, nullptr); status.RenderObjectList(layer.m_pObjectHolder, &FinalMatrix); - if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) - m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); - if (status.m_bStopped) { - pDevice->RestoreState(false); - break; - } } else { - CPDF_RenderStatus status; status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr, pOptions, layer.m_pObjectHolder->m_Transparency, false, nullptr); status.RenderObjectList(layer.m_pObjectHolder, &layer.m_Matrix); - if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) - m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); - if (status.m_bStopped) { - pDevice->RestoreState(false); - break; - } } - pDevice->RestoreState(false); + if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) + m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); + if (status.m_bStopped) + break; } } |