CPDF_Document::LoadPattern() and friends always have a valid matrix.

So pass by const-ref instead of by pointer.

Review URL: https://codereview.chromium.org/1923153002
diff --git a/BUILD.gn b/BUILD.gn
index 0ef7291..4c974a9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -383,7 +383,6 @@
     "core/fpdfapi/fpdf_page/fpdf_page_func.cpp",
     "core/fpdfapi/fpdf_page/fpdf_page_parser.cpp",
     "core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp",
-    "core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp",
     "core/fpdfapi/fpdf_page/include/cpdf_clippath.h",
     "core/fpdfapi/fpdf_page/include/cpdf_color.h",
     "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h",
diff --git a/core/fpdfapi/fpdf_page/cpdf_form.cpp b/core/fpdfapi/fpdf_page/cpdf_form.cpp
index 54698c6..570419f 100644
--- a/core/fpdfapi/fpdf_page/cpdf_form.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_form.cpp
@@ -18,15 +18,13 @@
                      CPDF_Dictionary* pParentResources) {
   m_pDocument = pDoc;
   m_pFormStream = pFormStream;
-  m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
+  m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr;
   m_pResources = m_pFormDict->GetDictBy("Resources");
   m_pPageResources = pPageResources;
-  if (!m_pResources) {
+  if (!m_pResources)
     m_pResources = pParentResources;
-  }
-  if (!m_pResources) {
+  if (!m_pResources)
     m_pResources = pPageResources;
-  }
   m_Transparency = 0;
   LoadTransInfo();
 }
@@ -34,23 +32,23 @@
 CPDF_Form::~CPDF_Form() {}
 
 void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
-                           CFX_Matrix* pParentMatrix,
+                           const CFX_Matrix* pParentMatrix,
                            CPDF_Type3Char* pType3Char,
                            int level) {
-  if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
+  if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
     return;
-  }
+
   m_pParser.reset(new CPDF_ContentParser);
   m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level);
   m_ParseState = CONTENT_PARSING;
 }
 
 void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates,
-                             CFX_Matrix* pParentMatrix,
+                             const CFX_Matrix* pParentMatrix,
                              CPDF_Type3Char* pType3Char,
                              int level) {
   StartParse(pGraphicStates, pParentMatrix, pType3Char, level);
-  ContinueParse(NULL);
+  ContinueParse(nullptr);
 }
 
 CPDF_Form* CPDF_Form::Clone() const {
diff --git a/core/fpdfapi/fpdf_page/cpdf_pattern.cpp b/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
index 838f4af..f8bc9a5 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
@@ -9,10 +9,10 @@
 CPDF_Pattern::CPDF_Pattern(PatternType type,
                            CPDF_Document* pDoc,
                            CPDF_Object* pObj,
-                           const CFX_Matrix* pParentMatrix)
-    : m_PatternType(type), m_pDocument(pDoc), m_pPatternObj(pObj) {
-  if (pParentMatrix)
-    m_ParentMatrix = *pParentMatrix;
-}
+                           const CFX_Matrix& parentMatrix)
+    : m_PatternType(type),
+      m_pDocument(pDoc),
+      m_pPatternObj(pObj),
+      m_ParentMatrix(parentMatrix) {}
 
 CPDF_Pattern::~CPDF_Pattern() {}
diff --git a/core/fpdfapi/fpdf_page/cpdf_pattern.h b/core/fpdfapi/fpdf_page/cpdf_pattern.h
index d6ef49c..983c9ea 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_pattern.h
@@ -27,19 +27,19 @@
   CPDF_Document* document() { return m_pDocument; }
   CPDF_Object* pattern_obj() { return m_pPatternObj; }
   CFX_Matrix* pattern_to_form() { return &m_Pattern2Form; }
-  CFX_Matrix* parent_matrix() { return &m_ParentMatrix; }
+  const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; }
 
  protected:
   CPDF_Pattern(PatternType type,
                CPDF_Document* pDoc,
                CPDF_Object* pObj,
-               const CFX_Matrix* pParentMatrix);
+               const CFX_Matrix& parentMatrix);
 
   const PatternType m_PatternType;
   CPDF_Document* const m_pDocument;
   CPDF_Object* const m_pPatternObj;
   CFX_Matrix m_Pattern2Form;
-  CFX_Matrix m_ParentMatrix;
+  const CFX_Matrix m_ParentMatrix;
 };
 
 #endif  // CORE_FPDFAPI_FPDF_PAGE_CPDF_PATTERN_H_
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
index 457de96..b7174b4 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
@@ -25,7 +25,7 @@
 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
                                          CPDF_Object* pPatternObj,
                                          FX_BOOL bShading,
