diff options
Diffstat (limited to 'core/fxge/win32')
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 11 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 14 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 10 |
3 files changed, 16 insertions, 19 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index dbc212123c..12795d0cc5 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -311,13 +311,10 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) { buf << pGraphState->m_LineCap << " J\n"; } if (!m_bGraphStateSet || - m_CurGraphState.m_DashCount != pGraphState->m_DashCount || - memcmp(m_CurGraphState.m_DashArray, pGraphState->m_DashArray, - sizeof(float) * m_CurGraphState.m_DashCount)) { + m_CurGraphState.m_DashArray != pGraphState->m_DashArray) { buf << "["; - for (int i = 0; i < pGraphState->m_DashCount; ++i) - buf << pGraphState->m_DashArray[i] << " "; - + for (const auto& dash : pGraphState->m_DashArray) + buf << dash << " "; buf << "]" << pGraphState->m_DashPhase << " d\n"; } if (!m_bGraphStateSet || @@ -332,7 +329,7 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) { m_CurGraphState.m_MiterLimit != pGraphState->m_MiterLimit) { buf << pGraphState->m_MiterLimit << " M\n"; } - m_CurGraphState.Copy(*pGraphState); + m_CurGraphState = *pGraphState; m_bGraphStateSet = true; WriteToStream(&buf); } diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index c8f049704f..526eea58f3 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -103,7 +103,7 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, float width = std::max(scale * pGraphState->m_LineWidth, 1.0f); uint32_t PenStyle = PS_GEOMETRIC; - if (pGraphState->m_DashCount) + if (!pGraphState->m_DashArray.empty()) PenStyle |= PS_USERSTYLE; else PenStyle |= PS_SOLID; @@ -137,9 +137,9 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, lb.lbStyle = BS_SOLID; lb.lbHatch = 0; std::vector<uint32_t> dashes; - if (pGraphState->m_DashCount) { - dashes.resize(pGraphState->m_DashCount); - for (int i = 0; i < pGraphState->m_DashCount; i++) { + if (!pGraphState->m_DashArray.empty()) { + dashes.resize(pGraphState->m_DashArray.size()); + for (size_t i = 0; i < pGraphState->m_DashArray.size(); i++) { dashes[i] = FXSYS_round( pMatrix ? pMatrix->TransformDistance(pGraphState->m_DashArray[i]) : pGraphState->m_DashArray[i]); @@ -147,7 +147,7 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, } } return ExtCreatePen(PenStyle, (DWORD)ceil(width), &lb, - pGraphState->m_DashCount, + pGraphState->m_DashArray.size(), reinterpret_cast<const DWORD*>(dashes.data())); } @@ -994,7 +994,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, if (pPlatform->m_GdiplusExt.IsAvailable()) { if (bDrawAlpha || ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || - (pGraphState && pGraphState->m_DashCount))) { + (pGraphState && !pGraphState->m_DashArray.empty()))) { if (!((!pMatrix || !pMatrix->WillScale()) && pGraphState && pGraphState->m_LineWidth == 1.0f && (pPathData->GetPoints().size() == 5 || @@ -1023,7 +1023,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); } if (pPathData->GetPoints().size() == 2 && pGraphState && - pGraphState->m_DashCount) { + !pGraphState->m_DashArray.empty()) { CFX_PointF pos1 = pPathData->GetPoint(0); CFX_PointF pos2 = pPathData->GetPoint(1); if (pMatrix) { diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index eee6b8798a..8d361e7c5e 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -770,15 +770,15 @@ GpPen* GdipCreatePenImpl(const CFX_GraphStateData* pGraphState, break; } CallFunc(GdipSetPenLineJoin)(pPen, lineJoin); - if (pGraphState->m_DashCount) { - float* pDashArray = FX_Alloc( - float, pGraphState->m_DashCount + pGraphState->m_DashCount % 2); + if (!pGraphState->m_DashArray.empty()) { + float* pDashArray = + FX_Alloc(float, (pGraphState->m_DashArray.size() + 1) & ~1); int nCount = 0; float on_leftover = 0, off_leftover = 0; - for (int i = 0; i < pGraphState->m_DashCount; i += 2) { + for (size_t i = 0; i < pGraphState->m_DashArray.size(); i += 2) { float on_phase = pGraphState->m_DashArray[i]; float off_phase; - if (i == pGraphState->m_DashCount - 1) + if (i == pGraphState->m_DashArray.size() - 1) off_phase = on_phase; else off_phase = pGraphState->m_DashArray[i + 1]; |