From 2f7653c0d8fe60f1a4956382dcb3d73822694dda Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Fri, 18 Aug 2017 14:04:56 -0400 Subject: Converted DrawCosmeticLine() to take point objects Converted CFX_RenderDevice::DrawCosmeticLine() and IFX_RenderDeviceDriver:: DrawCosmeticLine() to take in CFX_PointF objects instead of two coordinates per point. Bug=pdfium:769 Change-Id: I6116e4106a61487184a71e79c1dca3a85e8c7c27 Reviewed-on: https://pdfium-review.googlesource.com/11410 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fxge/cfx_renderdevice.cpp | 17 +++++++---------- core/fxge/cfx_renderdevice.h | 6 ++---- core/fxge/ifx_renderdevicedriver.cpp | 6 ++---- core/fxge/ifx_renderdevicedriver.h | 7 +++---- core/fxge/skia/fx_skia_device.cpp | 6 ++---- core/fxge/skia/fx_skia_device.h | 6 ++---- core/fxge/win32/fx_win32_device.cpp | 20 +++++++++----------- core/fxge/win32/win32_int.h | 6 ++---- 8 files changed, 29 insertions(+), 45 deletions(-) diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index a7b1a93643..8f35dce2da 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -514,8 +514,7 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, pos1 = pObject2Device->Transform(pos1); pos2 = pObject2Device->Transform(pos2); } - DrawCosmeticLine(pos1.x, pos1.y, pos2.x, pos2.y, fill_color, fill_mode, - blend_type); + DrawCosmeticLine(pos1, pos2, fill_color, fill_mode, blend_type); return true; } @@ -691,21 +690,19 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, return true; } -bool CFX_RenderDevice::DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, +bool CFX_RenderDevice::DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int fill_mode, int blend_type) { - if ((color >= 0xff000000) && - m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { + if ((color >= 0xff000000) && m_pDeviceDriver->DrawCosmeticLine( + ptMoveTo, ptLineTo, color, blend_type)) { return true; } CFX_GraphStateData graph_state; CFX_PathData path; - path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::MoveTo, false); - path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::LineTo, false); + path.AppendPoint(ptMoveTo, FXPT_TYPE::MoveTo, false); + path.AppendPoint(ptLineTo, FXPT_TYPE::LineTo, false); return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, fill_mode, blend_type); } diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 53443ab72f..49a0f3e0bc 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -288,10 +288,8 @@ class CFX_RenderDevice { uint32_t stroke_color, int fill_mode, int blend_type); - bool DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, + bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int fill_mode, int blend_type); diff --git a/core/fxge/ifx_renderdevicedriver.cpp b/core/fxge/ifx_renderdevicedriver.cpp index 9b94e883f2..ac7a7424e7 100644 --- a/core/fxge/ifx_renderdevicedriver.cpp +++ b/core/fxge/ifx_renderdevicedriver.cpp @@ -39,10 +39,8 @@ bool IFX_RenderDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, return false; } -bool IFX_RenderDeviceDriver::DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, +bool IFX_RenderDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type) { return false; diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h index f4df846011..1e4e30584e 100644 --- a/core/fxge/ifx_renderdevicedriver.h +++ b/core/fxge/ifx_renderdevicedriver.h @@ -10,6 +10,7 @@ #include #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" class CFX_DIBitmap; @@ -53,10 +54,8 @@ class IFX_RenderDeviceDriver { virtual bool FillRectWithBlend(const FX_RECT* pRect, uint32_t fill_color, int blend_type); - virtual bool DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, + virtual bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type); diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 523c8a28e8..6dd49d1be7 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -1948,10 +1948,8 @@ bool CFX_SkiaDeviceDriver::DrawPath( return true; } -bool CFX_SkiaDeviceDriver::DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, +bool CFX_SkiaDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type) { return false; diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index cde05eba67..2a92a36aac 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -69,10 +69,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { int blend_type) override; /** Draw a single pixel (device dependant) line */ - bool DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, + bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type) override; diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index b707a76c08..101c945fc5 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -998,14 +998,14 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, FX_RECT bbox = bbox_f.GetInnerRect(); if (bbox.Width() <= 0) { - return DrawCosmeticLine((float)(bbox.left), (float)(bbox.top), - (float)(bbox.left), (float)(bbox.bottom + 1), + return DrawCosmeticLine(CFX_PointF(bbox.left, bbox.top), + CFX_PointF(bbox.left, bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL); } if (bbox.Height() <= 0) { - return DrawCosmeticLine((float)(bbox.left), (float)(bbox.top), - (float)(bbox.right + 1), (float)(bbox.top), - fill_color, FXDIB_BLEND_NORMAL); + return DrawCosmeticLine(CFX_PointF(bbox.left, bbox.top), + CFX_PointF(bbox.right + 1, bbox.top), fill_color, + FXDIB_BLEND_NORMAL); } } int fill_alpha = FXARGB_A(fill_color); @@ -1137,10 +1137,8 @@ bool CGdiDeviceDriver::SetClip_PathStroke( return ret; } -bool CGdiDeviceDriver::DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, +bool CGdiDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type) { if (blend_type != FXDIB_BLEND_NORMAL) @@ -1154,8 +1152,8 @@ bool CGdiDeviceDriver::DrawCosmeticLine(float x1, HPEN hPen = CreatePen(PS_SOLID, 1, rgb); hPen = (HPEN)SelectObject(m_hDC, hPen); - MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); - LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); + MoveToEx(m_hDC, FXSYS_round(ptMoveTo.x), FXSYS_round(ptMoveTo.y), nullptr); + LineTo(m_hDC, FXSYS_round(ptLineTo.x), FXSYS_round(ptLineTo.y)); hPen = (HPEN)SelectObject(m_hDC, hPen); DeleteObject(hPen); return true; diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index c51bae7f67..f9fcbe83af 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -150,10 +150,8 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { bool FillRectWithBlend(const FX_RECT* pRect, uint32_t fill_color, int blend_type) override; - bool DrawCosmeticLine(float x1, - float y1, - float x2, - float y2, + bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, + const CFX_PointF& ptLineTo, uint32_t color, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; -- cgit v1.2.3