-                                         const CFX_Matrix* parentMatrix)
+                                         const CFX_Matrix& parentMatrix)
     : CPDF_Pattern(SHADING,
                    pDoc,
                    bShading ? nullptr : pPatternObj,
@@ -40,8 +40,7 @@
     CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
     m_Pattern2Form = pDict->GetMatrixBy("Matrix");
     m_pShadingObj = pDict->GetDirectObjectBy("Shading");
-    if (parentMatrix)
-      m_Pattern2Form.Concat(*parentMatrix);
+    m_Pattern2Form.Concat(parentMatrix);
   }
   for (size_t i = 0; i < FX_ArraySize(m_pFunctions); ++i)
     m_pFunctions[i] = nullptr;
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
index 7e5a24d..1872764 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
@@ -34,7 +34,7 @@
   CPDF_ShadingPattern(CPDF_Document* pDoc,
                       CPDF_Object* pPatternObj,
                       FX_BOOL bShading,
-                      const CFX_Matrix* parentMatrix);
+                      const CFX_Matrix& parentMatrix);
 
   ~CPDF_ShadingPattern() override;
 
diff --git a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
index 3ace570..0b1eeab 100644
--- a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
@@ -13,13 +13,12 @@
 
 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
                                        CPDF_Object* pPatternObj,
-                                       const CFX_Matrix* parentMatrix)
+                                       const CFX_Matrix& parentMatrix)
     : CPDF_Pattern(TILING, pDoc, pPatternObj, parentMatrix) {
   CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
   m_Pattern2Form = pDict->GetMatrixBy("Matrix");
   m_bColored = pDict->GetIntegerBy("PaintType") == 1;
-  if (parentMatrix)
-    m_Pattern2Form.Concat(*parentMatrix);
+  m_Pattern2Form.Concat(parentMatrix);
 }
 
 CPDF_TilingPattern::~CPDF_TilingPattern() {
diff --git a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
index 5936307..3e62810 100644
--- a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
@@ -21,7 +21,7 @@
  public:
   CPDF_TilingPattern(CPDF_Document* pDoc,
                      CPDF_Object* pPatternObj,
-                     const CFX_Matrix* parentMatrix);
+                     const CFX_Matrix& parentMatrix);
   ~CPDF_TilingPattern() override;
 
   CPDF_TilingPattern* AsTilingPattern() override { return this; }
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index dfc21b4..8287ea5 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -316,7 +316,7 @@
 
 CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
                                            FX_BOOL bShading,
-                                           const CFX_Matrix* matrix) {
+                                           const CFX_Matrix& matrix) {
   if (!pPatternObj)
     return nullptr;
 
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 1f10b4e..93ea93d 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -12,6 +12,7 @@
 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
 #include "core/fpdfapi/fpdf_page/cpdf_allstates.h"
+#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
 #include "core/fpdfapi/fpdf_page/include/cpdf_formobject.h"
@@ -33,6 +34,12 @@
 
 namespace {
 
+const int kSingleCoordinatePair = 1;
+const int kTensorCoordinatePairs = 16;
+const int kCoonsCoordinatePairs = 12;
+const int kSingleColorPerPatch = 1;
+const int kQuadColorsPerPatch = 4;
+
 const char kPathOperatorSubpath = 'm';
 const char kPathOperatorLine = 'l';
 const char kPathOperatorCubicBezier1 = 'c';
@@ -90,6 +97,64 @@
                              : CFX_ByteStringC();
 }
 
+CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
+                             ShadingType type,
+                             const CFX_Matrix& matrix,
+                             CPDF_Function** pFuncs,
+                             int nFuncs,
+                             CPDF_ColorSpace* pCS) {
+  if (!pStream || !pFuncs || !pCS)
+    return CFX_FloatRect(0, 0, 0, 0);
+
+  CPDF_MeshStream stream;
+  if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
+    return CFX_FloatRect(0, 0, 0, 0);
+
+  CFX_FloatRect rect;
+  bool bStarted = false;
+  bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
+                  type == kLatticeFormGouraudTriangleMeshShading;
+
+  int point_count = kSingleCoordinatePair;
+  if (type == kTensorProductPatchMeshShading)
+    point_count = kTensorCoordinatePairs;
+  else if (type == kCoonsPatchMeshShading)
+    point_count = kCoonsCoordinatePairs;
+
+  int color_count = kSingleColorPerPatch;
+  if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
+    color_count = kQuadColorsPerPatch;
+
+  while (!stream.m_BitStream.IsEOF()) {
+    uint32_t flag = 0;
+    if (type != kLatticeFormGouraudTriangleMeshShading)
+      flag = stream.GetFlag();
+
+    if (!bGouraud && flag) {
+      point_count -= 4;
+      color_count -= 2;
+    }
+
+    for (int i = 0; i < point_count; i++) {
+      FX_FLOAT x;
+      FX_FLOAT y;
+      stream.GetCoords(x, y);
+      if (bStarted) {
+        rect.UpdateRect(x, y);
+      } else {
+        rect.InitRect(x, y);
+        bStarted = true;
+      }
+    }
+    stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
+                                color_count);
+    if (bGouraud)
+      stream.m_BitStream.ByteAlign();
+  }
+  rect.Transform(&matrix);
+  return rect;
+}
+
 }  // namespace
 
 CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr) {
@@ -124,7 +189,7 @@
     CPDF_Document* pDocument,
     CPDF_Dictionary* pPageResources,
     CPDF_Dictionary* pParentResources,
-    CFX_Matrix* pmtContentToUser,
+    const CFX_Matrix* pmtContentToUser,
     CPDF_PageObjectHolder* pObjHolder,
     CPDF_Dictionary* pResources,
     CFX_FloatRect* pBBox,
@@ -985,7 +1050,7 @@
     }
   }
   if (nvalues != nargs) {
-    CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
+    CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
     if (pPattern) {
       m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
     }
@@ -1013,7 +1078,7 @@
     }
   }
   if (nvalues != nargs) {
-    CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
+    CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
     if (pPattern) {
       m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
     }
@@ -1023,15 +1088,8 @@
   FX_Free(values);
 }
 
-CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
-                             ShadingType type,
-                             const CFX_Matrix* pMatrix,
-                             CPDF_Function** pFuncs,
-                             int nFuncs,
-                             CPDF_ColorSpace* pCS);
-
 void CPDF_StreamContentParser::Handle_ShadeFill() {
-  CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
+  CPDF_Pattern* pPattern = FindPattern(GetString(0), true);
   if (!pPattern)
     return;
 
@@ -1051,7 +1109,7 @@
       pObj->m_ClipPath.IsNull() ? m_BBox : pObj->m_ClipPath.GetClipBox();
   if (pShading->IsMeshShading()) {
     bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj),
-                                  pShading->m_ShadingType, &pObj->m_Matrix,
+                                  pShading->m_ShadingType, pObj->m_Matrix,
                                   pShading->m_pFunctions, pShading->m_nFuncs,
                                   pShading->m_pCS));
   }
@@ -1164,15 +1222,15 @@
 }
 
 CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
-                                                    FX_BOOL bShading) {
+                                                    bool bShading) {
   CPDF_Object* pPattern =
       FindResourceObj(bShading ? "Shading" : "Pattern", name);
   if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) {
     m_bResourceMissing = TRUE;
-    return NULL;
+    return nullptr;
   }
   return m_pDocument->LoadPattern(pPattern, bShading,
-                                  &m_pCurStates->m_ParentMatrix);
+                                  m_pCurStates->m_ParentMatrix);
 }
 
 void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) {
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index dff4bb6..47c0336 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -664,7 +664,7 @@
 
 void CPDF_ContentParser::Start(CPDF_Form* pForm,
                                CPDF_AllStates* pGraphicStates,
-                               CFX_Matrix* pParentMatrix,
+                               const CFX_Matrix* pParentMatrix,
                                CPDF_Type3Char* pType3Char,
                                int level) {
   m_pType3Char = pType3Char;
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
deleted file mode 100644
index 68ac8c8..0000000
--- a/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfapi/fpdf_page/pageint.h"
-
-#include <algorithm>
-
-#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
-#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
-
-namespace {
-
-const int kSingleCoordinatePair = 1;
-const int kTensorCoordinatePairs = 16;
-const int kCoonsCoordinatePairs = 12;
-
-const int kSingleColorPerPatch = 1;
-const int kQuadColorsPerPatch = 4;
-
-}  // namespace
-
-
-
-CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
-                             ShadingType type,
-                             const CFX_Matrix* pMatrix,
-                             CPDF_Function** pFuncs,
-                             int nFuncs,
-                             CPDF_ColorSpace* pCS) {
-  if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
-    return CFX_FloatRect(0, 0, 0, 0);
-
-  CPDF_MeshStream stream;
-  if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
-    return CFX_FloatRect(0, 0, 0, 0);
-
-  CFX_FloatRect rect;
-  bool bStarted = false;
-  bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
-                  type == kLatticeFormGouraudTriangleMeshShading;
-
-  int point_count = kSingleCoordinatePair;
-  if (type == kTensorProductPatchMeshShading)
-    point_count = kTensorCoordinatePairs;
-  else if (type == kCoonsPatchMeshShading)
-    point_count = kCoonsCoordinatePairs;
-
-  int color_count = kSingleColorPerPatch;
-  if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
-    color_count = kQuadColorsPerPatch;
-
-  while (!stream.m_BitStream.IsEOF()) {
-    uint32_t flag = 0;
-    if (type != kLatticeFormGouraudTriangleMeshShading)
-      flag = stream.GetFlag();
-
-    if (!bGouraud && flag) {
-      point_count -= 4;
-      color_count -= 2;
-    }
-
-    for (int i = 0; i < point_count; i++) {
-      FX_FLOAT x, y;
-      stream.GetCoords(x, y);
-      if (bStarted) {
-        rect.UpdateRect(x, y);
-      } else {
-        rect.InitRect(x, y);
-        bStarted = TRUE;
-      }
-    }
-    stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
-                                color_count);
-    if (bGouraud)
-      stream.m_BitStream.ByteAlign();
-  }
-  rect.Transform(pMatrix);
-  return rect;
-}
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_form.h b/core/fpdfapi/fpdf_page/include/cpdf_form.h
index 542ab49..d36a976 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_form.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_form.h
@@ -25,17 +25,18 @@
 
   ~CPDF_Form();
 
