Changeset 61 for trunk/src/kernel/qpainter_pm.cpp
- Timestamp:
- Feb 6, 2006, 10:43:39 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel/qpainter_pm.cpp
r59 r61 42 42 #include "qpixmapcache.h" 43 43 #include "qptrlist.h" 44 // @@TODO (dmik):later44 /// @todo (dmik) later 45 45 //#include "qprinter.h" 46 46 #include <stdlib.h> … … 53 53 #include "qfontengine_p.h" 54 54 55 //@@TODO (dmik): does OS/2 have this bug?56 ///*57 // Workaround for win32 bug. When GM_ADVANCED graphicsmode is used with a non identity58 // matrix, subsequent calls to Ellipse, Chord and Pie will be inclusive. Also after59 // graphics mode is reset to GM_COMPATIBLE. This causes ellipses to grow in size60 // after a call to drawText when the painter is transformated.61 //62 // To work around this we register if a non identity transform is set in63 // QPainter::nativeXForm() and reduce the size by one if native xform has been used.64 //65 // Testcase for confirmation is checked in in:66 // //depot/manualtests/platformbugs/win32/ellipseafteradvgrmode.cpp67 //*/68 69 55 // QRgb has the same RGB format (0xaarrggbb) as OS/2 uses (ignoring the 70 56 // highest alpha byte) so we just mask alpha to get the valid OS/2 color. 71 57 #define COLOR_VALUE(c) ((flags & RGBColor) ? (c.rgb() & RGB_MASK) : c.pixel()) 72 58 73 //@@TODO (dmik): Innotek GCC 3.2.2 beta 4 CSD1 lacks this function in 74 // its version of the toolkit header. This should be fixed soon. 59 // Innotek GCC lacks some API functions in its version of OS/2 Toolkit headers 75 60 #if defined(Q_CC_GNU) && !defined(USE_OS2_TOOLKIT_HEADERS) 76 61 extern "C" LONG APIENTRY GpiQueryNearestPaletteIndex(HPAL hpal, ULONG color); … … 100 85 rc &= GpiSetAttrs( hps, PRIM_LINE, LBB_BACK_MIX_MODE, 0, (PBUNDLE) &lb ); 101 86 return rc; 102 }103 104 // helper function to select clip regions to the hps105 void qt_GpiSetClipRegion( HPS hps, HRGN hrgn, int devh, HRGN *hrgnOldRet )106 {107 if ( hrgn ) {108 // convert region y coordinates from Qt to GPI (see qregion_pm.cpp)109 if ( devh ) {110 POINTL ptl = { 0, devh };111 GpiOffsetRegion( hps, hrgn, &ptl );112 }113 }114 HRGN hrgnOld;115 GpiSetClipRegion( hps, hrgn, &hrgnOld );116 if ( hrgnOldRet )117 *hrgnOldRet = hrgnOld;118 else119 GpiDestroyRegion( hps, hrgnOld );120 87 } 121 88 … … 183 150 } 184 151 if ( bg_pixmap ) { 185 //@@TODO (dmik): don't realize why the windows code doesn't do it...186 152 // normalize pixmap offsets according to x and y 187 153 // to ensure that the offsets are always relative to … … 224 190 { 225 191 d = 0; 226 //@@TODO (dmik): later227 // hasUsedNativeXForm = FALSE;228 // usingNativeXForm = FALSE;229 192 flags = IsStartingUp; 230 193 pdev = 0; … … 240 203 wm_stack = 0; 241 204 hps = 0; 242 //@@TODO (dmik): remove?243 // hpen = 0;244 // hbrush = 0;245 // hfont = 0;246 205 holdpal = 0; 247 holdrgn = 0;206 holdrgn = HRGN_ERROR; 248 207 hbrushbm = 0; 249 208 pixmapBrush = nocolBrush = FALSE; … … 407 366 } 408 367 409 // @@TODO (dmik):possibly pixmapBrush is not needed, hbrushbm and368 /// @todo (dmik) possibly pixmapBrush is not needed, hbrushbm and 410 369 // CustomPattern can substitute it. 411 370 pixmapBrush = nocolBrush = FALSE; … … 521 480 hps = 0; 522 481 holdpal = 0; 523 holdrgn = 0;482 holdrgn = HRGN_ERROR; 524 483 devh = 0; 525 484 526 QRegion * pRepaintRgn = 0;485 QRegion *repaintRgn = 0; 527 486 528 487 if ( testf(ExtDev) ) { // external device … … 574 533 devh = wh; // for final y coord. flipping 575 534 if ( !w->isDesktop() ) 576 pRepaintRgn =// clip rgn passed from repaint()535 repaintRgn = // clip rgn passed from repaint() 577 536 (QRegion *) WinQueryWindowULong( w->winId(), QWL_QTCLIPRGN ); 578 537 if ( w->testWState(Qt::WState_InPaintEvent) ) { 579 538 hps = w->hps; // during paint event 580 539 } else { 581 if ( w->isDesktop() ) { 582 hps = WinGetScreenPS( HWND_DESKTOP ); 583 } else { 584 if ( unclipped || w->testWFlags( WPaintUnclipped ) ) { 585 hps = WinGetClipPS( w->winId(), 0, PSF_PARENTCLIP ); 586 } else { 587 hps = WinGetPS( w->winId() ); 588 } 589 } 540 hps = w->getTargetPS ( unclipped ? QWidget::Unclipped : 541 QWidget::ClipAll ); 590 542 w->hps = hps; 591 543 } … … 608 560 cpen.setColor( color1 ); 609 561 } 610 // @@TODO (dmik):later562 /// @todo (dmik) later 611 563 // } else if ( dt == QInternal::Printer ) { // device is a printer 612 564 // if ( pdev->handle() ) … … 634 586 cpen = QPen( copyFrom->foregroundColor() ); 635 587 bg_col = copyFrom->backgroundColor(); 636 pRepaintRgn =588 repaintRgn = 637 589 (QRegion *) WinQueryWindowULong( copyFrom->winId(), QWL_QTCLIPRGN ); 638 590 } … … 658 610 setBrushOrigin( 0, 0 ); 659 611 if ( hps ) { 660 HRGN hrgn = 0; 661 if ( pRepaintRgn ) { 662 // make a shallow copy (for the case if the QWL_QTCLIPRGN pointer 663 // will become invalid -- it should not ever happen though) 664 repaintRgn = *pRepaintRgn; 665 QRegion rgn = repaintRgn; 666 // clip region in OS/2 cannot be used for anything else, make a deep copy 667 rgn.detach(); 668 hrgn = rgn.handle(); 669 // prevent QRegion's destructor from destroying the region handle 670 // (qt_GpiSetClipRegion does the job) 671 rgn.data->rgn = 0; 612 holdrgn = GpiQueryClipRegion( hps ); 613 if ( repaintRgn ) { 614 // ensure that def_crgn is not null after assignment in any case 615 def_crgn = repaintRgn->isNull() ? QRegion( FALSE ) : *repaintRgn; 672 616 } 673 qt_GpiSetClipRegion( hps, hrgn, devh, &holdrgn ); 617 // clip region in GPI cannot be used for anything else, so detach it 618 def_crgn.detach(); 619 if ( holdrgn ) { 620 // intersect the original clip region and the region from repaint() 621 if ( def_crgn.isNull() ) 622 def_crgn = QRegion( 0, 0, ww, wh ); 623 GpiSetClipRegion( hps, 0, NULL ); // deselect holdrgn 624 HRGN hrgn = def_crgn.handle( devh ); 625 GpiCombineRegion( hps, hrgn, hrgn, holdrgn, CRGN_AND ); 626 } 627 cur_crgn = def_crgn; 628 if ( !cur_crgn.isNull() ) 629 GpiSetClipRegion( hps, cur_crgn.handle( devh ), NULL ); 674 630 } else { 675 631 holdrgn = HRGN_ERROR; … … 695 651 GpiSetPatternSet( hps, LCID_DEFAULT ); 696 652 GpiDeleteSetId( hps, LCID_QTPixmapBrush ); 697 } 698 //@@TODO (dmik): remove or set the LCID_DEFAULT font here? 699 // if ( hfont ) { 700 // SelectObject( hdc, stock_sysfont ); 701 // hfont = 0; 702 // } 703 if ( holdrgn != HRGN_ERROR ) 704 qt_GpiSetClipRegion( hps, holdrgn, 0, NULL ); 705 if ( holdpal ) 653 hbrushbm = 0; 654 } 655 if ( holdrgn != HRGN_ERROR ) { 656 GpiSetClipRegion( hps, holdrgn, NULL ); 657 holdrgn = HRGN_ERROR; 658 } 659 if ( holdpal ) { 706 660 GpiSelectPalette( hps, holdpal ); 661 holdpal = 0; 662 } 707 663 if ( !pdev ) 708 664 return FALSE; … … 719 675 } 720 676 677 if ( !def_crgn.isNull() ) 678 def_crgn = QRegion(); 679 cur_crgn = def_crgn; 680 721 681 if ( pfont ) { 722 682 delete pfont; … … 741 701 void QPainter::flush() 742 702 { 743 //@@TODO (dmik): need something here?744 // GdiFlush();745 703 } 746 704 … … 945 903 } 946 904 947 HRGN hrgn = 0; 948 QRegion rgn; 905 // the current clip region is stored in cur_crgn, so deselect the handle 906 // to let us operate on it. Note that the assignment op below will destroy 907 // the handle if it is no more referred, so there is no need to do it 908 // explicitly. 909 GpiSetClipRegion( hps, 0, NULL ); 949 910 950 911 if ( enable ) { 951 if ( ! repaintRgn.isNull() )952 rgn = crgn.intersect( repaintRgn );912 if ( !def_crgn.isNull() ) 913 cur_crgn = crgn.intersect( def_crgn ); 953 914 else 954 rgn =crgn;915 cur_crgn = crgn.isNull() ? QRegion( FALSE ) : crgn; 955 916 #ifndef QT_NO_PRINTER 956 // @@TODO (dmik):later917 /// @todo (dmik) later 957 918 // if ( pdev->devType() == QInternal::Printer ) { 958 919 // double xscale = ((float)pdev->metric( QPaintDeviceMetrics::PdmPhysicalDpiX )) / … … 971 932 #endif 972 933 } else { 973 if ( !repaintRgn.isNull() ) 974 rgn = repaintRgn; 975 } 976 977 if ( !rgn.isNull() ) { 978 // clip region in OS/2 cannot be used for anything else, make a deep copy 979 rgn.detach(); 980 hrgn = rgn.handle(); 981 // prevent QRegion's destructor from destroying the region handle 982 // (qt_GpiSetClipRegion does the job) 983 rgn.data->rgn = 0; 984 } 985 qt_GpiSetClipRegion( hps, hrgn, devh, NULL ); 934 cur_crgn = def_crgn; 935 } 936 937 // clip region in GPI cannot be used for anything else, so detach it 938 cur_crgn.detach(); 939 940 if ( !cur_crgn.isNull() ) 941 GpiSetClipRegion( hps, cur_crgn.handle( devh ), NULL ); 986 942 } 987 943 … … 1315 1271 qt_end_geom_line( hps, &gh ); 1316 1272 } 1317 //@@TODO (dmik): does OS/2 PM have the same bug?1318 // if ( (cpen.width() == 0) && (cpen.style() == SolidLine) )1319 // SetPixelV( hdc, x, y, COLOR_VALUE(cpen.color()) );1320 1273 } 1321 1274 … … 1824 1777 #endif // QT_NO_BEZIER 1825 1778 1826 //@@TODO (dmik): remove?1827 //extern uint qt_bitblt_foreground; // in qpaintdevice_pm.cpp1828 1829 1779 void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap, 1830 1780 int sx, int sy, int sw, int sh ) … … 1887 1837 1888 1838 if ( txop <= TxTranslate ) { // use optimized bitBlt 1889 //@@TODO (dmik): remove?1890 // if ( pixmap.depth() == 1 )1891 // qt_bitblt_foreground = COLOR_VALUE(cpen.color());1892 1839 bitBlt( pdev, x, y, &pixmap, sx, sy, sw, sh, (RasterOp)rop ); 1893 1840 return; … … 2004 1951 */ 2005 1952 QBitmap *mask = (QBitmap *)pixmap.mask(); 2006 //@@TODO (dmik): is OS/2 buggy too?2007 //#if 0 // Windows is too buggy, so we just use our own code (which is faster).2008 1953 if ( !testf(ExtDev) && txop <= TxTranslate && mask == 0 ) { 2009 1954 if ( txop == TxTranslate ) … … 2012 1957 return; 2013 1958 } 2014 //#endif2015 1959 if ( sw*sh < 8192 && sw*sh < 16*w*h ) { 2016 1960 int tw = sw, th = sh; … … 2032 1976 } 2033 1977 2034 //@@TODO (dmik): need this at all?2035 1978 #if 0 2036 1979 // … … 2157 2100 int ypos = y + si->y - ascent; 2158 2101 2159 //@@TODO (dmik): remove 2160 //#ifndef Q_OS_TEMP 2161 // if ( rop != CopyROP ) { 2162 // // Doesn't work for non-TrueType fonts, but we dealt with those 2163 // // with the bitmap above. 2164 // BeginPath(hdc); 2165 // } 2166 //#endif 2167 2168 //@@TODO (dmik): do we really need this? we already have painter->handle() 2102 /// @todo (dmik) do we really need this? we already have painter->handle() 2169 2103 // inside QFontEngine::draw(), and the font should have been selected into 2170 2104 // hps by updateFont() … … 2179 2113 2180 2114 fe->draw( this, xpos, ypos, engine, si, textFlags ); 2181 // @@TODO (dmik):need?2115 /// @todo (dmik) need? 2182 2116 // fe->hps = oldPs; 2183 2184 //@@TODO (dmik): remove2185 // if ( rop != CopyROP ) {2186 //#ifndef Q_OS_TEMP2187 // EndPath(hdc);2188 //#endif2189 // uint pix = COLOR_VALUE(cpen.data->color);2190 // HBRUSH tbrush = CreateSolidBrush( pix );2191 // SelectObject( hdc, tbrush );2192 //#ifndef Q_OS_TEMP2193 // FillPath(hdc);2194 //#endif2195 // SelectObject( hdc, hbrush );2196 // DeleteObject( tbrush );2197 // }2198 2117 } 2199 2118 } … … 2223 2142 y += si->y; 2224 2143 2225 // @@TODO (dmik):do we really need this? we already have painter->handle()2144 /// @todo (dmik) do we really need this? we already have painter->handle() 2226 2145 // inside QFontEngine::draw(), and the font should have been selected into 2227 2146 // hps by updateFont() … … 2231 2150 2232 2151 fe->draw( this, x, y, engine, si, textFlags ); 2233 // @@TODO (dmik):need?2152 /// @todo (dmik) need? 2234 2153 // fe->hps = oldPs; 2235 2154 }
Note:
See TracChangeset
for help on using the changeset viewer.