Pass FX_RECT by const-ref in rendering code.

Change-Id: I1232e6c61cbe696d90d87f461ebed0a7aea40893
Reviewed-on: https://pdfium-review.googlesource.com/29973
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 7dfa497..def2c2c 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -21,14 +21,14 @@
 
 bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
                                    CFX_RenderDevice* pDevice,
-                                   FX_RECT* pRect,
+                                   const FX_RECT& rect,
                                    const CPDF_PageObject* pObj,
                                    int max_dpi) {
   m_pDevice = pDevice;
   m_pContext = pContext;
-  m_Rect = *pRect;
+  m_Rect = rect;
   m_pObject = pObj;
-  m_Matrix.Translate(-pRect->left, -pRect->top);
+  m_Matrix.Translate(-rect.left, -rect.top);
 #if _FX_PLATFORM_ != _FX_PLATFORM_APPLE_
   int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
   int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
@@ -44,7 +44,7 @@
   }
 #endif
   FX_RECT bitmap_rect =
-      m_Matrix.TransformRect(CFX_FloatRect(*pRect)).GetOuterRect();
+      m_Matrix.TransformRect(CFX_FloatRect(rect)).GetOuterRect();
   m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
   m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb);
   return true;
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.h b/core/fpdfapi/render/cpdf_devicebuffer.h
index 854906e..d265b0c 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.h
+++ b/core/fpdfapi/render/cpdf_devicebuffer.h
@@ -25,7 +25,7 @@
 
   bool Initialize(CPDF_RenderContext* pContext,
                   CFX_RenderDevice* pDevice,
-                  FX_RECT* pRect,
+                  const FX_RECT& rect,
                   const CPDF_PageObject* pObj,
                   int max_dpi);
   void OutputToDevice();
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 2d66f9c..1f9e60d 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2035,7 +2035,7 @@
 
 void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
                                     CFX_Matrix* pMatrix,
-                                    FX_RECT& clip_rect,
+                                    const FX_RECT& clip_rect,
                                     int alpha,
                                     bool bAlphaMode) {
   const auto& funcs = pPattern->GetFuncs();
@@ -2060,17 +2060,19 @@
                               (int32_t)(B * 255));
     }
   }
+  FX_RECT clip_rect_bbox = clip_rect;
   if (pDict->KeyExist("BBox")) {
-    clip_rect.Intersect(
+    clip_rect_bbox.Intersect(
         pMatrix->TransformRect(pDict->GetRectFor("BBox")).GetOuterRect());
   }
   if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SHADING &&
-      m_pDevice->GetDeviceDriver()->DrawShading(pPattern, pMatrix, clip_rect,
-                                                alpha, bAlphaMode)) {
+      m_pDevice->GetDeviceDriver()->DrawShading(
+          pPattern, pMatrix, clip_rect_bbox, alpha, bAlphaMode)) {
     return;
   }
   CPDF_DeviceBuffer buffer;
-  buffer.Initialize(m_pContext.Get(), m_pDevice, &clip_rect, m_pCurObj, 150);
+  buffer.Initialize(m_pContext.Get(), m_pDevice, clip_rect_bbox, m_pCurObj,
+                    150);
   CFX_Matrix FinalMatrix = *pMatrix;
   FinalMatrix.Concat(*buffer.GetMatrix());
   RetainPtr<CFX_DIBitmap> pBitmap = buffer.GetBitmap();
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index 74d3567..6d5e680 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -123,7 +123,7 @@
                       const CFX_Matrix* pObj2Device);
   void DrawShading(const CPDF_ShadingPattern* pPattern,
                    CFX_Matrix* pMatrix,
-                   FX_RECT& clip_rect,
+                   const FX_RECT& clip_rect,
                    int alpha,
                    bool bAlphaMode);
   bool ProcessType3Text(CPDF_TextObject* textobj,