diff options
Diffstat (limited to 'xfa/fxgraphics')
-rw-r--r-- | xfa/fxgraphics/cfx_graphics.cpp | 37 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_graphics.h | 3 |
2 files changed, 18 insertions, 22 deletions
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 059872f81c..120634ca51 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -630,30 +630,25 @@ FWL_Error CFX_Graphics::EnableAntialiasing(bool isAntialiasing) { } FWL_Error CFX_Graphics::SaveGraphState() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_renderDevice->SaveState(); - m_infoStack.Add(new TInfo(m_info)); - return FWL_Error::Succeeded; - } - return FWL_Error::PropertyInvalid; + if (m_type != FX_CONTEXT_Device || !m_renderDevice) + return FWL_Error::PropertyInvalid; + + m_renderDevice->SaveState(); + m_infoStack.push_back(pdfium::MakeUnique<TInfo>(m_info)); + return FWL_Error::Succeeded; } FWL_Error CFX_Graphics::RestoreGraphState() { - if (m_type == FX_CONTEXT_Device && m_renderDevice) { - m_renderDevice->RestoreState(false); - int32_t size = m_infoStack.GetSize(); - if (size <= 0) { - return FWL_Error::IntermediateValueInvalid; - } - int32_t topIndex = size - 1; - std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex)); - if (!info) - return FWL_Error::IntermediateValueInvalid; - m_info = *info; - m_infoStack.RemoveAt(topIndex); - return FWL_Error::Succeeded; - } - return FWL_Error::PropertyInvalid; + if (m_type != FX_CONTEXT_Device || !m_renderDevice) + return FWL_Error::PropertyInvalid; + + m_renderDevice->RestoreState(false); + if (m_infoStack.empty() || !m_infoStack.back()) + return FWL_Error::IntermediateValueInvalid; + + m_info = *m_infoStack.back(); + m_infoStack.pop_back(); + return FWL_Error::Succeeded; } FWL_Error CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const { diff --git a/xfa/fxgraphics/cfx_graphics.h b/xfa/fxgraphics/cfx_graphics.h index e18564bf6d..48784254b0 100644 --- a/xfa/fxgraphics/cfx_graphics.h +++ b/xfa/fxgraphics/cfx_graphics.h @@ -8,6 +8,7 @@ #define XFA_FXGRAPHICS_CFX_GRAPHICS_H_ #include <memory> +#include <vector> #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_fxgedevice.h" @@ -233,7 +234,7 @@ class CFX_Graphics { CFX_RectF& rect); CFX_RenderDevice* m_renderDevice; - CFX_ArrayTemplate<TInfo*> m_infoStack; + std::vector<std::unique_ptr<TInfo>> m_infoStack; std::unique_ptr<CAGG_Graphics> m_aggGraphics; friend class CAGG_Graphics; }; |