Remove default argument from RestoreState() methods.

Review-Url: https://codereview.chromium.org/2009803003
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 5ffedca..3144191 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -443,7 +443,7 @@
   m_pDevice->SaveState();
   status.RenderObjectList(pFormObj->m_pForm, &matrix);
   m_bStopped = status.m_bStopped;
-  m_pDevice->RestoreState();
+  m_pDevice->RestoreState(false);
   return TRUE;
 }
 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) {
@@ -583,7 +583,7 @@
                                         const CFX_Matrix* pObj2Device) {
   if (ClipPath.IsNull()) {
     if (!m_LastClipPath.IsNull()) {
-      m_pDevice->RestoreState(TRUE);
+      m_pDevice->RestoreState(true);
       m_LastClipPath.SetNull();
     }
     return;
@@ -592,7 +592,7 @@
     return;
 
   m_LastClipPath = ClipPath;
-  m_pDevice->RestoreState(TRUE);
+  m_pDevice->RestoreState(true);
   int nClipPath = ClipPath.GetPathCount();
   for (int i = 0; i < nClipPath; ++i) {
     const CFX_PathData* pPathData = ClipPath.GetPath(i);
@@ -974,7 +974,7 @@
         m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
       }
       if (status.m_bStopped) {
-        pDevice->RestoreState();
+        pDevice->RestoreState(false);
         break;
       }
     } else {
@@ -986,11 +986,11 @@
         m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
       }
       if (status.m_bStopped) {
-        pDevice->RestoreState();
+        pDevice->RestoreState(false);
         break;
       }
     }
-    pDevice->RestoreState();
+    pDevice->RestoreState(false);
   }
 }
 
@@ -1007,7 +1007,7 @@
 
 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() {
   if (m_pRenderStatus)
-    m_pDevice->RestoreState();
+    m_pDevice->RestoreState(false);
 }
 
 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) {
@@ -1080,7 +1080,7 @@
     }
     if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) {
       m_pRenderStatus.reset();
-      m_pDevice->RestoreState();
+      m_pDevice->RestoreState(false);
       m_pCurrentLayer = nullptr;
       m_LayerIndex++;
       if (pPause && pPause->NeedToPauseNow()) {
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index b8fa400..393b993 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -959,7 +959,7 @@
   m_pDevice->SaveState();
   if (pPageObj->IsPath()) {
     if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
-      m_pDevice->RestoreState();
+      m_pDevice->RestoreState(false);
       return;
     }
   } else if (pPageObj->IsImage()) {
@@ -969,7 +969,7 @@
   }
   FX_RECT rect;
   if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) {
-    m_pDevice->RestoreState();
+    m_pDevice->RestoreState(false);
     return;
   }
   CFX_Matrix matrix = *pattern->pattern_to_form();
@@ -978,7 +978,7 @@
   int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke);
   DrawShading(pattern, &matrix, rect, alpha,
               m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
-  m_pDevice->RestoreState();
+  m_pDevice->RestoreState(false);
 }
 
 void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
@@ -1006,7 +1006,7 @@
   m_pDevice->SaveState();
   if (pPageObj->IsPath()) {
     if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
-      m_pDevice->RestoreState();
+      m_pDevice->RestoreState(false);
       return;
     }
   } else if (pPageObj->IsImage()) {
@@ -1016,7 +1016,7 @@
   }
   FX_RECT clip_box = m_pDevice->GetClipBox();
   if (clip_box.IsEmpty()) {
-    m_pDevice->RestoreState();
+    m_pDevice->RestoreState(false);
     return;
   }
   CFX_Matrix dCTM = m_pDevice->GetCTM();
@@ -1084,9 +1084,9 @@
                           pStates, &m_Options, pPattern->form()->m_Transparency,
                           m_bDropObjects, pFormResource);
         status.RenderObjectList(pPattern->form(), &matrix);
-        m_pDevice->RestoreState();
+        m_pDevice->RestoreState(false);
       }
-    m_pDevice->RestoreState();
+    m_pDevice->RestoreState(false);
     delete pStates;
     return;
   }
@@ -1124,7 +1124,7 @@
         pObj2Device, width, height, m_Options.m_Flags);
   }
   if (!pPatternBitmap) {
-    m_pDevice->RestoreState();
+    m_pDevice->RestoreState(false);
     return;
   }
   if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
@@ -1178,7 +1178,7 @@
   }
   CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255,
                     FXDIB_BLEND_NORMAL, FALSE);
-  m_pDevice->RestoreState();
+  m_pDevice->RestoreState(false);
 }
 
 void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index ce73208..5bd7c35 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -430,7 +430,7 @@
         status.m_Type3FontCache.Add(pType3Font);
         m_pDevice->SaveState();
         status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
