Chromium Code Reviews| 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/fwl/core/fwl_widgetmgrimp.h" | 7 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
| 10 #include "xfa/fwl/core/fwl_appimp.h" | 10 #include "xfa/fwl/core/fwl_appimp.h" |
| 11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
| 12 #include "xfa/fwl/core/fwl_widgetimp.h" | 12 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 13 #include "xfa/fwl/core/ifwl_adapternative.h" | 13 #include "xfa/fwl/core/ifwl_adapternative.h" |
| 14 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | 14 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" |
| 15 #include "xfa/fwl/core/ifwl_app.h" | 15 #include "xfa/fwl/core/ifwl_app.h" |
| 16 #include "xfa/fwl/core/ifwl_form.h" | 16 #include "xfa/fwl/core/ifwl_form.h" |
| 17 | 17 |
| 18 namespace { | |
| 19 | |
| 20 const int kNeedRepaintHitPoints = 12; | |
| 21 const int kNeedRepaintHitPiece = 3; | |
| 22 | |
| 23 struct FWL_NEEDREPAINTHITDATA { | |
| 24 CFX_PointF hitPoint; | |
| 25 FX_BOOL bNotNeedRepaint; | |
|
Tom Sepez
2016/05/02 21:45:39
can these be bools?
dsinclair
2016/05/03 13:58:16
Done.
| |
| 26 FX_BOOL bNotContainByDirty; | |
| 27 }; | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 18 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { | 31 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { |
| 19 #if (_FX_OS_ == _FX_MACOSX_) | 32 #if (_FX_OS_ == _FX_MACOSX_) |
| 20 return FALSE; | 33 return FALSE; |
| 21 #else | 34 #else |
| 22 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; | 35 return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen; |
| 23 #endif | 36 #endif |
| 24 } | 37 } |
| 25 IFWL_WidgetMgr* FWL_GetWidgetMgr() { | 38 IFWL_WidgetMgr* FWL_GetWidgetMgr() { |
| 26 IFWL_App* pApp = FWL_GetApp(); | 39 IFWL_App* pApp = FWL_GetApp(); |
| 27 if (!pApp) | 40 if (!pApp) |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, | 869 pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, |
| 857 pMatrix); | 870 pMatrix); |
| 858 #ifdef _WIN32 | 871 #ifdef _WIN32 |
| 859 pItem->pOffscreen->ClearClip(); | 872 pItem->pOffscreen->ClearClip(); |
| 860 #endif | 873 #endif |
| 861 } | 874 } |
| 862 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 875 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 863 pItem->iRedrawCounter = 0; | 876 pItem->iRedrawCounter = 0; |
| 864 } | 877 } |
| 865 | 878 |
| 866 #define FWL_NEEDREPAINTHIT_Point 12 | |
| 867 #define FWL_NEEDREPAINTHIT_Piece 3 | |
| 868 struct FWL_NEEDREPAINTHITDATA { | |
| 869 CFX_PointF hitPoint; | |
| 870 FX_BOOL bNotNeedRepaint; | |
| 871 FX_BOOL bNotContainByDirty; | |
| 872 }; | |
| 873 | |
| 874 FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, | 879 FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, |
| 875 CFX_Matrix* pMatrix, | 880 CFX_Matrix* pMatrix, |
| 876 const CFX_RectF& rtDirty) { | 881 const CFX_RectF& rtDirty) { |
| 877 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 882 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 878 if (pItem && pItem->iRedrawCounter > 0) { | 883 if (pItem && pItem->iRedrawCounter > 0) { |
| 879 pItem->iRedrawCounter = 0; | 884 pItem->iRedrawCounter = 0; |
| 880 return TRUE; | 885 return TRUE; |
| 881 } | 886 } |
| 882 CFX_RectF rtWidget; | 887 CFX_RectF rtWidget; |
| 883 pWidget->GetWidgetRect(rtWidget); | 888 pWidget->GetWidgetRect(rtWidget); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 901 return TRUE; | 906 return TRUE; |
| 902 } | 907 } |
| 903 } | 908 } |
| 904 } | 909 } |
| 905 CFX_RectF rtChilds; | 910 CFX_RectF rtChilds; |
| 906 rtChilds.Empty(); | 911 rtChilds.Empty(); |
| 907 FX_BOOL bChildIntersectWithDirty = FALSE; | 912 FX_BOOL bChildIntersectWithDirty = FALSE; |
| 908 FX_BOOL bOrginPtIntersectWidthChild = FALSE; | 913 FX_BOOL bOrginPtIntersectWidthChild = FALSE; |
| 909 FX_BOOL bOrginPtIntersectWidthDirty = | 914 FX_BOOL bOrginPtIntersectWidthDirty = |
| 910 rtDirty.Contains(rtWidget.left, rtWidget.top); | 915 rtDirty.Contains(rtWidget.left, rtWidget.top); |
| 911 static FWL_NEEDREPAINTHITDATA hitPoint[FWL_NEEDREPAINTHIT_Point]; | 916 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; |
| 912 int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA); | 917 int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA); |
| 913 FXSYS_memset(hitPoint, 0, iSize); | 918 FXSYS_memset(hitPoint, 0, iSize); |
| 914 FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece; | 919 FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; |
| 915 FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece; | 920 FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece; |
| 916 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; | 921 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; |
| 917 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = | 922 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = |
| 918 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; | 923 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; |
| 919 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = | 924 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = |
| 920 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; | 925 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; |
| 921 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = | 926 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = |
| 922 rtWidget.width + rtWidget.left; | 927 rtWidget.width + rtWidget.left; |
| 923 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; | 928 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; |
| 924 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = | 929 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = |
| 925 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; | 930 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 943 bChildIntersectWithDirty = TRUE; | 948 bChildIntersectWithDirty = TRUE; |
| 944 } | 949 } |
| 945 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { | 950 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { |
| 946 bOrginPtIntersectWidthChild = rect.Contains(0, 0); | 951 bOrginPtIntersectWidthChild = rect.Contains(0, 0); |
| 947 } | 952 } |
| 948 if (rtChilds.IsEmpty()) { | 953 if (rtChilds.IsEmpty()) { |
| 949 rtChilds = rect; | 954 rtChilds = rect; |
| 950 } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) { | 955 } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) { |
| 951 rtChilds.Union(rect); | 956 rtChilds.Union(rect); |
| 952 } | 957 } |
| 953 for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) { | 958 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
| 954 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) { | 959 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) { |
| 955 continue; | 960 continue; |
| 956 } | 961 } |
| 957 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { | 962 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { |
| 958 hitPoint[i].bNotContainByDirty = TRUE; | 963 hitPoint[i].bNotContainByDirty = TRUE; |
| 959 continue; | 964 continue; |
| 960 } | 965 } |
| 961 if (r.Contains(hitPoint[i].hitPoint)) { | 966 if (r.Contains(hitPoint[i].hitPoint)) { |
| 962 hitPoint[i].bNotNeedRepaint = TRUE; | 967 hitPoint[i].bNotNeedRepaint = TRUE; |
| 963 } | 968 } |
| 964 } | 969 } |
| 965 } while ((pChild = FWL_GetWidgetMgr()->GetWidget( | 970 } while ((pChild = FWL_GetWidgetMgr()->GetWidget( |
| 966 pChild, FWL_WGTRELATION_NextSibling)) != NULL); | 971 pChild, FWL_WGTRELATION_NextSibling)) != NULL); |
| 967 if (!bChildIntersectWithDirty) { | 972 if (!bChildIntersectWithDirty) { |
| 968 return TRUE; | 973 return TRUE; |
| 969 } | 974 } |
| 970 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { | 975 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { |
| 971 return TRUE; | 976 return TRUE; |
| 972 } | 977 } |
| 973 if (rtChilds.IsEmpty()) { | 978 if (rtChilds.IsEmpty()) { |
| 974 return TRUE; | 979 return TRUE; |
| 975 } | 980 } |
| 976 int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point; | 981 int32_t repaintPoint = kNeedRepaintHitPoints; |
| 977 for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) { | 982 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
| 978 if (hitPoint[i].bNotNeedRepaint) { | 983 if (hitPoint[i].bNotNeedRepaint) { |
| 979 repaintPoint--; | 984 repaintPoint--; |
| 980 } | 985 } |
| 981 } | 986 } |
| 982 if (repaintPoint > 0) { | 987 if (repaintPoint > 0) { |
| 983 return TRUE; | 988 return TRUE; |
| 984 } | 989 } |
| 985 pMatrix->TransformRect(rtChilds); | 990 pMatrix->TransformRect(rtChilds); |
| 986 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) { | 991 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) { |
| 987 return FALSE; | 992 return FALSE; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1000 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 1005 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); |
| 1001 temp.Deflate(50, 50); | 1006 temp.Deflate(50, 50); |
| 1002 if (!temp.Contains(r)) { | 1007 if (!temp.Contains(r)) { |
| 1003 return FALSE; | 1008 return FALSE; |
| 1004 } | 1009 } |
| 1005 pItem->bOutsideChanged = FALSE; | 1010 pItem->bOutsideChanged = FALSE; |
| 1006 } | 1011 } |
| 1007 #endif | 1012 #endif |
| 1008 return pItem->iRedrawCounter == 0; | 1013 return pItem->iRedrawCounter == 0; |
| 1009 } | 1014 } |
| OLD | NEW |