diff options
-rw-r--r-- | core/fxge/cfx_renderdevice.cpp | 29 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.h | 16 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_scroll_bar.cpp | 39 |
3 files changed, 42 insertions, 42 deletions
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index a479517d0e..826f14dfa7 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -9,7 +9,6 @@ #include <algorithm> #include <memory> #include <utility> -#include <vector> #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/cfx_defaultrenderdevice.h" @@ -477,12 +476,14 @@ bool CFX_RenderDevice::SetClip_PathStroke( return true; } +#ifdef PDF_ENABLE_XFA bool CFX_RenderDevice::SetClip_Rect(const CFX_RectF& rtClip) { return SetClip_Rect(FX_RECT(static_cast<int32_t>(floor(rtClip.left)), static_cast<int32_t>(floor(rtClip.top)), static_cast<int32_t>(ceil(rtClip.right())), static_cast<int32_t>(ceil(rtClip.bottom())))); } +#endif bool CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { CFX_PathData path; @@ -1104,19 +1105,19 @@ void CFX_RenderDevice::DrawFillRect(const CFX_Matrix* pUser2Device, DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING); } -void CFX_RenderDevice::DrawFillArea(const CFX_Matrix* pUser2Device, - const CFX_PointF* pPts, - int32_t nCount, +void CFX_RenderDevice::DrawFillArea(const CFX_Matrix& mtUser2Device, + const std::vector<CFX_PointF>& points, const FX_COLORREF& color) { + ASSERT(!points.empty()); CFX_PathData path; - path.AppendPoint(pPts[0], FXPT_TYPE::MoveTo, false); - for (int32_t i = 1; i < nCount; i++) - path.AppendPoint(pPts[i], FXPT_TYPE::LineTo, false); + path.AppendPoint(points[0], FXPT_TYPE::MoveTo, false); + for (size_t i = 1; i < points.size(); ++i) + path.AppendPoint(points[i], FXPT_TYPE::LineTo, false); - DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); + DrawPath(&path, &mtUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); } -void CFX_RenderDevice::DrawStrokeRect(const CFX_Matrix* pUser2Device, +void CFX_RenderDevice::DrawStrokeRect(const CFX_Matrix& mtUser2Device, const CFX_FloatRect& rect, const FX_COLORREF& color, float fWidth) { @@ -1125,7 +1126,7 @@ void CFX_RenderDevice::DrawStrokeRect(const CFX_Matrix* pUser2Device, CFX_PathData path; path.AppendRect(rect); - DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); + DrawPath(&path, &mtUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); } void CFX_RenderDevice::DrawStrokeLine(const CFX_Matrix* pUser2Device, @@ -1150,10 +1151,10 @@ void CFX_RenderDevice::DrawFillRect(const CFX_Matrix* pUser2Device, DrawFillRect(pUser2Device, rect, color.ToFXColor(nTransparency)); } -void CFX_RenderDevice::DrawShadow(const CFX_Matrix* pUser2Device, +void CFX_RenderDevice::DrawShadow(const CFX_Matrix& mtUser2Device, bool bVertical, bool bHorizontal, - CFX_FloatRect rect, + const CFX_FloatRect& rect, int32_t nTransparency, int32_t nStartGray, int32_t nEndGray) { @@ -1164,7 +1165,7 @@ void CFX_RenderDevice::DrawShadow(const CFX_Matrix* pUser2Device, for (float fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) { int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom)); - DrawStrokeLine(pUser2Device, CFX_PointF(rect.left, fy), + DrawStrokeLine(&mtUser2Device, CFX_PointF(rect.left, fy), CFX_PointF(rect.right, fy), ArgbEncode(nTransparency, nGray, nGray, nGray), 1.5f); } @@ -1175,7 +1176,7 @@ void CFX_RenderDevice::DrawShadow(const CFX_Matrix* pUser2Device, for (float fx = rect.left + 0.5f; fx <= rect.right - 0.5f; fx += 1.0f) { int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left)); - DrawStrokeLine(pUser2Device, CFX_PointF(fx, rect.bottom), + DrawStrokeLine(&mtUser2Device, CFX_PointF(fx, rect.bottom), CFX_PointF(fx, rect.top), ArgbEncode(nTransparency, nGray, nGray, nGray), 1.5f); } diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index e6c44ff35f..1d6fe48170 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -8,6 +8,7 @@ #define CORE_FXGE_CFX_RENDERDEVICE_H_ #include <memory> +#include <vector> #include "core/fpdfdoc/cpdf_defaultappearance.h" #include "core/fxcrt/unowned_ptr.h" @@ -123,7 +124,9 @@ class CFX_RenderDevice { bool SetClip_PathFill(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, int fill_mode); - bool SetClip_Rect(const CFX_RectF& pRect); +#ifdef PDF_ENABLE_XFA + bool SetClip_Rect(const CFX_RectF& rtClip); +#endif bool SetClip_Rect(const FX_RECT& pRect); bool SetClip_PathStroke(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, @@ -233,7 +236,7 @@ class CFX_RenderDevice { void DrawFillRect(const CFX_Matrix* pUser2Device, const CFX_FloatRect& rect, const FX_COLORREF& color); - void DrawStrokeRect(const CFX_Matrix* pUser2Device, + void DrawStrokeRect(const CFX_Matrix& mtUser2Device, const CFX_FloatRect& rect, const FX_COLORREF& color, float fWidth); @@ -250,14 +253,13 @@ class CFX_RenderDevice { const CFX_Color& crRightBottom, BorderStyle nStyle, int32_t nTransparency); - void DrawFillArea(const CFX_Matrix* pUser2Device, - const CFX_PointF* pPts, - int32_t nCount, + void DrawFillArea(const CFX_Matrix& mtUser2Device, + const std::vector<CFX_PointF>& points, const FX_COLORREF& color); - void DrawShadow(const CFX_Matrix* pUser2Device, + void DrawShadow(const CFX_Matrix& mtUser2Device, bool bVertical, bool bHorizontal, - CFX_FloatRect rect, + const CFX_FloatRect& rect, int32_t nTransparency, int32_t nStartGray, int32_t nEndGray); diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp index d71ce353d0..a9cd4f67d0 100644 --- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp +++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp @@ -187,15 +187,15 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, } // draw border - pDevice->DrawStrokeRect(&mtUser2Device, rectWnd, + pDevice->DrawStrokeRect(mtUser2Device, rectWnd, ArgbEncode(nTransparency, 100, 100, 100), 0.0f); - pDevice->DrawStrokeRect(&mtUser2Device, rectWnd.GetDeflated(0.5f, 0.5f), + pDevice->DrawStrokeRect(mtUser2Device, rectWnd.GetDeflated(0.5f, 0.5f), ArgbEncode(nTransparency, 255, 255, 255), 1.0f); if (m_eSBButtonType != PSBT_POS) { // draw background if (IsEnabled()) { - pDevice->DrawShadow(&mtUser2Device, true, false, + pDevice->DrawShadow(mtUser2Device, true, false, rectWnd.GetDeflated(1.0f, 1.0f), nTransparency, 80, 220); } else { @@ -208,24 +208,21 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, float fX = rectWnd.left + 1.5f; float fY = rectWnd.bottom; std::vector<CFX_PointF> pts; - if (m_eSBButtonType == PSBT_MIN) { - pts.push_back(CFX_PointF(fX + 2.5f, fY + 4.0f)); - pts.push_back(CFX_PointF(fX + 2.5f, fY + 3.0f)); - pts.push_back(CFX_PointF(fX + 4.5f, fY + 5.0f)); - pts.push_back(CFX_PointF(fX + 6.5f, fY + 3.0f)); - pts.push_back(CFX_PointF(fX + 6.5f, fY + 4.0f)); - pts.push_back(CFX_PointF(fX + 4.5f, fY + 6.0f)); - pts.push_back(CFX_PointF(fX + 2.5f, fY + 4.0f)); - } else { - pts.push_back(CFX_PointF(fX + 2.5f, fY + 5.0f)); - pts.push_back(CFX_PointF(fX + 2.5f, fY + 6.0f)); - pts.push_back(CFX_PointF(fX + 4.5f, fY + 4.0f)); - pts.push_back(CFX_PointF(fX + 6.5f, fY + 6.0f)); - pts.push_back(CFX_PointF(fX + 6.5f, fY + 5.0f)); - pts.push_back(CFX_PointF(fX + 4.5f, fY + 3.0f)); - pts.push_back(CFX_PointF(fX + 2.5f, fY + 5.0f)); - } - pDevice->DrawFillArea(&mtUser2Device, pts.data(), 7, + static constexpr float kOffsetsX[] = {2.5f, 2.5f, 4.5f, 6.5f, + 6.5f, 4.5f, 2.5f}; + static constexpr float kOffsetsY[] = {5.0f, 6.0f, 4.0f, 6.0f, + 5.0f, 3.0f, 5.0f}; + static constexpr float kOffsetsMinY[] = {4.0f, 3.0f, 5.0f, 3.0f, + 4.0f, 6.0f, 4.0f}; + static_assert(FX_ArraySize(kOffsetsX) == FX_ArraySize(kOffsetsY), + "Wrong offset count"); + static_assert(FX_ArraySize(kOffsetsX) == FX_ArraySize(kOffsetsMinY), + "Wrong offset count"); + const float* pOffsetsY = + m_eSBButtonType == PSBT_MIN ? kOffsetsMinY : kOffsetsY; + for (size_t i = 0; i < FX_ArraySize(kOffsetsX); ++i) + pts.push_back(CFX_PointF(fX + kOffsetsX[i], fY + pOffsetsY[i])); + pDevice->DrawFillArea(mtUser2Device, pts, IsEnabled() ? ArgbEncode(nTransparency, 255, 255, 255) : PWL_DEFAULT_HEAVYGRAYCOLOR.ToFXColor(255)); |