-        m_pDevice->RestoreState();
+        m_pDevice->RestoreState(false);
       } else {
         CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox();
         rect_f.Transform(&matrix);
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 6726877..86326f6 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -284,21 +284,21 @@
   m_StateStack.Add(pClip);
 }
 
-void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
-  if (m_StateStack.GetSize() == 0) {
-    delete m_pClipRgn;
-    m_pClipRgn = nullptr;
-    return;
-  }
-  CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1];
+void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) {
   delete m_pClipRgn;
   m_pClipRgn = nullptr;
+
+  int size = m_StateStack.GetSize();
+  if (!size)
+    return;
+
+  CFX_ClipRgn* pSavedClip = m_StateStack[size - 1];
   if (bKeepSaved) {
     if (pSavedClip) {
       m_pClipRgn = new CFX_ClipRgn(*pSavedClip);
     }
   } else {
-    m_StateStack.RemoveAt(m_StateStack.GetSize() - 1);
+    m_StateStack.RemoveAt(size - 1);
     m_pClipRgn = pSavedClip;
   }
 }
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 18f8d34..a33bc09 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -40,7 +40,7 @@
   // IFX_RenderDeviceDriver
   int GetDeviceCaps(int caps_id) override;
   void SaveState() override;
-  void RestoreState(FX_BOOL bKeepSaved) override;
+  void RestoreState(bool bKeepSaved) override;
   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
                            const CFX_Matrix* pObject2Device,
                            int fill_mode) override;
diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h
index 02754cc..ddfa792 100644
--- a/core/fxge/apple/apple_int.h
+++ b/core/fxge/apple/apple_int.h
@@ -91,7 +91,7 @@
   FX_BOOL StartRendering() override { return TRUE; }
   void EndRendering() override {}
   void SaveState() override;
-  void RestoreState(FX_BOOL bKeepSaved) override;
+  void RestoreState(bool bKeepSaved) override;
   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
                            const CFX_Matrix* pObject2Device,
                            int fill_mode) override;
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index 6669899..5bdffa9 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -218,7 +218,8 @@
   CGContextSaveGState(m_context);
   m_saveCount++;
 }
-void CFX_QuartzDeviceDriver::RestoreState(FX_BOOL isKeepSaved) {
+
+void CFX_QuartzDeviceDriver::RestoreState(bool isKeepSaved) {
   CGContextRestoreGState(m_context);
   if (isKeepSaved) {
     CGContextSaveGState(m_context);
@@ -226,6 +227,7 @@
     m_saveCount--;
   }
 }
+
 FX_BOOL CFX_QuartzDeviceDriver::SetClip_PathFill(const CFX_PathData* pathData,
                                                  const CFX_Matrix* matrix,
                                                  int fillMode) {
@@ -238,7 +240,7 @@
   m = CGAffineTransformConcat(m, m_foxitDevice2User);
   CGContextConcatCTM(m_context, m);
   setPathToContext(pathData);
-  RestoreState(FALSE);
+  RestoreState(false);
   if ((fillMode & 3) == FXFILL_WINDING) {
     CGContextClip(m_context);
   } else {
@@ -277,7 +279,7 @@
   setStrokeInfo(graphState, 0xFF000000, lineWidth);
   setPathToContext(pathData);
   CGContextReplacePathWithStrokedPath(m_context);
-  RestoreState(FALSE);
+  RestoreState(false);
   CGContextClip(m_context);
   return TRUE;
 }
@@ -389,7 +391,7 @@
   } else if (pathMode == 6) {
     CGContextDrawPath(m_context, kCGPathEOFillStroke);
   }
-  RestoreState(FALSE);
+  RestoreState(false);
   return TRUE;
 }
 FX_BOOL CFX_QuartzDeviceDriver::FillRect(const FX_RECT* rect,
@@ -553,7 +555,7 @@
       pBitmap1 = pBitmap->Clone();
     }
     if (NULL == pBitmap1) {
-      RestoreState(FALSE);
+      RestoreState(false);
       return FALSE;
     }
     CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
@@ -576,7 +578,7 @@
     if (pBitmap1 != pBitmap) {
       delete pBitmap1;
     }
