From fed6e124109f089a38e24e37b104d983231bee78 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 24 Sep 2018 17:55:00 +0000 Subject: Give CFX_GraphStateData a work-over. Use std::vector for dash array. Use compiler-generated default operations. Squeeze some enums. Fix obvious logic botch in DashChanged(). Change-Id: If1d809cc46a3cf2db98a09a3f5a49d22138c0640 Reviewed-on: https://pdfium-review.googlesource.com/42613 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxge/skia/fx_skia_device.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'core/fxge/skia') diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 2ffd446023..a06fcaaa55 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -734,7 +734,7 @@ class SkiaState { ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType); if (pDrawState) - m_drawState.Copy(*pDrawState); + m_drawState = *pDrawState; m_fillColor = fill_color; m_strokeColor = stroke_color; m_blendType = blend_type; @@ -1139,20 +1139,13 @@ class SkiaState { bool DashChanged(const CFX_GraphStateData* pState, const CFX_GraphStateData& refState) const { - bool dashArray = pState && pState->m_DashArray; - if (!dashArray && !refState.m_DashArray) + bool dashArray = pState && !pState->m_DashArray.empty(); + if (!dashArray && refState.m_DashArray.empty()) return false; - if (!dashArray || !refState.m_DashArray) + if (!dashArray || refState.m_DashArray.empty()) return true; - if (pState->m_DashPhase != refState.m_DashPhase || - pState->m_DashCount != refState.m_DashCount) { - return true; - } - for (int index = 0; index < pState->m_DashCount; ++index) { - if (pState->m_DashArray[index] != refState.m_DashArray[index]) - return true; - } - return true; + return pState->m_DashPhase != refState.m_DashPhase || + pState->m_DashArray != refState.m_DashArray; } void AdjustClip(int limit) { @@ -1476,16 +1469,16 @@ void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, float width = SkTMax(pGraphState->m_LineWidth, SkTMin(deviceUnits[0].length(), deviceUnits[1].length())); - if (pGraphState->m_DashArray) { - int count = (pGraphState->m_DashCount + 1) / 2; + if (!pGraphState->m_DashArray.empty()) { + size_t count = (pGraphState->m_DashArray.size() + 1) / 2; std::unique_ptr intervals( FX_Alloc2D(SkScalar, count, sizeof(SkScalar))); // Set dash pattern - for (int i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { float on = pGraphState->m_DashArray[i * 2]; if (on <= 0.000001f) on = 1.f / 10; - float off = i * 2 + 1 == pGraphState->m_DashCount + float off = i * 2 + 1 == pGraphState->m_DashArray.size() ? on : pGraphState->m_DashArray[i * 2 + 1]; if (off < 0) -- cgit v1.2.3