OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/xfa_ffwidget.h" | 7 #include "xfa/fxfa/xfa_ffwidget.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 if (!bStart && !bEnd) { | 1210 if (!bStart && !bEnd) { |
1211 fillPath.AddEllipse(rtDraw); | 1211 fillPath.AddEllipse(rtDraw); |
1212 return; | 1212 return; |
1213 } | 1213 } |
1214 startAngle = -startAngle * FX_PI / 180.0f; | 1214 startAngle = -startAngle * FX_PI / 180.0f; |
1215 sweepAngle = -sweepAngle * FX_PI / 180.0f; | 1215 sweepAngle = -sweepAngle * FX_PI / 180.0f; |
1216 fillPath.AddArc(rtDraw.left, rtDraw.top, rtDraw.width, rtDraw.height, | 1216 fillPath.AddArc(rtDraw.left, rtDraw.top, rtDraw.width, rtDraw.height, |
1217 startAngle, sweepAngle); | 1217 startAngle, sweepAngle); |
1218 } | 1218 } |
1219 static void XFA_BOX_GetPath(CXFA_Box box, | 1219 static void XFA_BOX_GetPath(CXFA_Box box, |
1220 const CXFA_StrokeArray& strokes, | 1220 const std::vector<CXFA_Stroke>& strokes, |
1221 CFX_RectF rtWidget, | 1221 CFX_RectF rtWidget, |
1222 CFX_Path& path, | 1222 CFX_Path& path, |
1223 int32_t nIndex, | 1223 int32_t nIndex, |
1224 bool bStart, | 1224 bool bStart, |
1225 bool bCorner) { | 1225 bool bCorner) { |
1226 ASSERT(nIndex >= 0 && nIndex < 8); | 1226 ASSERT(nIndex >= 0 && nIndex < 8); |
1227 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; | 1227 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex; |
1228 CXFA_Corner corner1(strokes[n].GetNode()); | 1228 CXFA_Corner corner1(strokes[n].GetNode()); |
1229 CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); | 1229 CXFA_Corner corner2(strokes[(n + 2) % 8].GetNode()); |
1230 FX_FLOAT fRadius1 = bCorner ? corner1.GetRadius() : 0.0f; | 1230 FX_FLOAT fRadius1 = bCorner ? corner1.GetRadius() : 0.0f; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; | 1378 cp.x = cp1.x + fRadius1 * vx, cp.y = cp1.y + fRadius1 * vy; |
1379 } else { | 1379 } else { |
1380 cp = cp1; | 1380 cp = cp1; |
1381 } | 1381 } |
1382 path.LineTo(cp.x, cp.y); | 1382 path.LineTo(cp.x, cp.y); |
1383 path.LineTo(cp1.x + fRadius1 * sx + offsetX, | 1383 path.LineTo(cp1.x + fRadius1 * sx + offsetX, |
1384 cp1.y + fRadius1 * sy + offsetY); | 1384 cp1.y + fRadius1 * sy + offsetY); |
1385 } | 1385 } |
1386 } | 1386 } |
1387 static void XFA_BOX_GetFillPath(CXFA_Box box, | 1387 static void XFA_BOX_GetFillPath(CXFA_Box box, |
1388 const CXFA_StrokeArray& strokes, | 1388 const std::vector<CXFA_Stroke>& strokes, |
1389 CFX_RectF rtWidget, | 1389 CFX_RectF rtWidget, |
1390 CFX_Path& fillPath, | 1390 CFX_Path& fillPath, |
1391 uint16_t dwFlags) { | 1391 uint16_t dwFlags) { |
1392 if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { | 1392 if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { |
1393 CXFA_Edge edge = box.GetEdge(0); | 1393 CXFA_Edge edge = box.GetEdge(0); |
1394 FX_FLOAT fThickness = edge.GetThickness(); | 1394 FX_FLOAT fThickness = edge.GetThickness(); |
1395 if (fThickness < 0) { | 1395 if (fThickness < 0) { |
1396 fThickness = 0; | 1396 fThickness = 0; |
1397 } | 1397 } |
1398 FX_FLOAT fHalf = fThickness / 2; | 1398 FX_FLOAT fHalf = fThickness / 2; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 break; | 1624 break; |
1625 default: | 1625 default: |
1626 break; | 1626 break; |
1627 } | 1627 } |
1628 CFX_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd); | 1628 CFX_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd); |
1629 CFX_Color cr(&shading); | 1629 CFX_Color cr(&shading); |
1630 pGS->SetFillColor(&cr); | 1630 pGS->SetFillColor(&cr); |
1631 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1631 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
1632 } | 1632 } |
1633 static void XFA_BOX_Fill(CXFA_Box box, | 1633 static void XFA_BOX_Fill(CXFA_Box box, |
1634 const CXFA_StrokeArray& strokes, | 1634 const std::vector<CXFA_Stroke>& strokes, |
1635 CFX_Graphics* pGS, | 1635 CFX_Graphics* pGS, |
1636 const CFX_RectF& rtWidget, | 1636 const CFX_RectF& rtWidget, |
1637 CFX_Matrix* pMatrix, | 1637 CFX_Matrix* pMatrix, |
1638 uint32_t dwFlags) { | 1638 uint32_t dwFlags) { |
1639 CXFA_Fill fill = box.GetFill(); | 1639 CXFA_Fill fill = box.GetFill(); |
1640 if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { | 1640 if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { |
1641 return; | 1641 return; |
1642 } | 1642 } |
1643 pGS->SaveGraphState(); | 1643 pGS->SaveGraphState(); |
1644 CFX_Path fillPath; | 1644 CFX_Path fillPath; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 CFX_RectF rt, | 1863 CFX_RectF rt, |
1864 FX_FLOAT fThickness, | 1864 FX_FLOAT fThickness, |
1865 CFX_Matrix* pMatrix) { | 1865 CFX_Matrix* pMatrix) { |
1866 FX_FLOAT fHalfWidth = fThickness / 2.0f; | 1866 FX_FLOAT fHalfWidth = fThickness / 2.0f; |
1867 XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); | 1867 XFA_Draw3DRect(pGS, rt, fThickness, pMatrix, 0xFF808080, 0xFF000000); |
1868 CFX_RectF rtInner(rt); | 1868 CFX_RectF rtInner(rt); |
1869 rtInner.Deflate(fHalfWidth, fHalfWidth); | 1869 rtInner.Deflate(fHalfWidth, fHalfWidth); |
1870 XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); | 1870 XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); |
1871 } | 1871 } |
1872 static void XFA_BOX_Stroke_Rect(CXFA_Box box, | 1872 static void XFA_BOX_Stroke_Rect(CXFA_Box box, |
1873 const CXFA_StrokeArray& strokes, | 1873 const std::vector<CXFA_Stroke>& strokes, |
1874 CFX_Graphics* pGS, | 1874 CFX_Graphics* pGS, |
1875 CFX_RectF rtWidget, | 1875 CFX_RectF rtWidget, |
1876 CFX_Matrix* pMatrix) { | 1876 CFX_Matrix* pMatrix) { |
1877 bool bVisible = false; | 1877 bool bVisible = false; |
1878 FX_FLOAT fThickness = 0; | 1878 FX_FLOAT fThickness = 0; |
1879 int32_t i3DType = box.Get3DStyle(bVisible, fThickness); | 1879 int32_t i3DType = box.Get3DStyle(bVisible, fThickness); |
1880 if (i3DType) { | 1880 if (i3DType) { |
1881 if (!bVisible || fThickness < 0.001f) { | 1881 if (!bVisible || fThickness < 0.001f) { |
1882 return; | 1882 return; |
1883 } | 1883 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 } | 1954 } |
1955 bool bEmpty = path.IsEmpty(); | 1955 bool bEmpty = path.IsEmpty(); |
1956 if (!bEmpty) { | 1956 if (!bEmpty) { |
1957 if (bClose) { | 1957 if (bClose) { |
1958 path.Close(); | 1958 path.Close(); |
1959 } | 1959 } |
1960 XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); | 1960 XFA_BOX_StrokePath(strokes[7], &path, pGS, pMatrix); |
1961 } | 1961 } |
1962 } | 1962 } |
1963 static void XFA_BOX_Stroke(CXFA_Box box, | 1963 static void XFA_BOX_Stroke(CXFA_Box box, |
1964 const CXFA_StrokeArray& strokes, | 1964 const std::vector<CXFA_Stroke>& strokes, |
1965 CFX_Graphics* pGS, | 1965 CFX_Graphics* pGS, |
1966 CFX_RectF rtWidget, | 1966 CFX_RectF rtWidget, |
1967 CFX_Matrix* pMatrix, | 1967 CFX_Matrix* pMatrix, |
1968 uint32_t dwFlags) { | 1968 uint32_t dwFlags) { |
1969 if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { | 1969 if (box.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { |
1970 XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); | 1970 XFA_BOX_StrokeArc(box, pGS, rtWidget, pMatrix, dwFlags); |
1971 return; | 1971 return; |
1972 } | 1972 } |
1973 bool bVisible = false; | 1973 bool bVisible = false; |
1974 for (int32_t j = 0; j < 4; j++) { | 1974 for (int32_t j = 0; j < 4; j++) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 CFX_Matrix* pMatrix, | 2031 CFX_Matrix* pMatrix, |
2032 uint32_t dwFlags) { | 2032 uint32_t dwFlags) { |
2033 if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) | 2033 if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) |
2034 return; | 2034 return; |
2035 | 2035 |
2036 XFA_Element eType = box.GetElementType(); | 2036 XFA_Element eType = box.GetElementType(); |
2037 if (eType != XFA_Element::Arc && eType != XFA_Element::Border && | 2037 if (eType != XFA_Element::Arc && eType != XFA_Element::Border && |
2038 eType != XFA_Element::Rectangle) { | 2038 eType != XFA_Element::Rectangle) { |
2039 return; | 2039 return; |
2040 } | 2040 } |
2041 CXFA_StrokeArray strokes; | 2041 std::vector<CXFA_Stroke> strokes; |
2042 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) { | 2042 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) |
2043 box.GetStrokes(strokes); | 2043 box.GetStrokes(&strokes); |
2044 } | 2044 |
2045 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 2045 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
2046 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 2046 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
2047 } | 2047 } |
2048 | 2048 |
2049 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} | 2049 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} |
2050 | 2050 |
2051 CXFA_CalcData::~CXFA_CalcData() { | 2051 CXFA_CalcData::~CXFA_CalcData() { |
2052 m_Globals.RemoveAll(); | 2052 m_Globals.RemoveAll(); |
2053 } | 2053 } |
OLD | NEW |