Change DrawTextPath() call stack to pass matrix by reference.

Starting with CFX_RenderDevice, go in both directions and change the
DrawTextPath() call stack to pass the text-to-device matrix around by
reference, since no caller ever passes in nullptr.

Change-Id: If940955d11dc209e8464f624f3dc499096d21ce9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55721
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index e374285..740c184 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1551,12 +1551,12 @@
       if (!textobj)
         break;
 
-      CFX_Matrix text_matrix = textobj->GetTextMatrix();
+      // TODO(thestig): Should we check the return value here?
       CPDF_TextRenderer::DrawTextPath(
           &text_device, textobj->GetCharCodes(), textobj->GetCharPositions(),
           textobj->m_TextState.GetFont(), textobj->m_TextState.GetFontSize(),
-          &text_matrix, &new_matrix, textobj->m_GraphState.GetObject(),
-          (FX_ARGB)-1, 0, nullptr, 0);
+          textobj->GetTextMatrix(), &new_matrix,
+          textobj->m_GraphState.GetObject(), 0xffffffff, 0, nullptr, 0);
     }
   }
   CPDF_RenderStatus bitmap_render(m_pContext.Get(), &bitmap_device);
@@ -1769,7 +1769,7 @@
       flag |= FXFILL_NOPATHSMOOTH;
     return CPDF_TextRenderer::DrawTextPath(
         m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(), pFont,
-        font_size, &text_matrix, pDeviceMatrix,
+        font_size, text_matrix, pDeviceMatrix,
         textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
         pClippingPath, flag);
   }
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index c681858..49cfcdf 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -30,7 +30,7 @@
                                      const std::vector<float>& charPos,
                                      CPDF_Font* pFont,
                                      float font_size,
-                                     const CFX_Matrix* pText2User,
+                                     const CFX_Matrix& mtText2User,
                                      const CFX_Matrix* pUser2Device,
                                      const CFX_GraphStateData* pGraphState,
                                      FX_ARGB fill_argb,
@@ -51,7 +51,7 @@
 
     CFX_Font* font = GetFont(pFont, fontPosition);
     if (!pDevice->DrawTextPath(i - startIndex, &CharPosList.GetAt(startIndex),
-                               font, font_size, pText2User, pUser2Device,
+                               font, font_size, mtText2User, pUser2Device,
                                pGraphState, fill_argb, stroke_argb,
                                pClippingPath, nFlag)) {
       bDraw = false;
@@ -62,7 +62,7 @@
   CFX_Font* font = GetFont(pFont, fontPosition);
   if (!pDevice->DrawTextPath(CharPosList.GetCount() - startIndex,
                              &CharPosList.GetAt(startIndex), font, font_size,
-                             pText2User, pUser2Device, pGraphState, fill_argb,
+                             mtText2User, pUser2Device, pGraphState, fill_argb,
                              stroke_argb, pClippingPath, nFlag)) {
     bDraw = false;
   }
diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h
index 93b7c6a..91ab4cc 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.h
+++ b/core/fpdfapi/render/cpdf_textrenderer.h
@@ -37,7 +37,7 @@
                            const std::vector<float>& charPos,
                            CPDF_Font* pFont,
                            float font_size,
-                           const CFX_Matrix* pText2User,
+                           const CFX_Matrix& mtText2User,
                            const CFX_Matrix* pUser2Device,
                            const CFX_GraphStateData* pGraphState,
                            FX_ARGB fill_argb,
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index da73a0c..f97b92f 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -893,7 +893,7 @@
     if (pFont->GetFace()) {
       int nPathFlags =
           (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH;
-      return DrawTextPath(nChars, pCharPos, pFont, font_size, &mtText2Device,
+      return DrawTextPath(nChars, pCharPos, pFont, font_size, mtText2Device,
                           nullptr, nullptr, fill_color, 0, nullptr, nPathFlags);
     }
   }
@@ -1054,7 +1054,7 @@
                                     const TextCharPos* pCharPos,
                                     CFX_Font* pFont,
                                     float font_size,
-                                    const CFX_Matrix* pText2User,
+                                    const CFX_Matrix& mtText2User,
                                     const CFX_Matrix* pUser2Device,
                                     const CFX_GraphStateData* pGraphState,
                                     uint32_t fill_color,
@@ -1076,7 +1076,7 @@
     if (!pPath)
       continue;
 
-    matrix.Concat(*pText2User);
+    matrix.Concat(mtText2User);
 
     CFX_PathData TransformedPath(*pPath);
     TransformedPath.Transform(matrix);
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index ad3ec87..96bba2e 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -229,7 +229,7 @@
                     const TextCharPos* pCharPos,
                     CFX_Font* pFont,
                     float font_size,
-                    const CFX_Matrix* pText2User,
+                    const CFX_Matrix& mtText2User,
                     const CFX_Matrix* pUser2Device,
                     const CFX_GraphStateData* pGraphState,
                     uint32_t fill_color,