-    RestoreState(FALSE);
+    RestoreState(false);
     return TRUE;
   }
   if (pBitmap->GetBPP() < 32) {
@@ -589,14 +591,14 @@
     }
   }
   if (NULL == pBitmap1) {
-    RestoreState(FALSE);
+    RestoreState(false);
     return FALSE;
   }
   if (pBitmap1->HasAlpha()) {
     if (pBitmap1 == pBitmap) {
       pBitmap1 = pBitmap->Clone();
       if (!pBitmap1) {
-        RestoreState(FALSE);
+        RestoreState(false);
         return FALSE;
       }
     }
@@ -630,7 +632,7 @@
   if (pBitmap1 != pBitmap) {
     delete pBitmap1;
   }
-  RestoreState(FALSE);
+  RestoreState(false);
   return TRUE;
 }
 FX_BOOL CFX_QuartzDeviceDriver::StretchDIBits(const CFX_DIBSource* pBitmap,
@@ -671,7 +673,7 @@
       pBitmap1 = pBitmap->Clone();
     }
     if (NULL == pBitmap1) {
-      RestoreState(FALSE);
+      RestoreState(false);
       return FALSE;
     }
     CGDataProviderRef pBitmapProvider = CGDataProviderCreateWithData(
@@ -694,7 +696,7 @@
     if (pBitmap1 != pBitmap) {
       delete pBitmap1;
     }
-    RestoreState(FALSE);
+    RestoreState(false);
     return TRUE;
   }
   if (pBitmap->GetBPP() < 32) {
@@ -707,14 +709,14 @@
     }
   }
   if (NULL == pBitmap1) {
-    RestoreState(FALSE);
+    RestoreState(false);
     return FALSE;
   }
   if (pBitmap1->HasAlpha()) {
     if (pBitmap1 == pBitmap) {
       pBitmap1 = pBitmap->Clone();
       if (!pBitmap1) {
-        RestoreState(FALSE);
+        RestoreState(false);
         return FALSE;
       }
     }
@@ -736,7 +738,7 @@
   if (pBitmap1 != pBitmap) {
     delete pBitmap1;
   }
-  RestoreState(FALSE);
+  RestoreState(false);
   return TRUE;
 }
 FX_BOOL CFX_QuartzDeviceDriver::CG_DrawGlypRun(int nChars,
@@ -803,7 +805,7 @@
   }
   CGContextShowGlyphsAtPositions(m_context, (CGGlyph*)glyph_indices,
                                  glyph_positions, nChars);
-  RestoreState(FALSE);
+  RestoreState(false);
   return TRUE;
 }
 FX_BOOL CFX_QuartzDeviceDriver::DrawDeviceText(int nChars,
@@ -833,7 +835,7 @@
         ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device,
                              font_size, color, alpha_flag, pIccTransform);
         if (!ret) {
-          RestoreState(FALSE);
+          RestoreState(false);
           return ret;
         }
       }
@@ -851,7 +853,7 @@
                            pObject2Device, font_size, color, alpha_flag,
                            pIccTransform);
       if (!ret) {
-        RestoreState(FALSE);
+        RestoreState(false);
         return ret;
       }
       i++;
@@ -866,7 +868,7 @@
     ret = CG_DrawGlypRun(i, pCharPos, pFont, pCache, NULL, pObject2Device,
                          font_size, color, alpha_flag, pIccTransform);
   }
-  RestoreState(FALSE);
+  RestoreState(false);
   return ret;
 }
 void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState,
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp
index 0d6adda..2d3ba56 100644
--- a/core/fxge/ge/fx_ge_device.cpp
+++ b/core/fxge/ge/fx_ge_device.cpp
@@ -40,10 +40,12 @@
 void CFX_RenderDevice::SaveState() {
   m_pDeviceDriver->SaveState();
 }
-void CFX_RenderDevice::RestoreState(FX_BOOL bKeepSaved) {
+
+void CFX_RenderDevice::RestoreState(bool bKeepSaved) {
   m_pDeviceDriver->RestoreState(bKeepSaved);
   UpdateClipBox();
 }
+
 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const {
   return m_pDeviceDriver->GetDeviceCaps(caps_id);
 }
diff --git a/core/fxge/ge/fx_ge_ps.cpp b/core/fxge/ge/fx_ge_ps.cpp
index 9825333..b112cf3 100644
--- a/core/fxge/ge/fx_ge_ps.cpp
+++ b/core/fxge/ge/fx_ge_ps.cpp
@@ -77,19 +77,25 @@
   OUTPUT_PS("q\n");
   m_ClipBoxStack.Add(m_ClipBox);
 }
