| 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 bool bNotNeedRepaint; |
| 26 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 } |
| 38 |
| 25 IFWL_WidgetMgr* FWL_GetWidgetMgr() { | 39 IFWL_WidgetMgr* FWL_GetWidgetMgr() { |
| 26 IFWL_App* pApp = FWL_GetApp(); | 40 IFWL_App* pApp = FWL_GetApp(); |
| 27 if (!pApp) | 41 if (!pApp) |
| 28 return NULL; | 42 return NULL; |
| 29 return pApp->GetWidgetMgr(); | 43 return pApp->GetWidgetMgr(); |
| 30 } | 44 } |
| 45 |
| 31 CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) | 46 CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative) |
| 32 : m_dwCapability(0) { | 47 : m_dwCapability(0) { |
| 33 m_pDelegate = new CFWL_WidgetMgrDelegate(this); | 48 m_pDelegate = new CFWL_WidgetMgrDelegate(this); |
| 34 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); | 49 m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate); |
| 35 ASSERT(m_pAdapter); | 50 ASSERT(m_pAdapter); |
| 36 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; | 51 CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem; |
| 37 m_mapWidgetItem.SetAt(NULL, pRoot); | 52 m_mapWidgetItem.SetAt(NULL, pRoot); |
| 53 |
| 38 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 54 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 39 m_rtScreen.Reset(); | 55 m_rtScreen.Reset(); |
| 40 #endif | 56 #endif |
| 41 } | 57 } |
| 42 | 58 |
| 43 CFWL_WidgetMgr::~CFWL_WidgetMgr() { | 59 CFWL_WidgetMgr::~CFWL_WidgetMgr() { |
| 44 FX_POSITION ps = m_mapWidgetItem.GetStartPosition(); | 60 FX_POSITION ps = m_mapWidgetItem.GetStartPosition(); |
| 45 while (ps) { | 61 while (ps) { |
| 46 void* pWidget; | 62 void* pWidget; |
| 47 CFWL_WidgetMgrItem* pItem; | 63 CFWL_WidgetMgrItem* pItem; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); | 731 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); |
| 716 if (pTopLoop) { | 732 if (pTopLoop) { |
| 717 pNoteDriver->UnqueueMessage(pTopLoop); | 733 pNoteDriver->UnqueueMessage(pTopLoop); |
| 718 } | 734 } |
| 719 #endif | 735 #endif |
| 720 if (m_pWidgetMgr->IsThreadEnabled()) { | 736 if (m_pWidgetMgr->IsThreadEnabled()) { |
| 721 pMessage->Release(); | 737 pMessage->Release(); |
| 722 } | 738 } |
| 723 return FWL_ERR_Succeeded; | 739 return FWL_ERR_Succeeded; |
| 724 } | 740 } |
| 741 |
| 725 FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, | 742 FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, |
| 726 CFX_Graphics* pGraphics, | 743 CFX_Graphics* pGraphics, |
| 727 const CFX_Matrix* pMatrix) { | 744 const CFX_Matrix* pMatrix) { |
| 728 if (!pWidget) | 745 if (!pWidget) |
| 729 return FWL_ERR_Indefinite; | 746 return FWL_ERR_Indefinite; |
| 730 if (!pGraphics) | 747 if (!pGraphics) |
| 731 return FWL_ERR_Indefinite; | 748 return FWL_ERR_Indefinite; |
| 749 |
| 732 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); | 750 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); |
| 733 CFX_RectF clipCopy; | 751 CFX_RectF clipCopy; |
| 734 pWidget->GetWidgetRect(clipCopy); | 752 pWidget->GetWidgetRect(clipCopy); |
| 735 clipCopy.left = clipCopy.top = 0; | 753 clipCopy.left = clipCopy.top = 0; |
| 736 if (bUseOffscreenDirect(pWidget)) { | 754 if (bUseOffscreenDirect(pWidget)) { |
| 737 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 755 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 738 return FWL_ERR_Succeeded; | 756 return FWL_ERR_Succeeded; |
| 739 } | 757 } |
| 740 CFX_RectF clipBounds; | 758 CFX_RectF clipBounds; |
| 759 |
| 741 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \ | 760 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \ |
| 742 (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_) | 761 (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_) |
| 743 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); | 762 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); |
| 744 pDelegate->OnDrawWidget(pTemp, pMatrix); | 763 pDelegate->OnDrawWidget(pTemp, pMatrix); |
| 745 pGraphics->GetClipRect(clipBounds); | 764 pGraphics->GetClipRect(clipBounds); |
| 746 clipCopy = clipBounds; | 765 clipCopy = clipBounds; |
| 747 #elif(_FX_OS_ == _FX_MACOSX_) | 766 #elif(_FX_OS_ == _FX_MACOSX_) |
| 748 if (m_pWidgetMgr->IsFormDisabled()) { | 767 if (m_pWidgetMgr->IsFormDisabled()) { |
| 749 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); | 768 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); |
| 750 pDelegate->OnDrawWidget(pTemp, pMatrix); | 769 pDelegate->OnDrawWidget(pTemp, pMatrix); |
| 751 pGraphics->GetClipRect(clipBounds); | 770 pGraphics->GetClipRect(clipBounds); |
| 752 clipCopy = clipBounds; | 771 clipCopy = clipBounds; |
| 753 } else { | 772 } else { |
| 754 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); | 773 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); |
| 755 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. | 774 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. |
| 756 #ifdef FWL_UseMacSystemBorder | 775 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); |
| 757 #else | 776 pDelegate->OnDrawWidget(pTemp, pMatrix); |
| 758 #endif | |
| 759 { | |
| 760 IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL); | |
| 761 pDelegate->OnDrawWidget(pTemp, pMatrix); | |
| 762 } | |
| 763 } | 777 } |
| 764 #endif | 778 #endif // _FX_OS_ == _FX_MACOSX_ |
| 779 |
| 765 if (!m_pWidgetMgr->IsFormDisabled()) { | 780 if (!m_pWidgetMgr->IsFormDisabled()) { |
| 766 CFX_RectF rtClient; | 781 CFX_RectF rtClient; |
| 767 pWidget->GetClientRect(rtClient); | 782 pWidget->GetClientRect(rtClient); |
| 768 clipBounds.Intersect(rtClient); | 783 clipBounds.Intersect(rtClient); |
| 769 } | 784 } |
| 770 if (!clipBounds.IsEmpty()) { | 785 if (!clipBounds.IsEmpty()) |
| 771 DrawChild(pWidget, clipBounds, pTemp, pMatrix); | 786 DrawChild(pWidget, clipBounds, pTemp, pMatrix); |
| 772 } | 787 |
| 773 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 788 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 774 m_pWidgetMgr->ResetRedrawCounts(pWidget); | 789 m_pWidgetMgr->ResetRedrawCounts(pWidget); |
| 775 return FWL_ERR_Succeeded; | 790 return FWL_ERR_Succeeded; |
| 776 } | 791 } |
| 792 |
| 777 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, | 793 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, |
| 778 const CFX_RectF& rtClip, | 794 const CFX_RectF& rtClip, |
| 779 CFX_Graphics* pGraphics, | 795 CFX_Graphics* pGraphics, |
| 780 const CFX_Matrix* pMatrix) { | 796 const CFX_Matrix* pMatrix) { |
| 781 if (!parent) | 797 if (!parent) |
| 782 return; | 798 return; |
| 799 |
| 783 FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); | 800 FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); |
| 784 IFWL_Widget* pNextChild = | 801 IFWL_Widget* pNextChild = |
| 785 m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild); | 802 m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild); |
| 786 while (pNextChild) { | 803 while (pNextChild) { |
| 787 IFWL_Widget* child = pNextChild; | 804 IFWL_Widget* child = pNextChild; |
| 788 pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); | 805 pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); |
| 789 if (child->GetStates() & FWL_WGTSTATE_Invisible) { | 806 if (child->GetStates() & FWL_WGTSTATE_Invisible) |
| 790 continue; | 807 continue; |
| 791 } | 808 |
| 792 CFX_RectF rtWidget; | 809 CFX_RectF rtWidget; |
| 793 child->GetWidgetRect(rtWidget); | 810 child->GetWidgetRect(rtWidget); |
| 794 if (rtWidget.IsEmpty()) { | 811 if (rtWidget.IsEmpty()) |
| 795 continue; | 812 continue; |
| 796 } | 813 |
| 797 CFX_Matrix widgetMatrix; | 814 CFX_Matrix widgetMatrix; |
| 798 CFX_RectF clipBounds(rtWidget); | 815 CFX_RectF clipBounds(rtWidget); |
| 799 if (!bFormDisable) { | 816 if (!bFormDisable) |
| 800 child->GetMatrix(widgetMatrix, TRUE); | 817 child->GetMatrix(widgetMatrix, TRUE); |
| 801 } | 818 if (pMatrix) |
| 802 if (pMatrix) { | |
| 803 widgetMatrix.Concat(*pMatrix); | 819 widgetMatrix.Concat(*pMatrix); |
| 804 } | 820 |
| 805 if (!bFormDisable) { | 821 if (!bFormDisable) { |
| 806 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); | 822 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); |
| 807 clipBounds.Intersect(rtClip); | 823 clipBounds.Intersect(rtClip); |
| 808 if (clipBounds.IsEmpty()) { | 824 if (clipBounds.IsEmpty()) |
| 809 continue; | 825 continue; |
| 810 } | 826 |
| 811 pGraphics->SaveGraphState(); | 827 pGraphics->SaveGraphState(); |
| 812 pGraphics->SetClipRect(clipBounds); | 828 pGraphics->SetClipRect(clipBounds); |
| 813 } | 829 } |
| 814 widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); | 830 widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); |
| 815 IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL); | 831 IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL); |
| 816 if (pDelegate) { | 832 if (pDelegate) { |
| 817 if (m_pWidgetMgr->IsFormDisabled() || | 833 if (m_pWidgetMgr->IsFormDisabled() || |
| 818 IsNeedRepaint(child, &widgetMatrix, rtClip)) { | 834 IsNeedRepaint(child, &widgetMatrix, rtClip)) { |
| 819 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); | 835 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); |
| 820 } | 836 } |
| 821 } | 837 } |
| 822 if (!bFormDisable) { | 838 if (!bFormDisable) |
| 823 pGraphics->RestoreGraphState(); | 839 pGraphics->RestoreGraphState(); |
| 824 } | 840 |
| 825 DrawChild(child, clipBounds, pGraphics, | 841 DrawChild(child, clipBounds, pGraphics, |
| 826 bFormDisable ? &widgetMatrix : pMatrix); | 842 bFormDisable ? &widgetMatrix : pMatrix); |
| 827 child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); | 843 child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling); |
| 828 } | 844 } |
| 829 } | 845 } |
| 846 |
| 830 CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( | 847 CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( |
| 831 IFWL_Widget* pWidget, | 848 IFWL_Widget* pWidget, |
| 832 CFX_Graphics* pGraphics, | 849 CFX_Graphics* pGraphics, |
| 833 const CFX_Matrix* pMatrix) { | 850 const CFX_Matrix* pMatrix) { |
| 834 if (!FWL_UseOffscreen(pWidget)) { | 851 if (!FWL_UseOffscreen(pWidget)) |
| 835 return pGraphics; | 852 return pGraphics; |
| 836 } | 853 |
| 837 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 854 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 838 if (!pItem->pOffscreen) { | 855 if (!pItem->pOffscreen) { |
| 839 pItem->pOffscreen = new CFX_Graphics; | 856 pItem->pOffscreen = new CFX_Graphics; |
| 840 CFX_RectF rect; | 857 CFX_RectF rect; |
| 841 pWidget->GetWidgetRect(rect); | 858 pWidget->GetWidgetRect(rect); |
| 842 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, | 859 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, |
| 843 FXDIB_Argb); | 860 FXDIB_Argb); |
| 844 } | 861 } |
| 845 CFX_RectF rect; | 862 CFX_RectF rect; |
| 846 pGraphics->GetClipRect(rect); | 863 pGraphics->GetClipRect(rect); |
| 847 pItem->pOffscreen->SetClipRect(rect); | 864 pItem->pOffscreen->SetClipRect(rect); |
| 848 return pItem->pOffscreen; | 865 return pItem->pOffscreen; |
| 849 } | 866 } |
| 867 |
| 850 void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, | 868 void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, |
| 851 CFX_Graphics* pGraphics, | 869 CFX_Graphics* pGraphics, |
| 852 CFX_RectF& rtClip, | 870 CFX_RectF& rtClip, |
| 853 const CFX_Matrix* pMatrix) { | 871 const CFX_Matrix* pMatrix) { |
| 854 if (FWL_UseOffscreen(pWidget)) { | 872 if (FWL_UseOffscreen(pWidget)) { |
| 855 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 873 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 856 pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, | 874 pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip, |
| 857 pMatrix); | 875 pMatrix); |
| 858 #ifdef _WIN32 | 876 #ifdef _WIN32 |
| 859 pItem->pOffscreen->ClearClip(); | 877 pItem->pOffscreen->ClearClip(); |
| 860 #endif | 878 #endif |
| 861 } | 879 } |
| 862 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 880 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 863 pItem->iRedrawCounter = 0; | 881 pItem->iRedrawCounter = 0; |
| 864 } | 882 } |
| 865 | 883 |
| 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, | 884 FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, |
| 875 CFX_Matrix* pMatrix, | 885 CFX_Matrix* pMatrix, |
| 876 const CFX_RectF& rtDirty) { | 886 const CFX_RectF& rtDirty) { |
| 877 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 887 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 878 if (pItem && pItem->iRedrawCounter > 0) { | 888 if (pItem && pItem->iRedrawCounter > 0) { |
| 879 pItem->iRedrawCounter = 0; | 889 pItem->iRedrawCounter = 0; |
| 880 return TRUE; | 890 return TRUE; |
| 881 } | 891 } |
| 882 CFX_RectF rtWidget; | 892 CFX_RectF rtWidget; |
| 883 pWidget->GetWidgetRect(rtWidget); | 893 pWidget->GetWidgetRect(rtWidget); |
| 884 rtWidget.left = rtWidget.top = 0; | 894 rtWidget.left = rtWidget.top = 0; |
| 885 pMatrix->TransformRect(rtWidget); | 895 pMatrix->TransformRect(rtWidget); |
| 886 if (!rtWidget.IntersectWith(rtDirty)) { | 896 if (!rtWidget.IntersectWith(rtDirty)) |
| 887 return FALSE; | 897 return FALSE; |
| 888 } | 898 |
| 889 IFWL_Widget* pChild = | 899 IFWL_Widget* pChild = |
| 890 FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); | 900 FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild); |
| 891 if (!pChild) { | 901 if (!pChild) |
| 892 return TRUE; | 902 return TRUE; |
| 893 } | |
| 894 if (pChild->GetClassID() == 3150298670) { | 903 if (pChild->GetClassID() == 3150298670) { |
| 895 CFX_RectF rtTemp; | 904 CFX_RectF rtTemp; |
| 896 pChild->GetWidgetRect(rtTemp); | 905 pChild->GetWidgetRect(rtTemp); |
| 897 if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) { | 906 if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) { |
| 898 pChild = | 907 pChild = |
| 899 FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild); | 908 FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild); |
| 900 if (!pChild) { | 909 if (!pChild) |
| 901 return TRUE; | 910 return TRUE; |
| 902 } | |
| 903 } | 911 } |
| 904 } | 912 } |
| 905 CFX_RectF rtChilds; | 913 CFX_RectF rtChilds; |
| 906 rtChilds.Empty(); | 914 rtChilds.Empty(); |
| 907 FX_BOOL bChildIntersectWithDirty = FALSE; | 915 FX_BOOL bChildIntersectWithDirty = FALSE; |
| 908 FX_BOOL bOrginPtIntersectWidthChild = FALSE; | 916 FX_BOOL bOrginPtIntersectWidthChild = FALSE; |
| 909 FX_BOOL bOrginPtIntersectWidthDirty = | 917 FX_BOOL bOrginPtIntersectWidthDirty = |
| 910 rtDirty.Contains(rtWidget.left, rtWidget.top); | 918 rtDirty.Contains(rtWidget.left, rtWidget.top); |
| 911 static FWL_NEEDREPAINTHITDATA hitPoint[FWL_NEEDREPAINTHIT_Point]; | 919 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; |
| 912 int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA); | 920 int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA); |
| 913 FXSYS_memset(hitPoint, 0, iSize); | 921 FXSYS_memset(hitPoint, 0, iSize); |
| 914 FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece; | 922 FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; |
| 915 FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece; | 923 FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece; |
| 916 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; | 924 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; |
| 917 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = | 925 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = |
| 918 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; | 926 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; |
| 919 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = | 927 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = |
| 920 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; | 928 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; |
| 921 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = | 929 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = |
| 922 rtWidget.width + rtWidget.left; | 930 rtWidget.width + rtWidget.left; |
| 923 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; | 931 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; |
| 924 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = | 932 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = |
| 925 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; | 933 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; |
| 926 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = | 934 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = |
| 927 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; | 935 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; |
| 928 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = | 936 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = |
| 929 rtWidget.height + rtWidget.top; | 937 rtWidget.height + rtWidget.top; |
| 930 do { | 938 do { |
| 931 CFX_RectF rect; | 939 CFX_RectF rect; |
| 932 pChild->GetWidgetRect(rect); | 940 pChild->GetWidgetRect(rect); |
| 933 CFX_RectF r = rect; | 941 CFX_RectF r = rect; |
| 934 r.left += rtWidget.left; | 942 r.left += rtWidget.left; |
| 935 r.top += rtWidget.top; | 943 r.top += rtWidget.top; |
| 936 if (r.IsEmpty()) { | 944 if (r.IsEmpty()) |
| 937 continue; | 945 continue; |
| 938 } | 946 if (r.Contains(rtDirty)) |
| 939 if (r.Contains(rtDirty)) { | |
| 940 return FALSE; | 947 return FALSE; |
| 941 } | 948 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) |
| 942 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) { | |
| 943 bChildIntersectWithDirty = TRUE; | 949 bChildIntersectWithDirty = TRUE; |
| 944 } | 950 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) |
| 945 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) |
| 960 continue; |
| 961 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { |
| 962 hitPoint[i].bNotContainByDirty = true; |
| 955 continue; | 963 continue; |
| 956 } | 964 } |
| 957 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { | 965 if (r.Contains(hitPoint[i].hitPoint)) |
| 958 hitPoint[i].bNotContainByDirty = TRUE; | 966 hitPoint[i].bNotNeedRepaint = true; |
| 959 continue; | |
| 960 } | |
| 961 if (r.Contains(hitPoint[i].hitPoint)) { | |
| 962 hitPoint[i].bNotNeedRepaint = TRUE; | |
| 963 } | |
| 964 } | 967 } |
| 965 } while ((pChild = FWL_GetWidgetMgr()->GetWidget( | 968 } while ((pChild = FWL_GetWidgetMgr()->GetWidget( |
| 966 pChild, FWL_WGTRELATION_NextSibling)) != NULL); | 969 pChild, FWL_WGTRELATION_NextSibling)) != NULL); |
| 967 if (!bChildIntersectWithDirty) { | 970 |
| 971 if (!bChildIntersectWithDirty) |
| 968 return TRUE; | 972 return TRUE; |
| 973 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) |
| 974 return TRUE; |
| 975 if (rtChilds.IsEmpty()) |
| 976 return TRUE; |
| 977 |
| 978 int32_t repaintPoint = kNeedRepaintHitPoints; |
| 979 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
| 980 if (hitPoint[i].bNotNeedRepaint) |
| 981 repaintPoint--; |
| 969 } | 982 } |
| 970 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) { | 983 if (repaintPoint > 0) |
| 971 return TRUE; | 984 return TRUE; |
| 972 } | 985 |
| 973 if (rtChilds.IsEmpty()) { | |
| 974 return TRUE; | |
| 975 } | |
| 976 int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point; | |
| 977 for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) { | |
| 978 if (hitPoint[i].bNotNeedRepaint) { | |
| 979 repaintPoint--; | |
| 980 } | |
| 981 } | |
| 982 if (repaintPoint > 0) { | |
| 983 return TRUE; | |
| 984 } | |
| 985 pMatrix->TransformRect(rtChilds); | 986 pMatrix->TransformRect(rtChilds); |
| 986 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) { | 987 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) |
| 987 return FALSE; | 988 return FALSE; |
| 988 } | |
| 989 return TRUE; | 989 return TRUE; |
| 990 } | 990 } |
| 991 |
| 991 FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { | 992 FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { |
| 992 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 993 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
| 993 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) { | 994 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) |
| 994 return FALSE; | 995 return FALSE; |
| 995 } | 996 |
| 996 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 997 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 997 if (pItem->bOutsideChanged) { | 998 if (pItem->bOutsideChanged) { |
| 998 CFX_RectF r; | 999 CFX_RectF r; |
| 999 pWidget->GetWidgetRect(r); | 1000 pWidget->GetWidgetRect(r); |
| 1000 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 1001 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); |
| 1001 temp.Deflate(50, 50); | 1002 temp.Deflate(50, 50); |
| 1002 if (!temp.Contains(r)) { | 1003 if (!temp.Contains(r)) |
| 1003 return FALSE; | 1004 return FALSE; |
| 1004 } | 1005 |
| 1005 pItem->bOutsideChanged = FALSE; | 1006 pItem->bOutsideChanged = FALSE; |
| 1006 } | 1007 } |
| 1007 #endif | 1008 #endif |
| 1009 |
| 1008 return pItem->iRedrawCounter == 0; | 1010 return pItem->iRedrawCounter == 0; |
| 1009 } | 1011 } |
| OLD | NEW |