diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-09-24 17:55:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-09-24 17:55:00 +0000 |
commit | fed6e124109f089a38e24e37b104d983231bee78 (patch) | |
tree | 6c1aa45a97eb27c67611dbe7480bdbcd26710d14 /core/fxge/skia | |
parent | 97f4483de007c2ff248696f24d34634e0adbf894 (diff) | |
download | pdfium-fed6e124109f089a38e24e37b104d983231bee78.tar.xz |
Give CFX_GraphStateData a work-over.chromium/3561
Use std::vector<float> 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 <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge/skia')
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
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<SkScalar, FxFreeDeleter> 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) |