-void CFX_PSRenderer::RestoreState(FX_BOOL bKeepSaved) {
+
+void CFX_PSRenderer::RestoreState(bool bKeepSaved) {
   StartRendering();
   if (bKeepSaved) {
     OUTPUT_PS("Q\nq\n");
   } else {
     OUTPUT_PS("Q\n");
   }
-  m_bColorSet = m_bGraphStateSet = FALSE;
-  m_ClipBox = m_ClipBoxStack.GetAt(m_ClipBoxStack.GetSize() - 1);
-  if (!bKeepSaved) {
-    m_ClipBoxStack.RemoveAt(m_ClipBoxStack.GetSize() - 1);
-  }
+  m_bColorSet = FALSE;
+  m_bGraphStateSet = FALSE;
+  int size = m_ClipBoxStack.GetSize();
+  if (!size)
+    return;
+
+  m_ClipBox = m_ClipBoxStack.GetAt(size - 1);
+  if (!bKeepSaved)
+    m_ClipBoxStack.RemoveAt(size - 1);
 }
+
 void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
                                 const CFX_Matrix* pObject2Device) {
   int nPoints = pPathData->GetPointCount();
diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h
index 8f6b10d..6efd517 100644
--- a/core/fxge/include/fx_ge.h
+++ b/core/fxge/include/fx_ge.h
@@ -216,7 +216,7 @@
   FX_BOOL StartRendering();
   void EndRendering();
   void SaveState();
-  void RestoreState(FX_BOOL bKeepSaved = FALSE);
+  void RestoreState(bool bKeepSaved);
 
   int GetWidth() const { return m_Width; }
   int GetHeight() const { return m_Height; }
@@ -431,7 +431,7 @@
 
   virtual void SaveState() = 0;
 
-  virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) = 0;
+  virtual void RestoreState(bool bKeepSaved) = 0;
 
   virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
                                    const CFX_Matrix* pObject2Device,
@@ -575,7 +575,7 @@
   FX_BOOL StartRendering();
   void EndRendering();
   void SaveState();
-  void RestoreState(FX_BOOL bKeepSaved = FALSE);
+  void RestoreState(bool bKeepSaved);
   void SetClip_PathFill(const CFX_PathData* pPathData,
                         const CFX_Matrix* pObject2Device,
                         int fill_mode);
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 6646eed..c4ca6f9 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -604,7 +604,7 @@
   m_pCanvas->save();
 }
 
-void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
+void CFX_SkiaDeviceDriver::RestoreState(bool bKeepSaved) {
   m_pCanvas->restore();
   if (bKeepSaved)
     m_pCanvas->save();
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index ef66b94..79097ad 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -30,7 +30,7 @@
 
   /** Save and restore all graphic states */
   void SaveState() override;
-  void RestoreState(FX_BOOL bKeepSaved) override;
+  void RestoreState(bool bKeepSaved) override;
 
   /** Set clipping path using filled region */
   FX_BOOL SetClip_PathFill(
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index caf271d..b71f3ae 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -507,6 +507,7 @@
     m_RenderCaps = FXRC_GET_BITS | FXRC_BIT_MASK;
   }
 }
+
 int CGdiDeviceDriver::GetDeviceCaps(int caps_id) {
   switch (caps_id) {
     case FXDC_DEVICE_CLASS:
@@ -522,6 +523,17 @@
   }
   return 0;
 }
+
+void CGdiDeviceDriver::SaveState() {
+  SaveDC(m_hDC);
+}
+
+void CGdiDeviceDriver::RestoreState(bool bKeepSaved) {
+  RestoreDC(m_hDC, -1);
+  if (bKeepSaved)
+    SaveDC(m_hDC);
+}
+
 void* CGdiDeviceDriver::GetClipRgn() {
   HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1);
   if (::GetClipRgn(m_hDC, hClipRgn) == 0) {
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index d035913..9fd1683 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -270,7 +270,7 @@
     FX_BOOL ret = StretchDIBits(
         pTransformed, color, full_rect.left, full_rect.top, full_rect.Width(),
         full_rect.Height(), NULL, 0, alpha_flag, pIccTransform, blend_type);
-    RestoreState();
+    RestoreState(false);
     delete pTransformed;
     handle = NULL;
     return ret;
@@ -371,9 +371,11 @@
 void CPSPrinterDriver::SaveState() {
   m_PSRenderer.SaveState();
 }
-void CPSPrinterDriver::RestoreState(FX_BOOL bKeepSaved) {
+
+void CPSPrinterDriver::RestoreState(bool bKeepSaved) {
   m_PSRenderer.RestoreState(bKeepSaved);
 }
+
 FX_BOOL CPSPrinterDriver::SetClip_PathFill(const CFX_PathData* pPathData,
                                            const CFX_Matrix* pObject2Device,
                                            int fill_mode) {
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 619ac2f..d2d091b 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -109,13 +109,8 @@
  protected:
   // IFX_RenderDeviceDriver
   int GetDeviceCaps(int caps_id) override;
-  void SaveState() override { SaveDC(m_hDC); }
-  void RestoreState(FX_BOOL bKeepSaved = FALSE) override {
-    RestoreDC(m_hDC, -1);
-    if (bKeepSaved) {
-      SaveDC(m_hDC);
-    }
-  }
+  void SaveState() override;
+  void RestoreState(bool bKeepSaved) override;
   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
                            const CFX_Matrix* pObject2Device,
                            int fill_mode) override;
@@ -298,7 +293,7 @@
   FX_BOOL StartRendering() override;
   void EndRendering() override;
   void SaveState() override;
-  void RestoreState(FX_BOOL bKeepSaved = FALSE) override;
+  void RestoreState(bool bKeepSaved) override;
   FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
                            const CFX_Matrix* pObject2Device,
                            int fill_mode) override;
diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp
index 411ae17..c66807c 100644
--- a/fpdfsdk/fpdf_progressive.cpp
+++ b/fpdfsdk/fpdf_progressive.cpp
@@ -91,6 +91,6 @@
   if (!pContext)
     return;
 
-  pContext->m_pDevice->RestoreState();
+  pContext->m_pDevice->RestoreState(false);
   pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
 }
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index b1c729b..6bcb605 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -374,7 +374,7 @@
     pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
 #endif  // PDF_ENABLE_XFA
 
