Changeset 561 for trunk/src/gui/painting/qregion.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/painting/qregion.cpp
r95 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 #include <qdebug.h> 51 51 52 #if defined(Q_OS_UNIX) || defined(Q_ OS_WINCE)52 #if defined(Q_OS_UNIX) || defined(Q_WS_WIN) 53 53 #include "qimage.h" 54 54 #include "qbitmap.h" … … 62 62 \brief The QRegion class specifies a clip region for a painter. 63 63 64 \ingroup multimedia64 \ingroup painting 65 65 \ingroup shared 66 66 … … 92 92 Example of using complex regions: 93 93 \snippet doc/src/snippets/code/src_gui_painting_qregion.cpp 0 94 95 \warning Due to window system limitations, the whole coordinate space for a96 region is limited to the points between -32767 and 32767 on Windows97 95/98/ME. You can circumvent this limitation by using a QPainterPath.98 94 99 95 \section1 Additional License Information … … 451 447 QVector<QRect> rects = r.rects(); 452 448 s.nospace() << "QRegion(size=" << rects.size() << "), " 453 << "bounds = " << r.boundingRect() << "\n";449 << "bounds = " << r.boundingRect() << '\n'; 454 450 for (int i=0; i<rects.size(); ++i) 455 s << "- " << i << rects.at(i) << "\n";451 s << "- " << i << rects.at(i) << '\n'; 456 452 return s; 457 453 } … … 550 546 \sa intersected() 551 547 */ 552 #if !defined (Q_OS_UNIX) && !defined (Q_ OS_WINCE)548 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) 553 549 QRegion& QRegion::operator+=(const QRect &r) 554 550 { … … 566 562 \sa intersected() 567 563 */ 568 #if (!defined(Q_WS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_WS_PM)569 564 QRegion& QRegion::operator&=(const QRegion &r) 570 565 { return *this = *this & r; } 571 #endif572 566 573 567 /*! … … 575 569 \since 4.4 576 570 */ 577 #if defined (Q_OS_UNIX) || defined (Q_ OS_WINCE)571 #if defined (Q_OS_UNIX) || defined (Q_WS_WIN) 578 572 QRegion& QRegion::operator&=(const QRect &r) 579 573 { … … 596 590 \sa subtracted() 597 591 */ 598 #if (!defined(Q_WS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_WS_PM)599 592 QRegion& QRegion::operator-=(const QRegion &r) 600 593 { return *this = *this - r; } 601 #endif602 594 603 595 /*! … … 699 691 if (!rect_intersects(boundingRect(), region.boundingRect())) 700 692 return false; 693 if (rectCount() == 1 && region.rectCount() == 1) 694 return true; 701 695 702 696 const QVector<QRect> myRects = rects(); … … 724 718 if (!rect_intersects(boundingRect(), r)) 725 719 return false; 720 if (rectCount() == 1) 721 return true; 726 722 727 723 const QVector<QRect> myRects = rects(); … … 732 728 } 733 729 734 #if !defined (Q_OS_UNIX) && !defined (Q_ OS_WINCE)730 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) 735 731 /*! 736 732 \overload … … 744 740 745 741 /*! 742 \obsolete 746 743 \fn int QRegion::numRects() const 747 744 \since 4.4 745 746 Returns the number of rectangles that will be returned in rects(). 747 */ 748 749 /*! 750 \fn int QRegion::rectCount() const 751 \since 4.6 748 752 749 753 Returns the number of rectangles that will be returned in rects(). … … 1032 1036 { 1033 1037 QPainterPath result; 1034 if (region. numRects() == 1) {1038 if (region.rectCount() == 1) { 1035 1039 result.addRect(region.boundingRect()); 1036 1040 return result; … … 1087 1091 } 1088 1092 1089 #if defined(Q_OS_UNIX) || defined(Q_ OS_WINCE)1093 #if defined(Q_OS_UNIX) || defined(Q_WS_WIN) 1090 1094 1091 1095 //#define QT_REGION_DEBUG … … 1602 1606 const QRect r = rects.at(i); 1603 1607 if ((r.width() * r.height()) > innerArea) 1604 qDebug() << "selfTest(): innerRect" << innerRect << "<"<< r;1608 qDebug() << "selfTest(): innerRect" << innerRect << '<' << r; 1605 1609 } 1606 1610 … … 1628 1632 # include "qregion_mac.cpp" 1629 1633 QT_END_INCLUDE_NAMESPACE 1630 #elif defined(Q_ OS_WINCE)1634 #elif defined(Q_WS_WIN) 1631 1635 QT_BEGIN_INCLUDE_NAMESPACE 1632 # include "qregion_win ce.cpp"1636 # include "qregion_win.cpp" 1633 1637 QT_END_INCLUDE_NAMESPACE 1634 1638 #elif defined(Q_WS_QWS) … … 3168 3172 tmpSLLBlock = 3169 3173 (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); 3174 Q_CHECK_PTR(tmpSLLBlock); 3170 3175 (*SLLBlock)->next = tmpSLLBlock; 3171 3176 tmpSLLBlock->next = (ScanLineListBlock *)NULL; … … 3554 3559 * encoding of the resultant bitmap -- the run-length 3555 3560 * encoding is in the form of an array of rectangles. 3561 * 3562 * Can return 0 in case of errors. 3556 3563 */ 3557 3564 static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) … … 3625 3632 3626 3633 3627 if (rule == EvenOddRule) { 3628 /* 3629 * for each scanline 3630 */ 3631 for (y = ET.ymin; y < ET.ymax; ++y) { 3632 3634 QT_TRY { 3635 if (rule == EvenOddRule) { 3633 3636 /* 3634 * Add a new edge to the active edge table when we 3635 * get to the next edge. 3637 * for each scanline 3636 3638 */ 3637 if (pSLL && y == pSLL->scanline) { 3638 loadAET(&AET, pSLL->edgelist); 3639 pSLL = pSLL->next; 3640 } 3641 pPrevAET = &AET; 3642 pAET = AET.next; 3643 3644 /* 3645 * for each active edge 3646 */ 3647 while (pAET) { 3648 pts->setX(pAET->bres.minor_axis); 3649 pts->setY(y); 3650 ++pts; 3651 ++iPts; 3639 for (y = ET.ymin; y < ET.ymax; ++y) { 3652 3640 3653 3641 /* 3654 * send out the buffer 3642 * Add a new edge to the active edge table when we 3643 * get to the next edge. 3655 3644 */ 3656 if (iPts == NUMPTSTOBUFFER) { 3657 tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); 3658 tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); 3659 curPtBlock->next = tmpPtBlock; 3660 curPtBlock = tmpPtBlock; 3661 pts = curPtBlock->pts; 3662 ++numFullPtBlocks; 3663 iPts = 0; 3645 if (pSLL && y == pSLL->scanline) { 3646 loadAET(&AET, pSLL->edgelist); 3647 pSLL = pSLL->next; 3664 3648 } 3665 EVALUATEEDGEEVENODD(pAET, pPrevAET, y) 3666 } 3667 InsertionSort(&AET); 3668 } 3669 } else { 3670 /* 3671 * for each scanline 3672 */ 3673 for (y = ET.ymin; y < ET.ymax; ++y) { 3674 /* 3675 * Add a new edge to the active edge table when we 3676 * get to the next edge. 3677 */ 3678 if (pSLL && y == pSLL->scanline) { 3679 loadAET(&AET, pSLL->edgelist); 3680 computeWAET(&AET); 3681 pSLL = pSLL->next; 3682 } 3683 pPrevAET = &AET; 3684 pAET = AET.next; 3685 pWETE = pAET; 3686 3687 /* 3688 * for each active edge 3689 */ 3690 while (pAET) { 3649 pPrevAET = &AET; 3650 pAET = AET.next; 3651 3691 3652 /* 3692 * add to the buffer only those edges that 3693 * are in the Winding active edge table. 3653 * for each active edge 3694 3654 */ 3695 if (pWETE ==pAET) {3655 while (pAET) { 3696 3656 pts->setX(pAET->bres.minor_axis); 3697 3657 pts->setY(y); … … 3703 3663 */ 3704 3664 if (iPts == NUMPTSTOBUFFER) { 3705 tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK))); 3665 tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK)); 3666 Q_CHECK_PTR(tmpPtBlock); 3706 3667 tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); 3707 3668 curPtBlock->next = tmpPtBlock; … … 3711 3672 iPts = 0; 3712 3673 } 3713 pWETE = pWETE->nextWETE;3674 EVALUATEEDGEEVENODD(pAET, pPrevAET, y) 3714 3675 } 3715 EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)3676 InsertionSort(&AET); 3716 3677 } 3717 3678 } else { 3718 3679 /* 3719 * recompute the winding active edge table if 3720 * we just resorted or have exited an edge. 3680 * for each scanline 3721 3681 */ 3722 if (InsertionSort(&AET) || fixWAET) { 3723 computeWAET(&AET); 3724 fixWAET = false; 3682 for (y = ET.ymin; y < ET.ymax; ++y) { 3683 /* 3684 * Add a new edge to the active edge table when we 3685 * get to the next edge. 3686 */ 3687 if (pSLL && y == pSLL->scanline) { 3688 loadAET(&AET, pSLL->edgelist); 3689 computeWAET(&AET); 3690 pSLL = pSLL->next; 3691 } 3692 pPrevAET = &AET; 3693 pAET = AET.next; 3694 pWETE = pAET; 3695 3696 /* 3697 * for each active edge 3698 */ 3699 while (pAET) { 3700 /* 3701 * add to the buffer only those edges that 3702 * are in the Winding active edge table. 3703 */ 3704 if (pWETE == pAET) { 3705 pts->setX(pAET->bres.minor_axis); 3706 pts->setY(y); 3707 ++pts; 3708 ++iPts; 3709 3710 /* 3711 * send out the buffer 3712 */ 3713 if (iPts == NUMPTSTOBUFFER) { 3714 tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK))); 3715 tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data); 3716 curPtBlock->next = tmpPtBlock; 3717 curPtBlock = tmpPtBlock; 3718 pts = curPtBlock->pts; 3719 ++numFullPtBlocks; 3720 iPts = 0; 3721 } 3722 pWETE = pWETE->nextWETE; 3723 } 3724 EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) 3725 } 3726 3727 /* 3728 * recompute the winding active edge table if 3729 * we just resorted or have exited an edge. 3730 */ 3731 if (InsertionSort(&AET) || fixWAET) { 3732 computeWAET(&AET); 3733 fixWAET = false; 3734 } 3725 3735 } 3726 3736 } 3727 } 3737 } QT_CATCH(...) { 3738 FreeStorage(SLLBlock.next); 3739 PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); 3740 for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) { 3741 tmpPtBlock = curPtBlock->next; 3742 free(curPtBlock); 3743 curPtBlock = tmpPtBlock; 3744 } 3745 free(pETEs); 3746 return 0; // this function returns 0 in case of an error 3747 } 3748 3728 3749 FreeStorage(SLLBlock.next); 3729 3750 PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region); … … 3830 3851 d->rgn = 0; 3831 3852 d->xrectangles = 0; 3832 #elif defined(Q_ OS_WINCE)3853 #elif defined(Q_WS_WIN) 3833 3854 d->rgn = 0; 3834 3855 #endif … … 3847 3868 { 3848 3869 if (a.count() > 2) { 3849 d = new QRegionData; 3850 d->ref = 1; 3870 QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), 3871 fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); 3872 if (qt_rgn) { 3873 d = new QRegionData; 3874 d->ref = 1; 3851 3875 #if defined(Q_WS_X11) 3852 d->rgn = 0;3853 d->xrectangles = 0;3854 #elif defined(Q_ OS_WINCE)3855 d->rgn = 0;3876 d->rgn = 0; 3877 d->xrectangles = 0; 3878 #elif defined(Q_WS_WIN) 3879 d->rgn = 0; 3856 3880 #endif 3857 d->qt_rgn = PolygonRegion(a.constData(), a.size(), 3858 fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); 3881 d->qt_rgn = qt_rgn; 3882 } else { 3883 d = &shared_empty; 3884 d->ref.ref(); 3885 } 3859 3886 } else { 3860 3887 d = &shared_empty; … … 3862 3889 } 3863 3890 } 3864 3865 3891 3866 3892 QRegion::QRegion(const QRegion &r) … … 3882 3908 d->rgn = 0; 3883 3909 d->xrectangles = 0; 3884 #elif defined(Q_ OS_WINCE)3910 #elif defined(Q_WS_WIN) 3885 3911 d->rgn = 0; 3886 3912 #endif … … 3897 3923 if (x->xrectangles) 3898 3924 free(x->xrectangles); 3899 #elif defined(Q_ OS_WINCE)3925 #elif defined(Q_WS_WIN) 3900 3926 if (x->rgn) 3901 3927 qt_win_dispose_rgn(x->rgn); … … 3924 3950 \internal 3925 3951 */ 3926 3927 3952 QRegion QRegion::copy() const 3928 3953 { 3929 3954 QRegion r; 3930 Q RegionData *x = new QRegionData;3955 QScopedPointer<QRegionData> x(new QRegionData); 3931 3956 x->ref = 1; 3932 3957 #if defined(Q_WS_X11) 3933 3958 x->rgn = 0; 3934 3959 x->xrectangles = 0; 3935 #elif defined(Q_ OS_WINCE)3960 #elif defined(Q_WS_WIN) 3936 3961 x->rgn = 0; 3937 3962 #endif … … 3942 3967 if (!r.d->ref.deref()) 3943 3968 cleanUp(r.d); 3944 r.d = x ;3969 r.d = x.take(); 3945 3970 return r; 3946 3971 } … … 4306 4331 } 4307 4332 4333 int QRegion::rectCount() const 4334 { 4335 return (d->qt_rgn ? d->qt_rgn->numRects : 0); 4336 } 4337 4338 4308 4339 bool QRegion::operator==(const QRegion &r) const 4309 4340 {
Note:
See TracChangeset
for help on using the changeset viewer.