No need to check for null pages in RenderPageWithContext()

Its callers are essentially "public", and already must validate the
parameter before calling.

- Reorder the parameters as |page| comes before |context| in the name.
- Pass the internal type rather than the public type.
- Early return in one spot.

Change-Id: I8744545cd9e7b266a15d6c5f1470f0e1e78a93fb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/61990
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
index d91e0b0..527a04a 100644
--- a/fpdfsdk/cpdfsdk_helpers.h
+++ b/fpdfsdk/cpdfsdk_helpers.h
@@ -261,8 +261,8 @@
 FPDF_BOOL IsPDFSandboxPolicyEnabled(FPDF_DWORD policy);
 
 // TODO(dsinclair): Where should this live?
-void RenderPageWithContext(CPDF_PageRenderContext* pContext,
-                           FPDF_PAGE page,
+void RenderPageWithContext(CPDF_Page* pPage,
+                           CPDF_PageRenderContext* pContext,
                            int start_x,
                            int start_y,
                            int size_x,
diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp
index 212509f..ac83405 100644
--- a/fpdfsdk/fpdf_progressive.cpp
+++ b/fpdfsdk/fpdf_progressive.cpp
@@ -56,18 +56,19 @@
   pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
 
   CPDFSDK_PauseAdapter pause_adapter(pause);
-  RenderPageWithContext(pContext, page, start_x, start_y, size_x, size_y,
+  RenderPageWithContext(pPage, pContext, start_x, start_y, size_x, size_y,
                         rotate, flags, false, &pause_adapter);
 
 #ifdef _SKIA_SUPPORT_PATHS_
   pDevice->Flush(false);
   pBitmap->UnPreMultiply();
 #endif
-  if (pContext->m_pRenderer) {
-    return CPDF_ProgressiveRenderer::ToFPDFStatus(
-        pContext->m_pRenderer->GetStatus());
-  }
-  return FPDF_RENDER_FAILED;
+
+  if (!pContext->m_pRenderer)
+    return FPDF_RENDER_FAILED;
+
+  return CPDF_ProgressiveRenderer::ToFPDFStatus(
+      pContext->m_pRenderer->GetStatus());
 }
 
 FPDF_EXPORT int FPDF_CALLCONV FPDF_RenderPage_Continue(FPDF_PAGE page,
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index c9253b9..009b7f4 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -556,7 +556,7 @@
     pContext->m_pDevice = pdfium::MakeUnique<CPDF_WindowsRenderDevice>(dc);
   }
 
-  RenderPageWithContext(pContext, page, start_x, start_y, size_x, size_y,
+  RenderPageWithContext(pPage, pContext, start_x, start_y, size_x, size_y,
                         rotate, flags, true, nullptr);
 
   if (bHasMask) {
@@ -582,7 +582,7 @@
     pContext->m_pOptions = pdfium::MakeUnique<CPDF_RenderOptions>();
     pContext->m_pOptions->GetOptions().bBreakForMasks = true;
 
-    RenderPageWithContext(pContext, page, start_x, start_y, size_x, size_y,
+    RenderPageWithContext(pPage, pContext, start_x, start_y, size_x, size_y,
                           rotate, flags, true, nullptr);
 
     // Render masks
@@ -639,7 +639,7 @@
 
   RetainPtr<CFX_DIBitmap> pBitmap(CFXDIBitmapFromFPDFBitmap(bitmap));
   pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
-  RenderPageWithContext(pContext, page, start_x, start_y, size_x, size_y,
+  RenderPageWithContext(pPage, pContext, start_x, start_y, size_x, size_y,
                         rotate, flags, true, nullptr);
 
 #ifdef _SKIA_SUPPORT_PATHS_
@@ -703,7 +703,7 @@
   FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y);
   pContext->m_pDevice = std::move(skDevice);
 
-  RenderPageWithContext(pContext, page, 0, 0, size_x, size_y, 0, 0, true,
+  RenderPageWithContext(pPage, pContext, 0, 0, size_x, size_y, 0, 0, true,
                         nullptr);
   return recorder;
 }
@@ -895,8 +895,8 @@
   destroyer.Unleak(CFXDIBitmapFromFPDFBitmap(bitmap));
 }
 
-void RenderPageWithContext(CPDF_PageRenderContext* pContext,
-                           FPDF_PAGE page,
+void RenderPageWithContext(CPDF_Page* pPage,
+                           CPDF_PageRenderContext* pContext,
                            int start_x,
                            int start_y,
                            int size_x,
@@ -905,10 +905,6 @@
                            int flags,
                            bool bNeedToRestore,
                            CPDFSDK_PauseAdapter* pause) {
-  CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
-  if (!pPage)
-    return;
-
   const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
   RenderPageImpl(pContext, pPage, pPage->GetDisplayMatrix(rect, rotate), rect,
                  flags, bNeedToRestore, pause);