diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 54 | ||||
-rw-r--r-- | fpdfsdk/fxedit/fxet_edit.cpp | 4 |
2 files changed, 28 insertions, 30 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 6610f81c65..a050dc0161 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -115,37 +115,37 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, #endif CFX_RetainPtr<CFX_DIBitmap> holder(CFXBitmapFromFPDFBitmap(bitmap)); pDevice->Attach(holder, false, nullptr, false); - pDevice->SaveState(); - pDevice->SetClip_Rect(clip); - - CPDF_RenderOptions options; - if (flags & FPDF_LCD_TEXT) - options.m_Flags |= RENDER_CLEARTYPE; - else - options.m_Flags &= ~RENDER_CLEARTYPE; - - // Grayscale output - if (flags & FPDF_GRAYSCALE) { - options.m_ColorMode = RENDER_COLOR_GRAY; - options.m_ForeColor = 0; - options.m_BackColor = 0xffffff; - } - options.m_AddFlags = flags >> 8; - options.m_bDrawAnnots = flags & FPDF_ANNOT; + { + CFX_RenderDevice::StateRestorer restorer(pDevice.get()); + pDevice->SetClip_Rect(clip); + + CPDF_RenderOptions options; + if (flags & FPDF_LCD_TEXT) + options.m_Flags |= RENDER_CLEARTYPE; + else + options.m_Flags &= ~RENDER_CLEARTYPE; + + // Grayscale output + if (flags & FPDF_GRAYSCALE) { + options.m_ColorMode = RENDER_COLOR_GRAY; + options.m_ForeColor = 0; + options.m_BackColor = 0xffffff; + } + options.m_AddFlags = flags >> 8; + options.m_bDrawAnnots = flags & FPDF_ANNOT; #ifdef PDF_ENABLE_XFA - options.m_pOCContext = - pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View); - if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true)) - pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); + options.m_pOCContext = + pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View); + if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true)) + pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); #else // PDF_ENABLE_XFA - options.m_pOCContext = pdfium::MakeRetain<CPDF_OCContext>( - pPage->m_pDocument, CPDF_OCContext::View); - if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) - pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); + options.m_pOCContext = pdfium::MakeRetain<CPDF_OCContext>( + pPage->m_pDocument, CPDF_OCContext::View); + if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) + pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); #endif // PDF_ENABLE_XFA - - pDevice->RestoreState(false); + } #ifdef _SKIA_SUPPORT_PATHS_ pDevice->Flush(); holder->UnPreMultiply(); diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp index 5b84c9b95e..cf4fdc3d91 100644 --- a/fpdfsdk/fxedit/fxet_edit.cpp +++ b/fpdfsdk/fxedit/fxet_edit.cpp @@ -681,7 +681,7 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, CFX_ByteTextBuf sTextBuf; int32_t nFontIndex = -1; CFX_PointF ptBT; - pDevice->SaveState(); + CFX_RenderDevice::StateRestorer restorer(pDevice); if (!rcClip.IsEmpty()) { CFX_FloatRect rcTemp = rcClip; pUser2Device->TransformRect(rcTemp); @@ -770,8 +770,6 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, sTextBuf.MakeString(), crOldFill, nHorzScale); } } - - pDevice->RestoreState(false); } CFX_Edit::CFX_Edit() |