diff options
author | Lei Zhang <thestig@chromium.org> | 2018-04-12 14:15:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-12 14:15:33 +0000 |
commit | e6d4559a1b6c2eb0eb433b9db70745e3be3d8465 (patch) | |
tree | d3c3ca944a97389e7ab698ecc5ab90dfb9bf1b13 /fpdfsdk | |
parent | 59a8f48571fc1e1b11f070c54e5d75b8b1c2e9a2 (diff) | |
download | pdfium-e6d4559a1b6c2eb0eb433b9db70745e3be3d8465.tar.xz |
Clean up some CFX_RenderDevice code.
- Pass matrices by const-ref instead of by pointers.
- Mark one SetClip_Rect() variant as XFA-only.
- Pass std::vector into DrawFillArea().
- Simplify the only DrawFillArea() caller.
Change-Id: I8f7497e4d46345d50ac4cc8f3e7eef135644e7a7
Reviewed-on: https://pdfium-review.googlesource.com/30131
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/pwl/cpwl_scroll_bar.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
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)); |