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/app/xfa_ffwidget.h" | 7 #include "xfa/fxfa/app/xfa_ffwidget.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" | 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
12 #include "core/include/fxcodec/fx_codec.h" | 12 #include "core/include/fxcodec/fx_codec.h" |
13 #include "xfa/fxfa/app/xfa_ffapp.h" | 13 #include "xfa/fxfa/app/xfa_ffapp.h" |
14 #include "xfa/fxfa/app/xfa_ffdoc.h" | 14 #include "xfa/fxfa/app/xfa_ffdoc.h" |
15 #include "xfa/fxfa/app/xfa_ffdocview.h" | 15 #include "xfa/fxfa/app/xfa_ffdocview.h" |
16 #include "xfa/fxfa/app/xfa_ffpageview.h" | 16 #include "xfa/fxfa/app/xfa_ffpageview.h" |
17 #include "xfa/fxfa/app/xfa_textlayout.h" | 17 #include "xfa/fxfa/app/xfa_textlayout.h" |
18 #include "xfa/include/fxgraphics/fx_graphics.h" | 18 #include "xfa/fxgraphics/cfx_color.h" |
| 19 #include "xfa/fxgraphics/cfx_path.h" |
| 20 #include "xfa/fxgraphics/cfx_pattern.h" |
| 21 #include "xfa/fxgraphics/cfx_shading.h" |
| 22 #include "xfa/fxgraphics/include/cfx_graphics.h" |
19 | 23 |
20 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, | 24 CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView, |
21 CXFA_WidgetAcc* pDataAcc) | 25 CXFA_WidgetAcc* pDataAcc) |
22 : CXFA_ContentLayoutItem(pDataAcc->GetNode()), | 26 : CXFA_ContentLayoutItem(pDataAcc->GetNode()), |
23 m_pPageView(pPageView), | 27 m_pPageView(pPageView), |
24 m_pDataAcc(pDataAcc) { | 28 m_pDataAcc(pDataAcc) { |
25 m_rtWidget.Set(0, 0, 0, 0); | 29 m_rtWidget.Set(0, 0, 0, 0); |
26 } | 30 } |
27 CXFA_FFWidget::~CXFA_FFWidget() {} | 31 CXFA_FFWidget::~CXFA_FFWidget() {} |
28 IXFA_PageView* CXFA_FFWidget::GetPageView() { | 32 IXFA_PageView* CXFA_FFWidget::GetPageView() { |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 } | 1453 } |
1450 static void XFA_BOX_Fill_Radial(CXFA_Box box, | 1454 static void XFA_BOX_Fill_Radial(CXFA_Box box, |
1451 CFX_Graphics* pGS, | 1455 CFX_Graphics* pGS, |
1452 CFX_Path& fillPath, | 1456 CFX_Path& fillPath, |
1453 CFX_RectF rtFill, | 1457 CFX_RectF rtFill, |
1454 CFX_Matrix* pMatrix) { | 1458 CFX_Matrix* pMatrix) { |
1455 CXFA_Fill fill = box.GetFill(); | 1459 CXFA_Fill fill = box.GetFill(); |
1456 FX_ARGB crStart, crEnd; | 1460 FX_ARGB crStart, crEnd; |
1457 crStart = fill.GetColor(); | 1461 crStart = fill.GetColor(); |
1458 int32_t iType = fill.GetRadial(crEnd); | 1462 int32_t iType = fill.GetRadial(crEnd); |
1459 CFX_Shading shading; | 1463 CFX_Shading shading(FX_SHADING_Radial); |
1460 if (iType != XFA_ATTRIBUTEENUM_ToEdge) { | 1464 if (iType != XFA_ATTRIBUTEENUM_ToEdge) { |
1461 FX_ARGB temp = crEnd; | 1465 FX_ARGB temp = crEnd; |
1462 crEnd = crStart; | 1466 crEnd = crStart; |
1463 crStart = temp; | 1467 crStart = temp; |
1464 } | 1468 } |
1465 shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, | 1469 shading.CreateRadial(rtFill.Center(), rtFill.Center(), 0, |
1466 FXSYS_sqrt(rtFill.Width() * rtFill.Width() + | 1470 FXSYS_sqrt(rtFill.Width() * rtFill.Width() + |
1467 rtFill.Height() * rtFill.Height()) / | 1471 rtFill.Height() * rtFill.Height()) / |
1468 2, | 1472 2, |
1469 TRUE, TRUE, crStart, crEnd); | 1473 TRUE, TRUE, crStart, crEnd); |
1470 CFX_Color cr(&shading); | 1474 CFX_Color cr(&shading); |
1471 pGS->SetFillColor(&cr); | 1475 pGS->SetFillColor(&cr); |
1472 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1476 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
1473 } | 1477 } |
1474 static void XFA_BOX_Fill_Pattern(CXFA_Box box, | 1478 static void XFA_BOX_Fill_Pattern(CXFA_Box box, |
1475 CFX_Graphics* pGS, | 1479 CFX_Graphics* pGS, |
1476 CFX_Path& fillPath, | 1480 CFX_Path& fillPath, |
1477 CFX_RectF rtFill, | 1481 CFX_RectF rtFill, |
1478 CFX_Matrix* pMatrix) { | 1482 CFX_Matrix* pMatrix) { |
1479 CXFA_Fill fill = box.GetFill(); | 1483 CXFA_Fill fill = box.GetFill(); |
1480 FX_ARGB crStart, crEnd; | 1484 FX_ARGB crStart, crEnd; |
1481 crStart = fill.GetColor(); | 1485 crStart = fill.GetColor(); |
1482 int32_t iType = fill.GetPattern(crEnd); | 1486 int32_t iType = fill.GetPattern(crEnd); |
1483 int32_t iHatch = FX_HATCHSTYLE_Cross; | 1487 FX_HatchStyle iHatch = FX_HATCHSTYLE_Cross; |
1484 switch (iType) { | 1488 switch (iType) { |
1485 case XFA_ATTRIBUTEENUM_CrossDiagonal: | 1489 case XFA_ATTRIBUTEENUM_CrossDiagonal: |
1486 iHatch = FX_HATCHSTYLE_DiagonalCross; | 1490 iHatch = FX_HATCHSTYLE_DiagonalCross; |
1487 break; | 1491 break; |
1488 case XFA_ATTRIBUTEENUM_DiagonalLeft: | 1492 case XFA_ATTRIBUTEENUM_DiagonalLeft: |
1489 iHatch = FX_HATCHSTYLE_ForwardDiagonal; | 1493 iHatch = FX_HATCHSTYLE_ForwardDiagonal; |
1490 break; | 1494 break; |
1491 case XFA_ATTRIBUTEENUM_DiagonalRight: | 1495 case XFA_ATTRIBUTEENUM_DiagonalRight: |
1492 iHatch = FX_HATCHSTYLE_BackwardDiagonal; | 1496 iHatch = FX_HATCHSTYLE_BackwardDiagonal; |
1493 break; | 1497 break; |
1494 case XFA_ATTRIBUTEENUM_Horizontal: | 1498 case XFA_ATTRIBUTEENUM_Horizontal: |
1495 iHatch = FX_HATCHSTYLE_Horizontal; | 1499 iHatch = FX_HATCHSTYLE_Horizontal; |
1496 break; | 1500 break; |
1497 case XFA_ATTRIBUTEENUM_Vertical: | 1501 case XFA_ATTRIBUTEENUM_Vertical: |
1498 iHatch = FX_HATCHSTYLE_Vertical; | 1502 iHatch = FX_HATCHSTYLE_Vertical; |
1499 break; | 1503 break; |
1500 default: | 1504 default: |
1501 break; | 1505 break; |
1502 } | 1506 } |
| 1507 |
1503 CFX_Pattern pattern; | 1508 CFX_Pattern pattern; |
1504 pattern.Create(iHatch, crEnd, crStart); | 1509 pattern.Create(iHatch, crEnd, crStart); |
1505 CFX_Color cr(&pattern); | 1510 CFX_Color cr(&pattern); |
1506 pGS->SetFillColor(&cr); | 1511 pGS->SetFillColor(&cr); |
1507 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1512 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
1508 } | 1513 } |
1509 static void XFA_BOX_Fill_Linear(CXFA_Box box, | 1514 static void XFA_BOX_Fill_Linear(CXFA_Box box, |
1510 CFX_Graphics* pGS, | 1515 CFX_Graphics* pGS, |
1511 CFX_Path& fillPath, | 1516 CFX_Path& fillPath, |
1512 CFX_RectF rtFill, | 1517 CFX_RectF rtFill, |
(...skipping 17 matching lines...) Expand all Loading... |
1530 ptStart = CFX_PointF(rtFill.right(), rtFill.top); | 1535 ptStart = CFX_PointF(rtFill.right(), rtFill.top); |
1531 ptEnd = CFX_PointF(rtFill.left, rtFill.top); | 1536 ptEnd = CFX_PointF(rtFill.left, rtFill.top); |
1532 break; | 1537 break; |
1533 case XFA_ATTRIBUTEENUM_ToTop: | 1538 case XFA_ATTRIBUTEENUM_ToTop: |
1534 ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); | 1539 ptStart = CFX_PointF(rtFill.left, rtFill.bottom()); |
1535 ptEnd = CFX_PointF(rtFill.left, rtFill.top); | 1540 ptEnd = CFX_PointF(rtFill.left, rtFill.top); |
1536 break; | 1541 break; |
1537 default: | 1542 default: |
1538 break; | 1543 break; |
1539 } | 1544 } |
1540 CFX_Shading shading; | 1545 CFX_Shading shading(FX_SHADING_Axial); |
1541 shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); | 1546 shading.CreateAxial(ptStart, ptEnd, FALSE, FALSE, crStart, crEnd); |
1542 CFX_Color cr(&shading); | 1547 CFX_Color cr(&shading); |
1543 pGS->SetFillColor(&cr); | 1548 pGS->SetFillColor(&cr); |
1544 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); | 1549 pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); |
1545 } | 1550 } |
1546 static void XFA_BOX_Fill(CXFA_Box box, | 1551 static void XFA_BOX_Fill(CXFA_Box box, |
1547 const CXFA_StrokeArray& strokes, | 1552 const CXFA_StrokeArray& strokes, |
1548 CFX_Graphics* pGS, | 1553 CFX_Graphics* pGS, |
1549 const CFX_RectF& rtWidget, | 1554 const CFX_RectF& rtWidget, |
1550 CFX_Matrix* pMatrix, | 1555 CFX_Matrix* pMatrix, |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 iType != XFA_ELEMENT_Rectangle) { | 1957 iType != XFA_ELEMENT_Rectangle) { |
1953 return; | 1958 return; |
1954 } | 1959 } |
1955 CXFA_StrokeArray strokes; | 1960 CXFA_StrokeArray strokes; |
1956 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { | 1961 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { |
1957 box.GetStrokes(strokes); | 1962 box.GetStrokes(strokes); |
1958 } | 1963 } |
1959 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1964 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
1960 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); | 1965 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); |
1961 } | 1966 } |
OLD | NEW |