salgdi.cxx (5f27b83c) | salgdi.cxx (d8ed516e) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 12 unchanged lines hidden (view full) --- 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_vcl.hxx" 26 27#include <stdio.h> 28#include <string.h> | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 12 unchanged lines hidden (view full) --- 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_vcl.hxx" 26 27#include <stdio.h> 28#include <string.h> |
29 | |
30#include <rtl/strbuf.hxx> | 29#include <rtl/strbuf.hxx> |
31 | |
32#include <tools/svwin.h> 33#include <tools/debug.hxx> 34#include <tools/poly.hxx> | 30#include <tools/svwin.h> 31#include <tools/debug.hxx> 32#include <tools/poly.hxx> |
35 | |
36#include <basegfx/polygon/b2dpolygon.hxx> 37#include <basegfx/polygon/b2dpolygontools.hxx> | 33#include <basegfx/polygon/b2dpolygon.hxx> 34#include <basegfx/polygon/b2dpolygontools.hxx> |
38 | 35#include <basegfx/polygon/b2dpolypolygontools.hxx> |
39#include <win/wincomp.hxx> 40#include <win/saldata.hxx> 41#include <win/salgdi.h> 42#include <win/salframe.h> | 36#include <win/wincomp.hxx> 37#include <win/saldata.hxx> 38#include <win/salgdi.h> 39#include <win/salframe.h> |
40#include <basegfx/matrix/b2dhommatrixtools.hxx> |
|
43 44using namespace rtl; 45 46// ======================================================================= 47 48// comment out to prevent use of beziers on GDI functions 49#define USE_GDI_BEZIERS 50 --- 797 unchanged lines hidden (view full) --- 848 849 SelectClipRgn( getHDC(), 0 ); 850} 851 852// ----------------------------------------------------------------------- 853 854bool WinSalGraphics::setClipRegion( const Region& i_rClip ) 855{ | 41 42using namespace rtl; 43 44// ======================================================================= 45 46// comment out to prevent use of beziers on GDI functions 47#define USE_GDI_BEZIERS 48 --- 797 unchanged lines hidden (view full) --- 846 847 SelectClipRgn( getHDC(), 0 ); 848} 849 850// ----------------------------------------------------------------------- 851 852bool WinSalGraphics::setClipRegion( const Region& i_rClip ) 853{ |
856 if ( mhRegion ) 857 { 858 DeleteRegion( mhRegion ); 859 mhRegion = 0; 860 } 861 862 if( i_rClip.HasPolyPolygonOrB2DPolyPolygon() ) 863 { 864 const basegfx::B2DPolyPolygon aPolyPolygon( i_rClip.GetAsB2DPolyPolygon() ); | 854 if ( mhRegion ) 855 { 856 DeleteRegion( mhRegion ); 857 mhRegion = 0; 858 } 859 860 bool bUsePolygon(i_rClip.HasPolyPolygonOrB2DPolyPolygon()); 861 static bool bTryToAvoidPolygon(true); 862 863 // #122149# try to avoid usage of PolyPolygon ClipRegions when PolyPolygon is no curve 864 // and only contains horizontal/vertical edges. In that case, use the fallback 865 // in GetRegionRectangles which will use Region::GetAsRegionBand() which will do 866 // the correct polygon-to-RegionBand transformation. 867 // Background is that when using the same Rectangle as rectangle or as Polygon 868 // clip region will lead to different results; the polygon-based one will be 869 // one pixel less to the right and down (see GDI docu for CreatePolygonRgn). This 870 // again is because of the polygon-nature and it's classic handling when filling. 871 // This also means that all cases which use a 'true' polygon-based incarnation of 872 // a Region should know what they do - it may lead to repaint errors. 873 if(bUsePolygon && bTryToAvoidPolygon) 874 { 875 const basegfx::B2DPolyPolygon aPolyPolygon( i_rClip.GetAsB2DPolyPolygon() ); 876 877 if(!aPolyPolygon.areControlPointsUsed()) 878 { 879 if(basegfx::tools::containsOnlyHorizontalAndVerticalEdges(aPolyPolygon)) 880 { 881 bUsePolygon = false; 882 } 883 } 884 } 885 886 if(bUsePolygon) 887 { 888 // #122149# check the comment above to know that this may lead to potentioal repaint 889 // problems. It may be solved (if needed) by scaling the polygon by one in X 890 // and Y. Currently the workaround to only use it if really unavoidable will 891 // solve most cases. When someone is really using polygon-based Regions he 892 // should know what he is doing. 893 // Added code to do that scaling to check if it works, testing it. 894 const basegfx::B2DPolyPolygon aPolyPolygon( i_rClip.GetAsB2DPolyPolygon() ); |
865 const sal_uInt32 nCount(aPolyPolygon.count()); 866 867 if( nCount ) 868 { 869 std::vector< POINT > aPolyPoints; 870 aPolyPoints.reserve( 1024 ); 871 std::vector< INT > aPolyCounts( nCount, 0 ); | 895 const sal_uInt32 nCount(aPolyPolygon.count()); 896 897 if( nCount ) 898 { 899 std::vector< POINT > aPolyPoints; 900 aPolyPoints.reserve( 1024 ); 901 std::vector< INT > aPolyCounts( nCount, 0 ); |
872 | 902 basegfx::B2DHomMatrix aExpand; 903 static bool bExpandByOneInXandY(true); 904 905 if(bExpandByOneInXandY) 906 { 907 const basegfx::B2DRange aRangeS(aPolyPolygon.getB2DRange()); 908 const basegfx::B2DRange aRangeT(aRangeS.getMinimum(), aRangeS.getMaximum() + basegfx::B2DTuple(1.0, 1.0)); 909 aExpand = basegfx::B2DHomMatrix(basegfx::tools::createSourceRangeTargetRangeTransform(aRangeS, aRangeT)); 910 } 911 |
873 for(sal_uInt32 a(0); a < nCount; a++) 874 { | 912 for(sal_uInt32 a(0); a < nCount; a++) 913 { |
875 basegfx::B2DPolygon aPoly(aPolyPolygon.getB2DPolygon(a)); 876 877 aPoly = basegfx::tools::adaptiveSubdivideByDistance( aPoly, 1 ); 878 const sal_uInt32 nPoints = aPoly.count(); | 914 const basegfx::B2DPolygon aPoly( 915 basegfx::tools::adaptiveSubdivideByDistance( 916 aPolyPolygon.getB2DPolygon(a), 917 1)); 918 const sal_uInt32 nPoints(aPoly.count()); |
879 aPolyCounts[a] = nPoints; | 919 aPolyCounts[a] = nPoints; |
880 | 920 |
881 for( sal_uInt32 b = 0; b < nPoints; b++ ) 882 { | 921 for( sal_uInt32 b = 0; b < nPoints; b++ ) 922 { |
883 basegfx::B2DPoint aPt( aPoly.getB2DPoint( b ) ); | 923 basegfx::B2DPoint aPt(aPoly.getB2DPoint(b)); 924 925 if(bExpandByOneInXandY) 926 { 927 aPt = aExpand * aPt; 928 } 929 |
884 POINT aPOINT; | 930 POINT aPOINT; |
885 aPOINT.x = (LONG)aPt.getX(); 886 aPOINT.y = (LONG)aPt.getY(); | 931 // #122149# do correct rounding 932 aPOINT.x = basegfx::fround(aPt.getX()); 933 aPOINT.y = basegfx::fround(aPt.getY()); |
887 aPolyPoints.push_back( aPOINT ); 888 } 889 } 890 891 mhRegion = CreatePolyPolygonRgn( &aPolyPoints[0], &aPolyCounts[0], nCount, ALTERNATE ); 892 } 893 } 894 else --- 69 unchanged lines hidden (view full) --- 964 } 965 else 966 { 967 mpClipRgnData->rdh.nCount--; 968 mpClipRgnData->rdh.nRgnSize -= sizeof( RECT ); 969 } 970 } 971 | 934 aPolyPoints.push_back( aPOINT ); 935 } 936 } 937 938 mhRegion = CreatePolyPolygonRgn( &aPolyPoints[0], &aPolyCounts[0], nCount, ALTERNATE ); 939 } 940 } 941 else --- 69 unchanged lines hidden (view full) --- 1011 } 1012 else 1013 { 1014 mpClipRgnData->rdh.nCount--; 1015 mpClipRgnData->rdh.nRgnSize -= sizeof( RECT ); 1016 } 1017 } 1018 |
972 //ImplRegionInfo aInfo; 973 //long nX, nY, nW, nH; 974 //bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH ); 975 //while( bRegionRect ) 976 //{ 977 // if ( nW && nH ) 978 // { 979 // long nRight = nX + nW; 980 // long nBottom = nY + nH; 981 // 982 // if ( bFirstClipRect ) 983 // { 984 // pBoundRect->left = nX; 985 // pBoundRect->top = nY; 986 // pBoundRect->right = nRight; 987 // pBoundRect->bottom = nBottom; 988 // bFirstClipRect = false; 989 // } 990 // else 991 // { 992 // if ( nX < pBoundRect->left ) 993 // pBoundRect->left = (int)nX; 994 // 995 // if ( nY < pBoundRect->top ) 996 // pBoundRect->top = (int)nY; 997 // 998 // if ( nRight > pBoundRect->right ) 999 // pBoundRect->right = (int)nRight; 1000 // 1001 // if ( nBottom > pBoundRect->bottom ) 1002 // pBoundRect->bottom = (int)nBottom; 1003 // } 1004 // 1005 // pNextClipRect->left = (int)nX; 1006 // pNextClipRect->top = (int)nY; 1007 // pNextClipRect->right = (int)nRight; 1008 // pNextClipRect->bottom = (int)nBottom; 1009 // pNextClipRect++; 1010 // } 1011 // else 1012 // { 1013 // mpClipRgnData->rdh.nCount--; 1014 // mpClipRgnData->rdh.nRgnSize -= sizeof( RECT ); 1015 // } 1016 // bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH ); 1017 //} 1018 | |
1019 // create clip region from ClipRgnData 1020 if ( mpClipRgnData->rdh.nCount == 1 ) 1021 { 1022 RECT* pRect = &(mpClipRgnData->rdh.rcBound); 1023 mhRegion = CreateRectRgn( pRect->left, pRect->top, 1024 pRect->right, pRect->bottom ); 1025 } 1026 else if( mpClipRgnData->rdh.nCount > 1 ) --- 22 unchanged lines hidden (view full) --- 1049 } 1050 1051 if ( mpClipRgnData != mpStdClipRgnData ) 1052 delete [] mpClipRgnData; 1053 } 1054 } 1055 1056 if( mhRegion ) | 1019 // create clip region from ClipRgnData 1020 if ( mpClipRgnData->rdh.nCount == 1 ) 1021 { 1022 RECT* pRect = &(mpClipRgnData->rdh.rcBound); 1023 mhRegion = CreateRectRgn( pRect->left, pRect->top, 1024 pRect->right, pRect->bottom ); 1025 } 1026 else if( mpClipRgnData->rdh.nCount > 1 ) --- 22 unchanged lines hidden (view full) --- 1049 } 1050 1051 if ( mpClipRgnData != mpStdClipRgnData ) 1052 delete [] mpClipRgnData; 1053 } 1054 } 1055 1056 if( mhRegion ) |
1057 SelectClipRgn( getHDC(), mhRegion ); | 1057 { 1058 SelectClipRgn( getHDC(), mhRegion ); 1059 1060 // debug code if you weant to check range of the newly applied ClipRegion 1061 //RECT aBound; 1062 //const int aRegionType = GetRgnBox(mhRegion, &aBound); 1063 // 1064 //bool bBla = true; 1065 } 1066 |
1058 return mhRegion != 0; 1059} 1060 1061// ----------------------------------------------------------------------- 1062 1063void WinSalGraphics::SetLineColor() 1064{ 1065 // create and select new pen --- 815 unchanged lines hidden --- | 1067 return mhRegion != 0; 1068} 1069 1070// ----------------------------------------------------------------------- 1071 1072void WinSalGraphics::SetLineColor() 1073{ 1074 // create and select new pen --- 815 unchanged lines hidden --- |