-  void StartParse(CPDF_AllStates* pGraphicStates,
-                  CFX_Matrix* pParentMatrix,
-                  CPDF_Type3Char* pType3Char,
-                  int level = 0);
-
   void ParseContent(CPDF_AllStates* pGraphicStates,
-                    CFX_Matrix* pParentMatrix,
+                    const CFX_Matrix* pParentMatrix,
                     CPDF_Type3Char* pType3Char,
                     int level = 0);
 
   CPDF_Form* Clone() const;
+
+ private:
+  void StartParse(CPDF_AllStates* pGraphicStates,
+                  const CFX_Matrix* pParentMatrix,
+                  CPDF_Type3Char* pType3Char,
+                  int level = 0);
 };
 
 #endif  // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_FORM_H_
diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h
index 24ed226..2dcf2e2 100644
--- a/core/fpdfapi/fpdf_page/pageint.h
+++ b/core/fpdfapi/fpdf_page/pageint.h
@@ -105,7 +105,7 @@
   CPDF_StreamContentParser(CPDF_Document* pDoc,
                            CPDF_Dictionary* pPageResources,
                            CPDF_Dictionary* pParentResources,
-                           CFX_Matrix* pmtContentToUser,
+                           const CFX_Matrix* pmtContentToUser,
                            CPDF_PageObjectHolder* pObjectHolder,
                            CPDF_Dictionary* pResources,
                            CFX_FloatRect* pBBox,
@@ -157,7 +157,7 @@
   void RestoreStates(CPDF_AllStates* pState);
   CPDF_Font* FindFont(const CFX_ByteString& name);
   CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name);
-  CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL bShading);
+  CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading);
   CPDF_Object* FindResourceObj(const CFX_ByteStringC& type,
                                const CFX_ByteString& name);
 
@@ -288,7 +288,7 @@
   void Start(CPDF_Page* pPage);
   void Start(CPDF_Form* pForm,
              CPDF_AllStates* pGraphicStates,
-             CFX_Matrix* pParentMatrix,
+             const CFX_Matrix* pParentMatrix,
              CPDF_Type3Char* pType3Char,
              int level);
   void Continue(IFX_Pause* pPause);
@@ -330,7 +330,7 @@
   void ReleaseColorSpace(CPDF_Object* pColorSpace);
   CPDF_Pattern* GetPattern(CPDF_Object* pPatternObj,
                            FX_BOOL bShading,
-                           const CFX_Matrix* matrix);
+                           const CFX_Matrix& matrix);
   void ReleasePattern(CPDF_Object* pPatternObj);
   CPDF_Image* GetImage(CPDF_Object* pImageStream);
   void ReleaseImage(CPDF_Object* pImageStream);
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index c92e177..ead1ac0 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -753,7 +753,7 @@
 
 CPDF_Pattern* CPDF_Document::LoadPattern(CPDF_Object* pPatternObj,
                                          FX_BOOL bShading,
-                                         const CFX_Matrix* matrix) {
+                                         const CFX_Matrix& matrix) {
   return m_pDocPage->GetPattern(pPatternObj, bShading, matrix);
 }
 
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index 38c0fdd..687619b 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -70,7 +70,7 @@
 
   CPDF_Pattern* LoadPattern(CPDF_Object* pObj,
                             FX_BOOL bShading,
-                            const CFX_Matrix* matrix = NULL);
+                            const CFX_Matrix& matrix);
 
   CPDF_Image* LoadImageF(CPDF_Object* pObj);
   CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream);
diff --git a/pdfium.gyp b/pdfium.gyp
index 8b48e12..cefdcaa 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -410,7 +410,6 @@
         'core/fpdfapi/fpdf_page/fpdf_page_func.cpp',
         'core/fpdfapi/fpdf_page/fpdf_page_parser.cpp',
         'core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp',
-        'core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp',
         'core/fpdfapi/fpdf_page/include/cpdf_clippath.h',
         'core/fpdfapi/fpdf_page/include/cpdf_color.h',
         'core/fpdfapi/fpdf_page/include/cpdf_colorspace.h',