-  pDevice->RestoreState();
+  pDevice->RestoreState(false);
   delete options.m_pOCContext;
 #ifdef PDF_ENABLE_XFA
   options.m_pOCContext = NULL;
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 0040c09..9bf9839 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -912,7 +912,7 @@
       pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions);
   pContext->m_pRenderer->Start(pause);
   if (bNeedToRestore)
-    pContext->m_pDevice->RestoreState();
+    pContext->m_pDevice->RestoreState(false);
 }
 
 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp
index be38609..91039f4 100644
--- a/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -136,7 +136,7 @@
     }
   }
 
-  pDevice->RestoreState();
+  pDevice->RestoreState(false);
 }
 
 void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
@@ -260,7 +260,7 @@
     }
   }
 
-  pDevice->RestoreState();
+  pDevice->RestoreState(false);
 }
 
 void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
@@ -385,7 +385,7 @@
     }
   }
 
-  pDevice->RestoreState();
+  pDevice->RestoreState(false);
 }
 
 static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
diff --git a/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp b/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
index 8067907..dde2160 100644
--- a/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
@@ -160,7 +160,7 @@
     }
   }
 
-  pDevice->RestoreState();
+  pDevice->RestoreState(false);
 }
 
 int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp
index f99dc6c..9c6cde3 100644
--- a/xfa/fde/fde_gedevice.cpp
+++ b/xfa/fde/fde_gedevice.cpp
@@ -41,7 +41,7 @@
   return NULL;
 }
 void CFDE_RenderDevice::RestoreState(FDE_HDEVICESTATE hState) {
-  m_pDevice->RestoreState();
+  m_pDevice->RestoreState(false);
   const FX_RECT& rt = m_pDevice->GetClipBox();
   m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(),
                (FX_FLOAT)rt.Height());
diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp
index 8ce583a..957a31f 100644
--- a/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -835,7 +835,7 @@
   while (bRet) {
     bRet = imageRender.Continue(NULL);
   }
-  pRenderDevice->RestoreState();
+  pRenderDevice->RestoreState(false);
 }
 
 static const uint8_t g_inv_base64[128] = {
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 179e470..8de0def 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -639,7 +639,7 @@
 
 FWL_Error CFX_Graphics::RestoreGraphState() {
   if (m_type == FX_CONTEXT_Device && m_renderDevice) {
-    m_renderDevice->RestoreState();
+    m_renderDevice->RestoreState(false);
     int32_t size = m_infoStack.GetSize();
     if (size <= 0) {
       return FWL_Error::IntermediateValueInvalid;
@@ -1356,7 +1356,7 @@
   m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
                                    fillMode);
   SetDIBitsWithMatrix(&bmp, &pattern->m_matrix);
-  m_renderDevice->RestoreState();
+  m_renderDevice->RestoreState(false);
   return FWL_Error::Succeeded;
 }
 
@@ -1477,7 +1477,7 @@
     m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
                                      fillMode);
     SetDIBitsWithMatrix(&bmp, matrix);
-    m_renderDevice->RestoreState();
+    m_renderDevice->RestoreState(false);
   }
   return result ? FWL_Error::Succeeded : FWL_Error::PropertyInvalid;
 }