Remove always-null args from CPDF_AnnotList::DisplayAnnots(), Try #2.

Then inline the long form of the overloaded method into the shorter
form. Then remove arguments from DisplayPass() that are always null.

Change-Id: Ife2c1760e20294d392cf189eaf56831e307645a7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86510
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 3ea2f5f..9a75b04 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -225,9 +225,7 @@
                                  CPDF_RenderContext* pContext,
                                  bool bPrinting,
                                  const CFX_Matrix& mtMatrix,
-                                 bool bWidgetPass,
-                                 CPDF_RenderOptions* pOptions,
-                                 FX_RECT* clip_rect) {
+                                 bool bWidgetPass) {
   for (const auto& pAnnot : m_AnnotList) {
     bool bWidget = pAnnot->GetSubtype() == CPDF_Annot::Subtype::WIDGET;
     if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget))
@@ -243,31 +241,13 @@
     if (!bPrinting && (annot_flags & pdfium::annotation_flags::kNoView))
       continue;
 
-    if (pOptions) {
-      const CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
-      const CPDF_OCContext* pOCContext = pOptions->GetOCContext();
-      if (pAnnotDict && pOCContext &&
-          !pOCContext->CheckOCGVisible(
-              pAnnotDict->GetDictFor(pdfium::annotation::kOC))) {
-        continue;
-      }
-    }
-
-    CFX_Matrix matrix = mtMatrix;
-    if (clip_rect) {
-      FX_RECT annot_rect =
-          matrix.TransformRect(pAnnot->GetRect()).GetOuterRect();
-      annot_rect.Intersect(*clip_rect);
-      if (annot_rect.IsEmpty())
-        continue;
-    }
     if (pContext) {
-      pAnnot->DrawInContext(pPage, pContext, matrix,
+      pAnnot->DrawInContext(pPage, pContext, mtMatrix,
                             CPDF_Annot::AppearanceMode::kNormal);
-    } else if (!pAnnot->DrawAppearance(pPage, pDevice, matrix,
+    } else if (!pAnnot->DrawAppearance(pPage, pDevice, mtMatrix,
                                        CPDF_Annot::AppearanceMode::kNormal,
-                                       pOptions)) {
-      pAnnot->DrawBorder(pDevice, &matrix, pOptions);
+                                       nullptr)) {
+      pAnnot->DrawBorder(pDevice, &mtMatrix, nullptr);
     }
   }
 }
@@ -277,29 +257,8 @@
                                    CPDF_RenderContext* pContext,
                                    bool bPrinting,
                                    const CFX_Matrix& mtUser2Device,
-                                   uint32_t dwAnnotFlags,
-                                   CPDF_RenderOptions* pOptions,
-                                   FX_RECT* pClipRect) {
-  if (dwAnnotFlags & pdfium::annotation_flags::kInvisible) {
-    DisplayPass(pPage, pDevice, pContext, bPrinting, mtUser2Device, false,
-                pOptions, pClipRect);
-  }
-  if (dwAnnotFlags & pdfium::annotation_flags::kHidden) {
-    DisplayPass(pPage, pDevice, pContext, bPrinting, mtUser2Device, true,
-                pOptions, pClipRect);
-  }
-}
-
-void CPDF_AnnotList::DisplayAnnots(CPDF_Page* pPage,
-                                   CFX_RenderDevice* device,
-                                   CPDF_RenderContext* pContext,
-                                   bool bPrinting,
-                                   const CFX_Matrix& mtMatrix,
-                                   bool bShowWidget,
-                                   CPDF_RenderOptions* pOptions) {
-  uint32_t dwAnnotFlags = bShowWidget ? pdfium::annotation_flags::kInvisible |
-                                            pdfium::annotation_flags::kHidden
-                                      : pdfium::annotation_flags::kInvisible;
-  DisplayAnnots(pPage, device, pContext, bPrinting, mtMatrix, dwAnnotFlags,
-                pOptions, nullptr);
+                                   bool bShowWidget) {
+  DisplayPass(pPage, pDevice, pContext, bPrinting, mtUser2Device, false);
+  if (bShowWidget)
+    DisplayPass(pPage, pDevice, pContext, bPrinting, mtUser2Device, true);
 }
diff --git a/core/fpdfdoc/cpdf_annotlist.h b/core/fpdfdoc/cpdf_annotlist.h
index ef87043..2664407 100644
--- a/core/fpdfdoc/cpdf_annotlist.h
+++ b/core/fpdfdoc/cpdf_annotlist.h
@@ -22,7 +22,6 @@
 class CPDF_Document;
 class CPDF_Page;
 class CPDF_RenderContext;
-class CPDF_RenderOptions;
 
 class CPDF_AnnotList final : public CPDF_PageRenderContext::AnnotListIface {
  public:
@@ -30,21 +29,11 @@
   ~CPDF_AnnotList() override;
 
   void DisplayAnnots(CPDF_Page* pPage,
-                     CFX_RenderDevice* device,
-                     CPDF_RenderContext* pContext,
-                     bool bPrinting,
-                     const CFX_Matrix& mtMatrix,
-                     bool bShowWidget,
-                     CPDF_RenderOptions* pOptions);
-
-  void DisplayAnnots(CPDF_Page* pPage,
                      CFX_RenderDevice* pDevice,
                      CPDF_RenderContext* pContext,
                      bool bPrinting,
                      const CFX_Matrix& mtUser2Device,
-                     uint32_t dwAnnotFlags,
-                     CPDF_RenderOptions* pOptions,
-                     FX_RECT* pClipRect);
+                     bool bShowWidget);
 
   size_t Count() const { return m_AnnotList.size(); }
   CPDF_Annot* GetAt(size_t index) const { return m_AnnotList[index].get(); }
@@ -58,9 +47,7 @@
                    CPDF_RenderContext* pContext,
                    bool bPrinting,
                    const CFX_Matrix& mtMatrix,
-                   bool bWidget,
-                   CPDF_RenderOptions* pOptions,
-                   FX_RECT* clip_rect);
+                   bool bWidget);
 
   UnownedPtr<CPDF_Document> const m_pDocument;
 
diff --git a/fpdfsdk/cpdfsdk_renderpage.cpp b/fpdfsdk/cpdfsdk_renderpage.cpp
index 548f82c..6a0869f 100644
--- a/fpdfsdk/cpdfsdk_renderpage.cpp
+++ b/fpdfsdk/cpdfsdk_renderpage.cpp
@@ -75,7 +75,7 @@
     const bool bShowWidget = false;
     pList->DisplayAnnots(pPage, pContext->m_pDevice.get(),
                          pContext->m_pContext.get(), bPrinting, matrix,
-                         bShowWidget, nullptr);
+                         bShowWidget);
   }
 
   pContext->m_pRenderer = std::make_unique<CPDF_ProgressiveRenderer>(