Pass CFX_Paths by const-ref rather than const-pointer. They aren't optional, so avoid any questions about nullness. -- fix some style issues while at it. Change-Id: I3ba9273ad6b091306af7b3f7ac670f76303dbd61 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86495 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index d19a424..d2aa2c7 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -493,7 +493,7 @@ uint32_t fill_color = ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha); m_pRenderStatus->GetRenderDevice()->DrawPath( - &path, nullptr, nullptr, fill_color, 0, + path, nullptr, nullptr, fill_color, 0, CFX_FillRenderOptions::WindingOptions()); return false; }
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp index 78ed8b2..7078c1a 100644 --- a/core/fpdfapi/render/cpdf_rendershading.cpp +++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -715,7 +715,7 @@ if (bNoPathSmooth) fill_options.aliased_path = true; pDevice->DrawPath( - &path, nullptr, nullptr, + path, nullptr, nullptr, ArgbEncode(alpha, div_colors[0].comp[0], div_colors[0].comp[1], div_colors[0].comp[2]), 0, fill_options);
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index ea0f3c7..d3d286d 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -428,7 +428,7 @@ return true; return m_pDevice->DrawPathWithBlend( - path_obj->path().GetObject(), &path_matrix, + *path_obj->path().GetObject(), &path_matrix, path_obj->m_GraphState.GetObject(), fill_argb, stroke_argb, GetFillOptionsForDrawPathWithBlend(options, path_obj, fill_type, stroke, m_pType3Char), @@ -524,13 +524,14 @@ continue; if (pPath->GetPoints().empty()) { - CFX_Path EmptyPath; - EmptyPath.AppendRect(-1, -1, 0, 0); - m_pDevice->SetClip_PathFill(&EmptyPath, nullptr, + CFX_Path empty_path; + empty_path.AppendRect(-1, -1, 0, 0); + m_pDevice->SetClip_PathFill(empty_path, nullptr, CFX_FillRenderOptions::WindingOptions()); } else { m_pDevice->SetClip_PathFill( - pPath, &mtObj2Device, CFX_FillRenderOptions(ClipPath.GetClipType(i))); + *pPath, &mtObj2Device, + CFX_FillRenderOptions(ClipPath.GetClipType(i))); } } @@ -558,7 +559,8 @@ CFX_FillRenderOptions fill_options(CFX_FillRenderOptions::WindingOptions()); if (m_Options.GetOptions().bNoTextSmooth) fill_options.aliased_path = true; - m_pDevice->SetClip_PathFill(pTextClippingPath.get(), nullptr, fill_options); + m_pDevice->SetClip_PathFill(*pTextClippingPath.get(), nullptr, + fill_options); pTextClippingPath.reset(); } } @@ -580,7 +582,7 @@ bool stroke) { CFX_Matrix path_matrix = path_obj->matrix() * mtObj2Device; if (stroke) { - return m_pDevice->SetClip_PathStroke(path_obj->path().GetObject(), + return m_pDevice->SetClip_PathStroke(*path_obj->path().GetObject(), &path_matrix, path_obj->m_GraphState.GetObject()); } @@ -588,8 +590,8 @@ if (m_Options.GetOptions().bNoPathSmooth) { fill_options.aliased_path = true; } - return m_pDevice->SetClip_PathFill(path_obj->path().GetObject(), &path_matrix, - fill_options); + return m_pDevice->SetClip_PathFill(*path_obj->path().GetObject(), + &path_matrix, fill_options); } bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index ca4d3a5..57a401d 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -520,6 +520,5 @@ if (pOptions && pOptions->GetOptions().bNoPathSmooth) fill_options.aliased_path = true; - pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, - fill_options); + pDevice->DrawPath(path, pUser2Device, &graph_state, argb, argb, fill_options); }
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 67a7106..11c49bb 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -966,10 +966,10 @@ // Note: BuildAggPath() has to take |agg_path| as an out-parameter. If it // returns the agg::path_storage instead, tests will fail with MSVC builds. -void BuildAggPath(const CFX_Path* pPath, +void BuildAggPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, - agg::path_storage& agg_path) { - pdfium::span<const CFX_Path::Point> points = pPath->GetPoints(); + agg::path_storage* agg_path) { + pdfium::span<const CFX_Path::Point> points = path.GetPoints(); for (size_t i = 0; i < points.size(); ++i) { CFX_PointF pos = points[i].m_Point; if (pObject2Device) @@ -978,7 +978,7 @@ pos = HardClip(pos); CFX_Path::Point::Type point_type = points[i].m_Type; if (point_type == CFX_Path::Point::Type::kMove) { - agg_path.move_to(pos.x, pos.y); + agg_path->move_to(pos.x, pos.y); } else if (point_type == CFX_Path::Point::Type::kLine) { if (i > 0 && points[i - 1].IsTypeAndOpen(CFX_Path::Point::Type::kMove) && (i == points.size() - 1 || @@ -986,7 +986,7 @@ points[i].m_Point == points[i - 1].m_Point) { pos.x += 1; } - agg_path.line_to(pos.x, pos.y); + agg_path->line_to(pos.x, pos.y); } else if (point_type == CFX_Path::Point::Type::kBezier) { if (i > 0 && i + 2 < points.size()) { CFX_PointF pos0 = points[i - 1].m_Point; @@ -1003,11 +1003,11 @@ agg::curve4 curve(pos0.x, pos0.y, pos.x, pos.y, pos2.x, pos2.y, pos3.x, pos3.y); i += 2; - agg_path.add_path_curve(curve); + agg_path->add_path_curve(curve); } } if (points[i].m_CloseFigure) - agg_path.end_poly(); + agg_path->end_poly(); } } @@ -1125,7 +1125,7 @@ } bool CFX_AggDeviceDriver::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) { DCHECK(fill_options.fill_type != CFX_FillRenderOptions::FillType::kNoFill); @@ -1135,7 +1135,7 @@ m_pClipRgn = std::make_unique<CFX_ClipRgn>( GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); } - absl::optional<CFX_FloatRect> maybe_rectf = pPath->GetRect(pObject2Device); + absl::optional<CFX_FloatRect> maybe_rectf = path.GetRect(pObject2Device); if (maybe_rectf.has_value()) { CFX_FloatRect& rectf = maybe_rectf.value(); rectf.Intersect( @@ -1146,7 +1146,7 @@ return true; } agg::path_storage path_data; - BuildAggPath(pPath, pObject2Device, path_data); + BuildAggPath(path, pObject2Device, &path_data); path_data.end_poly(); agg::rasterizer_scanline_aa rasterizer; rasterizer.clip_box(0.0f, 0.0f, @@ -1159,7 +1159,7 @@ } bool CFX_AggDeviceDriver::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { if (!m_pClipRgn) { @@ -1167,7 +1167,7 @@ GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); } agg::path_storage path_data; - BuildAggPath(pPath, nullptr, path_data); + BuildAggPath(path, nullptr, &path_data); agg::rasterizer_scanline_aa rasterizer; rasterizer.clip_box(0.0f, 0.0f, static_cast<float>(GetDeviceCaps(FXDC_PIXEL_WIDTH)), @@ -1196,7 +1196,7 @@ m_FillOptions.aliased_path); } -bool CFX_AggDeviceDriver::DrawPath(const CFX_Path* pPath, +bool CFX_AggDeviceDriver::DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -1213,7 +1213,7 @@ if (fill_options.fill_type != CFX_FillRenderOptions::FillType::kNoFill && fill_color) { agg::path_storage path_data; - BuildAggPath(pPath, pObject2Device, path_data); + BuildAggPath(path, pObject2Device, &path_data); agg::rasterizer_scanline_aa rasterizer; rasterizer.clip_box(0.0f, 0.0f, static_cast<float>(GetDeviceCaps(FXDC_PIXEL_WIDTH)), @@ -1229,7 +1229,7 @@ if (fill_options.zero_area) { agg::path_storage path_data; - BuildAggPath(pPath, pObject2Device, path_data); + BuildAggPath(path, pObject2Device, &path_data); agg::rasterizer_scanline_aa rasterizer; rasterizer.clip_box(0.0f, 0.0f, static_cast<float>(GetDeviceCaps(FXDC_PIXEL_WIDTH)), @@ -1253,7 +1253,7 @@ } agg::path_storage path_data; - BuildAggPath(pPath, &matrix1, path_data); + BuildAggPath(path, &matrix1, &path_data); agg::rasterizer_scanline_aa rasterizer; rasterizer.clip_box(0.0f, 0.0f, static_cast<float>(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 8fed4ec..51fe418 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h
@@ -42,13 +42,13 @@ int GetDeviceCaps(int caps_id) const override; void SaveState() override; void RestoreState(bool bKeepSaved) override; - bool SetClip_PathFill(const CFX_Path* pPath, + bool SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) override; - bool SetClip_PathStroke(const CFX_Path* pPath, + bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) override; - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/cfx_drawutils.cpp b/core/fxge/cfx_drawutils.cpp index fe37685..72c56bc 100644 --- a/core/fxge/cfx_drawutils.cpp +++ b/core/fxge/cfx_drawutils.cpp
@@ -35,7 +35,7 @@ graph_state_data.m_DashPhase = 0; graph_state_data.m_LineWidth = 1.0f; - render_device->DrawPath(&path, &user_to_device, &graph_state_data, 0, + render_device->DrawPath(path, &user_to_device, &graph_state_data, 0, ArgbEncode(255, 0, 0, 0), CFX_FillRenderOptions::EvenOddOptions()); }
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index a2a3c8a..7e4424e 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp
@@ -567,24 +567,23 @@ } bool CFX_RenderDevice::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) { - if (!m_pDeviceDriver->SetClip_PathFill(pPath, pObject2Device, fill_options)) { + if (!m_pDeviceDriver->SetClip_PathFill(path, pObject2Device, fill_options)) return false; - } + UpdateClipBox(); return true; } bool CFX_RenderDevice::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { - if (!m_pDeviceDriver->SetClip_PathStroke(pPath, pObject2Device, - pGraphState)) { + if (!m_pDeviceDriver->SetClip_PathStroke(path, pObject2Device, pGraphState)) return false; - } + UpdateClipBox(); return true; } @@ -592,8 +591,7 @@ bool CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { CFX_Path path; path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); - if (!SetClip_PathFill(&path, nullptr, - CFX_FillRenderOptions::WindingOptions())) + if (!SetClip_PathFill(path, nullptr, CFX_FillRenderOptions::WindingOptions())) return false; UpdateClipBox(); @@ -609,18 +607,18 @@ m_ClipBox.bottom = m_Height; } -bool CFX_RenderDevice::DrawPath(const CFX_Path* pPath, +bool CFX_RenderDevice::DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions& fill_options) { - return DrawPathWithBlend(pPath, pObject2Device, pGraphState, fill_color, + return DrawPathWithBlend(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options, BlendMode::kNormal); } bool CFX_RenderDevice::DrawPathWithBlend( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -631,7 +629,7 @@ fill_options.fill_type != CFX_FillRenderOptions::FillType::kNoFill; uint8_t fill_alpha = fill ? FXARGB_A(fill_color) : 0; uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; - pdfium::span<const CFX_Path::Point> points = pPath->GetPoints(); + pdfium::span<const CFX_Path::Point> points = path.GetPoints(); if (stroke_alpha == 0 && points.size() == 2) { CFX_PointF pos1 = points[0].m_Point; CFX_PointF pos2 = points[1].m_Point; @@ -644,7 +642,7 @@ } if (stroke_alpha == 0 && !fill_options.rect_aa) { - absl::optional<CFX_FloatRect> maybe_rect_f = pPath->GetRect(pObject2Device); + absl::optional<CFX_FloatRect> maybe_rect_f = path.GetRect(pObject2Device); if (maybe_rect_f.has_value()) { const CFX_FloatRect& rect_f = maybe_rect_f.value(); FX_RECT rect_i = rect_f.GetOuterRect(); @@ -726,21 +724,21 @@ if (fill && fill_alpha && stroke_alpha < 0xff && fill_options.stroke) { if (m_RenderCaps & FXRC_FILLSTROKE_PATH) { - return m_pDeviceDriver->DrawPath(pPath, pObject2Device, pGraphState, + return m_pDeviceDriver->DrawPath(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options, blend_type); } - return DrawFillStrokePath(pPath, pObject2Device, pGraphState, fill_color, + return DrawFillStrokePath(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options, blend_type); } - return m_pDeviceDriver->DrawPath(pPath, pObject2Device, pGraphState, + return m_pDeviceDriver->DrawPath(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options, blend_type); } // This can be removed once PDFium entirely relies on Skia bool CFX_RenderDevice::DrawFillStrokePath( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -751,10 +749,10 @@ return false; CFX_FloatRect bbox; if (pGraphState) { - bbox = pPath->GetBoundingBoxForStrokePath(pGraphState->m_LineWidth, - pGraphState->m_MiterLimit); + bbox = path.GetBoundingBoxForStrokePath(pGraphState->m_LineWidth, + pGraphState->m_MiterLimit); } else { - bbox = pPath->GetBoundingBox(); + bbox = path.GetBoundingBox(); } if (pObject2Device) bbox = pObject2Device->TransformRect(bbox); @@ -783,7 +781,7 @@ if (pObject2Device) matrix = *pObject2Device; matrix.Translate(-rect.left, -rect.top); - if (!bitmap_device.GetDeviceDriver()->DrawPath(pPath, &matrix, pGraphState, + if (!bitmap_device.GetDeviceDriver()->DrawPath(path, &matrix, pGraphState, fill_color, stroke_color, fill_options, blend_type)) { return false; @@ -835,7 +833,7 @@ CFX_Path path; path.AppendPoint(ptMoveTo, CFX_Path::Point::Type::kMove); path.AppendPoint(ptLineTo, CFX_Path::Point::Type::kLine); - return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, + return m_pDeviceDriver->DrawPath(path, nullptr, &graph_state, 0, color, fill_options, blend_type); } @@ -872,8 +870,8 @@ path_options.zero_area = true; path_options.aliased_path = aliased_path; - m_pDeviceDriver->DrawPath(&new_path, new_matrix, &graph_state, 0, - stroke_color, path_options, blend_type); + m_pDeviceDriver->DrawPath(new_path, new_matrix, &graph_state, 0, stroke_color, + path_options, blend_type); } bool CFX_RenderDevice::GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, @@ -1247,21 +1245,21 @@ matrix.Concat(mtText2User); - CFX_Path TransformedPath(*pPath); - TransformedPath.Transform(matrix); + CFX_Path transformed_path(*pPath); + transformed_path.Transform(matrix); if (fill_color || stroke_color) { CFX_FillRenderOptions options(fill_options); if (fill_color) options.fill_type = CFX_FillRenderOptions::FillType::kWinding; options.text_mode = true; - if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, + if (!DrawPathWithBlend(transformed_path, pUser2Device, pGraphState, fill_color, stroke_color, options, BlendMode::kNormal)) { return false; } } if (pClippingPath) - pClippingPath->Append(TransformedPath, pUser2Device); + pClippingPath->Append(transformed_path, pUser2Device); } return true; } @@ -1271,7 +1269,7 @@ const FX_COLORREF& color) { CFX_Path path; path.AppendFloatRect(rect); - DrawPath(&path, pUser2Device, nullptr, color, 0, + DrawPath(path, pUser2Device, nullptr, color, 0, CFX_FillRenderOptions::WindingOptions()); } @@ -1284,7 +1282,7 @@ for (size_t i = 1; i < points.size(); ++i) path.AppendPoint(points[i], CFX_Path::Point::Type::kLine); - DrawPath(&path, &mtUser2Device, nullptr, color, 0, + DrawPath(path, &mtUser2Device, nullptr, color, 0, CFX_FillRenderOptions::EvenOddOptions()); } @@ -1297,7 +1295,7 @@ CFX_Path path; path.AppendFloatRect(rect); - DrawPath(&path, &mtUser2Device, &gsd, 0, color, + DrawPath(path, &mtUser2Device, &gsd, 0, color, CFX_FillRenderOptions::EvenOddOptions()); } @@ -1313,7 +1311,7 @@ CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; - DrawPath(&path, pUser2Device, &gsd, 0, color, + DrawPath(path, pUser2Device, &gsd, 0, color, CFX_FillRenderOptions::EvenOddOptions()); } @@ -1390,7 +1388,7 @@ path.AppendRect(fLeft, fBottom, fRight, fTop); path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth); - DrawPath(&path, pUser2Device, nullptr, color.ToFXColor(nTransparency), 0, + DrawPath(path, pUser2Device, nullptr, color.ToFXColor(nTransparency), 0, CFX_FillRenderOptions::EvenOddOptions()); break; } @@ -1411,7 +1409,7 @@ CFX_Path::Point::Type::kLine); path.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth), CFX_Path::Point::Type::kLine); - DrawPath(&path, pUser2Device, &gsd, 0, color.ToFXColor(nTransparency), + DrawPath(path, pUser2Device, &gsd, 0, color.ToFXColor(nTransparency), CFX_FillRenderOptions::WindingOptions()); break; } @@ -1439,7 +1437,7 @@ path_left_top.AppendPoint( CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth), CFX_Path::Point::Type::kLine); - DrawPath(&path_left_top, pUser2Device, &gsd, + DrawPath(path_left_top, pUser2Device, &gsd, crLeftTop.ToFXColor(nTransparency), 0, CFX_FillRenderOptions::EvenOddOptions()); @@ -1464,7 +1462,7 @@ path_right_bottom.AppendPoint( CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth), CFX_Path::Point::Type::kLine); - DrawPath(&path_right_bottom, pUser2Device, &gsd, + DrawPath(path_right_bottom, pUser2Device, &gsd, crRightBottom.ToFXColor(nTransparency), 0, CFX_FillRenderOptions::EvenOddOptions()); @@ -1472,7 +1470,7 @@ path.AppendRect(fLeft, fBottom, fRight, fTop); path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth, fRight - fHalfWidth, fTop - fHalfWidth); - DrawPath(&path, pUser2Device, &gsd, color.ToFXColor(nTransparency), 0, + DrawPath(path, pUser2Device, &gsd, color.ToFXColor(nTransparency), 0, CFX_FillRenderOptions::EvenOddOptions()); break; } @@ -1485,7 +1483,7 @@ CFX_Path::Point::Type::kMove); path.AppendPoint(CFX_PointF(fRight, fBottom + fHalfWidth), CFX_Path::Point::Type::kLine); - DrawPath(&path, pUser2Device, &gsd, 0, color.ToFXColor(nTransparency), + DrawPath(path, pUser2Device, &gsd, 0, color.ToFXColor(nTransparency), CFX_FillRenderOptions::EvenOddOptions()); break; }
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 34afef5..44e0fdc 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h
@@ -72,20 +72,20 @@ int height) const; const FX_RECT& GetClipBox() const { return m_ClipBox; } void SetBaseClip(const FX_RECT& rect); - bool SetClip_PathFill(const CFX_Path* pPath, + bool SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options); - bool SetClip_PathStroke(const CFX_Path* pPath, + bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState); bool SetClip_Rect(const FX_RECT& pRect); - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions& fill_options); - bool DrawPathWithBlend(const CFX_Path* pPath, + bool DrawPathWithBlend(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -231,7 +231,7 @@ private: void InitDeviceInfo(); void UpdateClipBox(); - bool DrawFillStrokePath(const CFX_Path* pPath, + bool DrawFillStrokePath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/cfx_windowsrenderdevice_embeddertest.cpp b/core/fxge/cfx_windowsrenderdevice_embeddertest.cpp index c27e13d..f7c7fb1 100644 --- a/core/fxge/cfx_windowsrenderdevice_embeddertest.cpp +++ b/core/fxge/cfx_windowsrenderdevice_embeddertest.cpp
@@ -57,7 +57,7 @@ path_data.AppendLine(p3, p1); path_data.ClosePath(); EXPECT_TRUE(m_driver->SetClip_PathFill( - &path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); + path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); } TEST_F(CFX_WindowsRenderDeviceTest, SimpleClipRect) { @@ -66,7 +66,7 @@ path_data.AppendRect(0.0f, 100.0f, 200.0f, 0.0f); path_data.ClosePath(); EXPECT_TRUE(m_driver->SetClip_PathFill( - &path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); + path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); } TEST_F(CFX_WindowsRenderDeviceTest, GargantuanClipRect) { @@ -80,7 +80,7 @@ // however they do not because the GDI API IntersectClipRect() errors out and // affect subsequent imaging. crbug.com/1019026 EXPECT_FALSE(m_driver->SetClip_PathFill( - &path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); + path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); } TEST_F(CFX_WindowsRenderDeviceTest, GargantuanClipRectWithBaseClip) { @@ -94,5 +94,5 @@ // Use of a reasonable base clip ensures that we avoid getting an error back // from GDI API IntersectClipRect(). EXPECT_TRUE(m_driver->SetClip_PathFill( - &path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); + path_data, &kIdentityMatrix, CFX_FillRenderOptions::WindingOptions())); }
diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp index 436d70e..f8e695b 100644 --- a/core/fxge/renderdevicedriver_iface.cpp +++ b/core/fxge/renderdevicedriver_iface.cpp
@@ -13,7 +13,7 @@ RenderDeviceDriverIface::~RenderDeviceDriverIface() = default; bool RenderDeviceDriverIface::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { return false;
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h index cc1fc61..1350487 100644 --- a/core/fxge/renderdevicedriver_iface.h +++ b/core/fxge/renderdevicedriver_iface.h
@@ -45,13 +45,13 @@ virtual void RestoreState(bool bKeepSaved) = 0; virtual void SetBaseClip(const FX_RECT& rect); - virtual bool SetClip_PathFill(const CFX_Path* pPath, + virtual bool SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) = 0; - virtual bool SetClip_PathStroke(const CFX_Path* pPath, + virtual bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState); - virtual bool DrawPath(const CFX_Path* pPath, + virtual bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 5d0567c..d270a56 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp
@@ -327,9 +327,9 @@ fill == SkPathFillType::kInverseEvenOdd; } -SkPath BuildPath(const CFX_Path* pPath) { +SkPath BuildPath(const CFX_Path& path) { SkPath sk_path; - pdfium::span<const CFX_Path::Point> points = pPath->GetPoints(); + pdfium::span<const CFX_Path::Point> points = path.GetPoints(); for (size_t i = 0; i < points.size(); ++i) { const CFX_PointF& point = points[i].m_Point; CFX_Path::Point::Type point_type = points[i].m_Type; @@ -752,7 +752,7 @@ // mark all cached state as uninitialized explicit SkiaState(CFX_SkiaDeviceDriver* pDriver) : m_pDriver(pDriver) {} - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_GraphStateData* pDrawState, uint32_t fill_color, @@ -788,7 +788,7 @@ m_drawIndex = m_commandIndex; m_type = Accumulator::kPath; } - SkPath skPath = BuildPath(pPath); + SkPath skPath = BuildPath(path); SkPoint delta; if (MatrixOffset(pMatrix, &delta)) skPath.offset(delta.fX, delta.fY); @@ -1050,15 +1050,15 @@ bool IsEmpty() const { return !m_commands.count(); } - bool SetClipFill(const CFX_Path* pPath, + bool SetClipFill(const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_FillRenderOptions& fill_options) { if (m_debugDisable) return false; Dump(__func__); SkPath skClipPath; - if (pPath->GetPoints().size() == 5 || pPath->GetPoints().size() == 4) { - absl::optional<CFX_FloatRect> maybe_rectf = pPath->GetRect(pMatrix); + if (path.GetPoints().size() == 5 || path.GetPoints().size() == 4) { + absl::optional<CFX_FloatRect> maybe_rectf = path.GetRect(pMatrix); if (maybe_rectf.has_value()) { CFX_FloatRect& rectf = maybe_rectf.value(); rectf.Intersect(CFX_FloatRect( @@ -1072,7 +1072,7 @@ } } if (skClipPath.isEmpty()) { - skClipPath = BuildPath(pPath); + skClipPath = BuildPath(path); skClipPath.setFillType(GetAlternateOrWindingFillType(fill_options)); SkMatrix skMatrix = ToSkMatrix(*pMatrix); skClipPath.transform(skMatrix); @@ -1108,13 +1108,13 @@ return true; } - bool SetClipStroke(const CFX_Path* pPath, + bool SetClipStroke(const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_GraphStateData* pGraphState) { if (m_debugDisable) return false; Dump(__func__); - SkPath skPath = BuildPath(pPath); + SkPath skPath = BuildPath(path); SkMatrix skMatrix = ToSkMatrix(*pMatrix); SkPaint skPaint; m_pDriver->PaintStroke(&skPaint, pGraphState, skMatrix); @@ -1980,21 +1980,21 @@ #endif // defined(_SKIA_SUPPORT_PATHS_) bool CFX_SkiaDeviceDriver::SetClip_PathFill( - const CFX_Path* pPath, // path info + const CFX_Path& path, // path info const CFX_Matrix* pObject2Device, // flips object's y-axis const CFX_FillRenderOptions& fill_options) { m_FillOptions = fill_options; CFX_Matrix identity; const CFX_Matrix* deviceMatrix = pObject2Device ? pObject2Device : &identity; - bool cached = m_pCache->SetClipFill(pPath, deviceMatrix, fill_options); + bool cached = m_pCache->SetClipFill(path, deviceMatrix, fill_options); #if defined(_SKIA_SUPPORT_PATHS_) if (!m_pClipRgn) { m_pClipRgn = std::make_unique<CFX_ClipRgn>( GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); } #endif - if (pPath->GetPoints().size() == 5 || pPath->GetPoints().size() == 4) { - absl::optional<CFX_FloatRect> maybe_rectf = pPath->GetRect(deviceMatrix); + if (path.GetPoints().size() == 5 || path.GetPoints().size() == 4) { + absl::optional<CFX_FloatRect> maybe_rectf = path.GetRect(deviceMatrix); if (maybe_rectf.has_value()) { CFX_FloatRect& rectf = maybe_rectf.value(); rectf.Intersect(CFX_FloatRect(0, 0, @@ -2016,7 +2016,7 @@ return true; } } - SkPath skClipPath = BuildPath(pPath); + SkPath skClipPath = BuildPath(path); skClipPath.setFillType(GetAlternateOrWindingFillType(fill_options)); SkMatrix skMatrix = ToSkMatrix(*deviceMatrix); skClipPath.transform(skMatrix); @@ -2035,11 +2035,11 @@ } bool CFX_SkiaDeviceDriver::SetClip_PathStroke( - const CFX_Path* pPath, // path info + const CFX_Path& path, // path info const CFX_Matrix* pObject2Device, // required transformation const CFX_GraphStateData* pGraphState // graphic state, for pen attributes ) { - bool cached = m_pCache->SetClipStroke(pPath, pObject2Device, pGraphState); + bool cached = m_pCache->SetClipStroke(path, pObject2Device, pGraphState); #if defined(_SKIA_SUPPORT_PATHS_) if (!m_pClipRgn) { @@ -2048,7 +2048,7 @@ } #endif // build path data - SkPath skPath = BuildPath(pPath); + SkPath skPath = BuildPath(path); SkMatrix skMatrix = ToSkMatrix(*pObject2Device); SkPaint skPaint; PaintStroke(&skPaint, pGraphState, skMatrix); @@ -2069,7 +2069,7 @@ } bool CFX_SkiaDeviceDriver::DrawPath( - const CFX_Path* pPath, // path info + const CFX_Path& path, // path info const CFX_Matrix* pObject2Device, // optional transformation const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes uint32_t fill_color, // fill color @@ -2077,7 +2077,7 @@ const CFX_FillRenderOptions& fill_options, BlendMode blend_type) { m_FillOptions = fill_options; - if (m_pCache->DrawPath(pPath, pObject2Device, pGraphState, fill_color, + if (m_pCache->DrawPath(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options, blend_type)) { return true; } @@ -2094,7 +2094,7 @@ bool is_paint_stroke = pGraphState && stroke_alpha; if (is_paint_stroke) PaintStroke(&skPaint, pGraphState, skMatrix); - SkPath skPath = BuildPath(pPath); + SkPath skPath = BuildPath(path); SkAutoCanvasRestore scoped_save_restore(m_pCanvas, /*doSave=*/true); m_pCanvas->concat(skMatrix); bool do_stroke = true;
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index e44aa42..34be146 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h
@@ -46,21 +46,21 @@ /** Set clipping path using filled region */ bool SetClip_PathFill( - const CFX_Path* pPath, // path info + const CFX_Path& path, // path info const CFX_Matrix* pObject2Device, // optional transformation const CFX_FillRenderOptions& fill_options) // fill options override; /** Set clipping path using stroked region */ bool SetClip_PathStroke( - const CFX_Path* pPath, // path info + const CFX_Path& path, // path info const CFX_Matrix* pObject2Device, // required transformation const CFX_GraphStateData* pGraphState) // graphic state, for pen attributes override; /** Draw a path */ - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp index 4c58d29..7c3c256 100644 --- a/core/fxge/skia/fx_skia_device_embeddertest.cpp +++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -64,9 +64,9 @@ if (state.m_save == State::Save::kYes) driver->SaveState(); if (state.m_clip != State::Clip::kNo) - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); if (state.m_graphic == State::Graphic::kPath) { - driver->DrawPath(&path1, &matrix, &graphState, 0xFF112233, 0, + driver->DrawPath(path1, &matrix, &graphState, 0xFF112233, 0, CFX_FillRenderOptions::WindingOptions(), BlendMode::kNormal); } else if (state.m_graphic == State::Graphic::kText) { @@ -84,13 +84,13 @@ fontSize = 2; } if (state.m_clip == State::Clip::kSame) - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); else if (state.m_clip == State::Clip::kDifferentPath) - driver->SetClip_PathFill(&clipPath2, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath2, &clipMatrix, CFX_FillRenderOptions()); else if (state.m_clip == State::Clip::kDifferentMatrix) - driver->SetClip_PathFill(&clipPath, &clipMatrix2, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix2, CFX_FillRenderOptions()); if (state.m_graphic == State::Graphic::kPath) { - driver->DrawPath(&path2, &matrix2, &graphState, 0xFF112233, 0, + driver->DrawPath(path2, &matrix2, &graphState, 0xFF112233, 0, CFX_FillRenderOptions::WindingOptions(), BlendMode::kNormal); } else if (state.m_graphic == State::Graphic::kText) { @@ -107,18 +107,18 @@ clipPath.AppendRect(1, 0, 3, 1); CFX_Matrix clipMatrix; driver->SaveState(); - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); driver->RestoreState(true); driver->SaveState(); - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); driver->RestoreState(false); driver->RestoreState(false); driver->SaveState(); driver->SaveState(); - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); driver->RestoreState(true); - driver->SetClip_PathFill(&clipPath, &clipMatrix, CFX_FillRenderOptions()); + driver->SetClip_PathFill(clipPath, &clipMatrix, CFX_FillRenderOptions()); driver->RestoreState(false); driver->RestoreState(false); }
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 0d74d21..b358cab 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -285,15 +285,15 @@ m_ClipBoxStack.pop_back(); } -void CFX_PSRenderer::OutputPath(const CFX_Path* pPath, +void CFX_PSRenderer::OutputPath(const CFX_Path& path, const CFX_Matrix* pObject2Device) { std::ostringstream buf; - size_t size = pPath->GetPoints().size(); + size_t size = path.GetPoints().size(); for (size_t i = 0; i < size; i++) { - CFX_Path::Point::Type type = pPath->GetType(i); - bool closing = pPath->IsClosingFigure(i); - CFX_PointF pos = pPath->GetPoint(i); + CFX_Path::Point::Type type = path.GetType(i); + bool closing = path.IsClosingFigure(i); + CFX_PointF pos = path.GetPoint(i); if (pObject2Device) pos = pObject2Device->Transform(pos); @@ -308,8 +308,8 @@ buf << "h "; break; case CFX_Path::Point::Type::kBezier: { - CFX_PointF pos1 = pPath->GetPoint(i + 1); - CFX_PointF pos2 = pPath->GetPoint(i + 2); + CFX_PointF pos1 = path.GetPoint(i + 1); + CFX_PointF pos2 = path.GetPoint(i + 2); if (pObject2Device) { pos1 = pObject2Device->Transform(pos1); pos2 = pObject2Device->Transform(pos2); @@ -328,12 +328,12 @@ } void CFX_PSRenderer::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) { StartRendering(); - OutputPath(pPath, pObject2Device); - CFX_FloatRect rect = pPath->GetBoundingBox(); + OutputPath(path, pObject2Device); + CFX_FloatRect rect = path.GetBoundingBox(); if (pObject2Device) rect = pObject2Device->TransformRect(rect); @@ -348,7 +348,7 @@ WriteString(" n\n"); } -void CFX_PSRenderer::SetClip_PathStroke(const CFX_Path* pPath, +void CFX_PSRenderer::SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { StartRendering(); @@ -360,15 +360,15 @@ << pObject2Device->e << " " << pObject2Device->f << "]cm "; WriteStream(buf); - OutputPath(pPath, nullptr); - CFX_FloatRect rect = pPath->GetBoundingBoxForStrokePath( + OutputPath(path, nullptr); + CFX_FloatRect rect = path.GetBoundingBoxForStrokePath( pGraphState->m_LineWidth, pGraphState->m_MiterLimit); m_ClipBox.Intersect(pObject2Device->TransformRect(rect).GetOuterRect()); WriteString("strokepath W n sm\n"); } -bool CFX_PSRenderer::DrawPath(const CFX_Path* pPath, +bool CFX_PSRenderer::DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -395,7 +395,7 @@ } } - OutputPath(pPath, stroke_alpha ? nullptr : pObject2Device); + OutputPath(path, stroke_alpha ? nullptr : pObject2Device); if (fill_options.fill_type != CFX_FillRenderOptions::FillType::kNoFill && fill_alpha) { SetColor(fill_color);
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index beba00c..4271ea4 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h
@@ -73,14 +73,14 @@ int height); void SaveState(); void RestoreState(bool bKeepSaved); - void SetClip_PathFill(const CFX_Path* pPath, + void SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options); - void SetClip_PathStroke(const CFX_Path* pPath, + void SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState); FX_RECT GetClipBox() { return m_ClipBox; } - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -123,7 +123,7 @@ void StartRendering(); void EndRendering(); - void OutputPath(const CFX_Path* pPath, const CFX_Matrix* pObject2Device); + void OutputPath(const CFX_Path& path, const CFX_Matrix* pObject2Device); void SetGraphState(const CFX_GraphStateData* pGraphState); void SetColor(uint32_t color); void FindPSFontGlyph(CFX_GlyphCache* pGlyphCache,
diff --git a/core/fxge/win32/cgdi_device_driver.cpp b/core/fxge/win32/cgdi_device_driver.cpp index a8b8382..1989eda 100644 --- a/core/fxge/win32/cgdi_device_driver.cpp +++ b/core/fxge/win32/cgdi_device_driver.cpp
@@ -107,10 +107,10 @@ return CreateSolidBrush(ArgbToColorRef(argb)); } -void SetPathToDC(HDC hDC, const CFX_Path* pPath, const CFX_Matrix* pMatrix) { +void SetPathToDC(HDC hDC, const CFX_Path& path, const CFX_Matrix* pMatrix) { BeginPath(hDC); - pdfium::span<const CFX_Path::Point> points = pPath->GetPoints(); + pdfium::span<const CFX_Path::Point> points = path.GetPoints(); for (size_t i = 0; i < points.size(); ++i) { CFX_PointF pos = points[i].m_Point; if (pMatrix) @@ -538,7 +538,7 @@ LineTo(m_hDC, FXSYS_roundf(x2), FXSYS_roundf(y2)); } -bool CGdiDeviceDriver::DrawPath(const CFX_Path* pPath, +bool CGdiDeviceDriver::DrawPath(const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_GraphStateData* pGraphState, uint32_t fill_color, @@ -552,7 +552,7 @@ static_cast<CWin32Platform*>(CFX_GEModule::Get()->GetPlatform()); if (!(pGraphState || stroke_color == 0) && !pPlatform->m_GdiplusExt.IsAvailable()) { - CFX_FloatRect bbox_f = pPath->GetBoundingBox(); + CFX_FloatRect bbox_f = path.GetBoundingBox(); if (pMatrix) bbox_f = pMatrix->TransformRect(bbox_f); @@ -580,8 +580,8 @@ ((m_DeviceType != DeviceType::kPrinter && !fill_options.full_cover) || (pGraphState && !pGraphState->m_DashArray.empty()))) { if (!((!pMatrix || !pMatrix->WillScale()) && pGraphState && - pGraphState->m_LineWidth == 1.0f && pPath->IsRect())) { - if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPath, pMatrix, pGraphState, + pGraphState->m_LineWidth == 1.0f && path.IsRect())) { + if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, path, pMatrix, pGraphState, fill_color, stroke_color, fill_options)) { return true; @@ -603,24 +603,24 @@ hBrush = CreateBrush(fill_color); hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); } - if (pPath->GetPoints().size() == 2 && pGraphState && + if (path.GetPoints().size() == 2 && pGraphState && !pGraphState->m_DashArray.empty()) { - CFX_PointF pos1 = pPath->GetPoint(0); - CFX_PointF pos2 = pPath->GetPoint(1); + CFX_PointF pos1 = path.GetPoint(0); + CFX_PointF pos2 = path.GetPoint(1); if (pMatrix) { pos1 = pMatrix->Transform(pos1); pos2 = pMatrix->Transform(pos2); } DrawLine(pos1.x, pos1.y, pos2.x, pos2.y); } else { - SetPathToDC(m_hDC, pPath, pMatrix); + SetPathToDC(m_hDC, path, pMatrix); if (pGraphState && stroke_alpha) { if (fill && fill_alpha) { if (fill_options.text_mode) { StrokeAndFillPath(m_hDC); } else { FillPath(m_hDC); - SetPathToDC(m_hDC, pPath, pMatrix); + SetPathToDC(m_hDC, path, pMatrix); StrokePath(m_hDC); } } else { @@ -668,10 +668,10 @@ } bool CGdiDeviceDriver::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_FillRenderOptions& fill_options) { - absl::optional<CFX_FloatRect> maybe_rectf = pPath->GetRect(pMatrix); + absl::optional<CFX_FloatRect> maybe_rectf = path.GetRect(pMatrix); if (maybe_rectf.has_value()) { FX_RECT rect = maybe_rectf.value().GetOuterRect(); // Can easily apply base clip to protect against wildly large rectangular @@ -681,19 +681,19 @@ return IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.bottom) != ERROR; } - SetPathToDC(m_hDC, pPath, pMatrix); + SetPathToDC(m_hDC, path, pMatrix); SetPolyFillMode(m_hDC, FillTypeToGdiFillType(fill_options.fill_type)); SelectClipPath(m_hDC, RGN_AND); return true; } bool CGdiDeviceDriver::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pMatrix, const CFX_GraphStateData* pGraphState) { HPEN hPen = CreateExtPen(pGraphState, pMatrix, 0xff000000); hPen = (HPEN)SelectObject(m_hDC, hPen); - SetPathToDC(m_hDC, pPath, pMatrix); + SetPathToDC(m_hDC, path, pMatrix); WidenPath(m_hDC); SetPolyFillMode(m_hDC, WINDING); bool ret = !!SelectClipPath(m_hDC, RGN_AND);
diff --git a/core/fxge/win32/cgdi_device_driver.h b/core/fxge/win32/cgdi_device_driver.h index 4aec6f9..20a8e55 100644 --- a/core/fxge/win32/cgdi_device_driver.h +++ b/core/fxge/win32/cgdi_device_driver.h
@@ -24,13 +24,13 @@ void SaveState() override; void RestoreState(bool bKeepSaved) override; void SetBaseClip(const FX_RECT& rect) override; - bool SetClip_PathFill(const CFX_Path* pPath, + bool SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) override; - bool SetClip_PathStroke(const CFX_Path* pPath, + bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) override; - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/win32/cgdi_plus_ext.cpp b/core/fxge/win32/cgdi_plus_ext.cpp index 601d8ab..693f1f2 100644 --- a/core/fxge/win32/cgdi_plus_ext.cpp +++ b/core/fxge/win32/cgdi_plus_ext.cpp
@@ -597,13 +597,13 @@ } bool CGdiplusExt::DrawPath(HDC hDC, - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_argb, uint32_t stroke_argb, const CFX_FillRenderOptions& fill_options) { - pdfium::span<const CFX_Path::Point> points = pPath->GetPoints(); + pdfium::span<const CFX_Path::Point> points = path.GetPoints(); if (points.empty()) return true;
diff --git a/core/fxge/win32/cgdi_plus_ext.h b/core/fxge/win32/cgdi_plus_ext.h index bcb4358..458cb1d 100644 --- a/core/fxge/win32/cgdi_plus_ext.h +++ b/core/fxge/win32/cgdi_plus_ext.h
@@ -38,7 +38,7 @@ const FX_RECT* pClipRect, const FXDIB_ResampleOptions& options); bool DrawPath(HDC hDC, - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_argb,
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp index ab6fe06..e7ff871 100644 --- a/core/fxge/win32/cps_printer_driver.cpp +++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -80,7 +80,7 @@ static_cast<float>(pRect->right), static_cast<float>(pRect->top)); } - m_PSRenderer.SetClip_PathFill(&path, nullptr, + m_PSRenderer.SetClip_PathFill(path, nullptr, CFX_FillRenderOptions::WindingOptions()); } } @@ -123,22 +123,22 @@ } bool CPSPrinterDriver::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) { - m_PSRenderer.SetClip_PathFill(pPath, pObject2Device, fill_options); + m_PSRenderer.SetClip_PathFill(path, pObject2Device, fill_options); return true; } bool CPSPrinterDriver::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { - m_PSRenderer.SetClip_PathStroke(pPath, pObject2Device, pGraphState); + m_PSRenderer.SetClip_PathStroke(path, pObject2Device, pGraphState); return true; } -bool CPSPrinterDriver::DrawPath(const CFX_Path* pPath, +bool CPSPrinterDriver::DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, FX_ARGB fill_color, @@ -147,7 +147,7 @@ BlendMode blend_type) { if (blend_type != BlendMode::kNormal) return false; - return m_PSRenderer.DrawPath(pPath, pObject2Device, pGraphState, fill_color, + return m_PSRenderer.DrawPath(path, pObject2Device, pGraphState, fill_color, stroke_color, fill_options); }
diff --git a/core/fxge/win32/cps_printer_driver.h b/core/fxge/win32/cps_printer_driver.h index f3654eb..a7b90fb 100644 --- a/core/fxge/win32/cps_printer_driver.h +++ b/core/fxge/win32/cps_printer_driver.h
@@ -31,13 +31,13 @@ int GetDeviceCaps(int caps_id) const override; void SaveState() override; void RestoreState(bool bKeepSaved) override; - bool SetClip_PathFill(const CFX_Path* pPath, + bool SetClip_PathFill(const CFX_Path& paath, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) override; - bool SetClip_PathStroke(const CFX_Path* pPath, + bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) override; - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/win32/ctext_only_printer_driver.cpp b/core/fxge/win32/ctext_only_printer_driver.cpp index 20ca4ef..4950f17 100644 --- a/core/fxge/win32/ctext_only_printer_driver.cpp +++ b/core/fxge/win32/ctext_only_printer_driver.cpp
@@ -55,21 +55,25 @@ } } +void CTextOnlyPrinterDriver::SaveState() {} + +void CTextOnlyPrinterDriver::RestoreState(bool bKeepSaved) {} + bool CTextOnlyPrinterDriver::SetClip_PathFill( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) { return true; } bool CTextOnlyPrinterDriver::SetClip_PathStroke( - const CFX_Path* pPath, + const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) { return false; } -bool CTextOnlyPrinterDriver::DrawPath(const CFX_Path* pPath, +bool CTextOnlyPrinterDriver::DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/core/fxge/win32/ctext_only_printer_driver.h b/core/fxge/win32/ctext_only_printer_driver.h index 0d2eba0..b3a2be8 100644 --- a/core/fxge/win32/ctext_only_printer_driver.h +++ b/core/fxge/win32/ctext_only_printer_driver.h
@@ -20,15 +20,15 @@ // RenderDeviceDriverIface: DeviceType GetDeviceType() const override; int GetDeviceCaps(int caps_id) const override; - void SaveState() override {} - void RestoreState(bool bKeepSaved) override {} - bool SetClip_PathFill(const CFX_Path* pPath, + void SaveState() override; + void RestoreState(bool bKeepSaved) override; + bool SetClip_PathFill(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_FillRenderOptions& fill_options) override; - bool SetClip_PathStroke(const CFX_Path* pPath, + bool SetClip_PathStroke(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState) override; - bool DrawPath(const CFX_Path* pPath, + bool DrawPath(const CFX_Path& path, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, uint32_t fill_color,
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index b1c1b62..964e636 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -681,7 +681,7 @@ CFX_Path path; path.AppendFloatRect(GetRect()); - pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0, 0xFFAAAAAA, + pDevice->DrawPath(path, &mtUser2Device, &gsd, 0, 0xFFAAAAAA, CFX_FillRenderOptions::EvenOddOptions()); } else { CPDFSDK_BAAnnot::DrawAppearance(pDevice, mtUser2Device, mode, pOptions);
diff --git a/fpdfsdk/pwl/cpwl_caret.cpp b/fpdfsdk/pwl/cpwl_caret.cpp index efc7404..295d261 100644 --- a/fpdfsdk/pwl/cpwl_caret.cpp +++ b/fpdfsdk/pwl/cpwl_caret.cpp
@@ -49,7 +49,7 @@ CFX_GraphStateData gsd; gsd.m_LineWidth = m_fWidth; - pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0), + pDevice->DrawPath(path, &mtUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0), CFX_FillRenderOptions::EvenOddOptions()); }
diff --git a/fpdfsdk/pwl/cpwl_cbbutton.cpp b/fpdfsdk/pwl/cpwl_cbbutton.cpp index a4d94a7..e78d0f2 100644 --- a/fpdfsdk/pwl/cpwl_cbbutton.cpp +++ b/fpdfsdk/pwl/cpwl_cbbutton.cpp
@@ -53,7 +53,7 @@ path.AppendPoint(pt3, CFX_Path::Point::Type::kLine); path.AppendPoint(pt1, CFX_Path::Point::Type::kLine); - pDevice->DrawPath(&path, &mtUser2Device, nullptr, + pDevice->DrawPath(path, &mtUser2Device, nullptr, kDefaultBlackColor.ToFXColor(GetTransparency()), 0, CFX_FillRenderOptions::EvenOddOptions()); }
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp index 72d3cae..7e503a3 100644 --- a/fpdfsdk/pwl/cpwl_edit.cpp +++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -198,7 +198,7 @@ path.AppendPoint(top, CFX_Path::Point::Type::kLine); } if (!path.GetPoints().empty()) { - pDevice->DrawPath(&path, &mtUser2Device, &gsd, 0, + pDevice->DrawPath(path, &mtUser2Device, &gsd, 0, GetBorderColor().ToFXColor(255), CFX_FillRenderOptions::EvenOddOptions()); }
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp index a1a82ee..7e98a39 100644 --- a/fpdfsdk/pwl/cpwl_edit_impl.cpp +++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -645,7 +645,7 @@ word.ptWord.x + word.fWidth, line.ptLine.y + line.fLineAscent); - pDevice->DrawPath(&pathSelBK, &mtUser2Device, nullptr, crSelBK, 0, + pDevice->DrawPath(pathSelBK, &mtUser2Device, nullptr, crSelBK, 0, CFX_FillRenderOptions::WindingOptions()); } }
diff --git a/fxbarcode/BC_TwoDimWriter.cpp b/fxbarcode/BC_TwoDimWriter.cpp index c3647d9..ec5b985 100644 --- a/fxbarcode/BC_TwoDimWriter.cpp +++ b/fxbarcode/BC_TwoDimWriter.cpp
@@ -91,7 +91,7 @@ CFX_GraphStateData stateData; CFX_Path path; path.AppendRect(0, 0, m_Width, m_Height); - device->DrawPath(&path, &matrix, &stateData, kBackgroundColor, + device->DrawPath(path, &matrix, &stateData, kBackgroundColor, kBackgroundColor, CFX_FillRenderOptions::EvenOddOptions()); int32_t leftPos = m_leftPadding; int32_t topPos = m_topPadding; @@ -121,7 +121,7 @@ topPos + start_y_output * m_multiY, leftPos + end_x_output * m_multiX, topPos + end_y_output * m_multiY); - device->DrawPath(&rect, &matri, &data, kBarColor, 0, + device->DrawPath(rect, &matri, &data, kBarColor, 0, CFX_FillRenderOptions::WindingOptions()); } }
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp index a76467c..6b5b82a 100644 --- a/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -254,14 +254,14 @@ CFX_Path path; path.AppendRect(0, 0, static_cast<float>(m_Width), static_cast<float>(m_Height)); - device->DrawPath(&path, &matrix, &stateData, kBackgroundColor, + device->DrawPath(path, &matrix, &stateData, kBackgroundColor, kBackgroundColor, CFX_FillRenderOptions::EvenOddOptions()); CFX_Matrix scaledMatrix(m_outputHScale, 0.0, 0.0, static_cast<float>(m_Height), 0.0, 0.0); scaledMatrix.Concat(matrix); for (const auto& rect : m_output) { CFX_GraphStateData data; - device->DrawPath(&rect, &scaledMatrix, &data, kBarColor, 0, + device->DrawPath(rect, &scaledMatrix, &data, kBarColor, 0, CFX_FillRenderOptions::WindingOptions()); }
diff --git a/xfa/fgas/graphics/cfgas_gegraphics.cpp b/xfa/fgas/graphics/cfgas_gegraphics.cpp index 7efda45..2e17570 100644 --- a/xfa/fgas/graphics/cfgas_gegraphics.cpp +++ b/xfa/fgas/graphics/cfgas_gegraphics.cpp
@@ -258,7 +258,7 @@ mask->Create(data.width, data.height, FXDIB_Format::k1bppMask); memcpy(mask->GetBuffer(), data.maskBits, mask->GetPitch() * data.height); const CFX_FloatRect rectf = - matrix.TransformRect(path.GetPath()->GetBoundingBox()); + matrix.TransformRect(path.GetPath().GetBoundingBox()); const FX_RECT rect = rectf.ToRoundedFxRect(); CFX_DefaultRenderDevice device;
diff --git a/xfa/fgas/graphics/cfgas_gepath.h b/xfa/fgas/graphics/cfgas_gepath.h index 47893c5..7506f99 100644 --- a/xfa/fgas/graphics/cfgas_gepath.h +++ b/xfa/fgas/graphics/cfgas_gepath.h
@@ -15,7 +15,7 @@ CFGAS_GEPath(); ~CFGAS_GEPath(); - const CFX_Path* GetPath() const { return &path_; } + const CFX_Path& GetPath() const { return path_; } void Clear(); bool IsEmpty() const { return path_.GetPoints().empty(); }
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 95df80e..aa757c3 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -127,7 +127,7 @@ CFX_RenderDevice::StateRestorer restorer(pRenderDevice); CFX_Path path; path.AppendRect(rtImage.left, rtImage.bottom(), rtImage.right(), rtImage.top); - pRenderDevice->SetClip_PathFill(&path, &matrix, + pRenderDevice->SetClip_PathFill(path, &matrix, CFX_FillRenderOptions::WindingOptions()); CFX_Matrix mtImage(1, 0, 0, -1, 0, 1);
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 3f90538..e7e7b03 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -1285,7 +1285,7 @@ graphState.m_LineWidth = 1; graphState.m_MiterLimit = 10; graphState.m_DashPhase = 0; - pDevice->DrawPath(&path, &mtDoc2Device, &graphState, 0, pPiece->dwColor, + pDevice->DrawPath(path, &mtDoc2Device, &graphState, 0, pPiece->dwColor, CFX_FillRenderOptions()); }