# HG changeset patch # User Viktor Demidov # Date 1575824826 -7200 # Sun Dec 08 19:07:06 2019 +0200 # Node ID f323278af2ff28139822bf06fb055536e841bfe0 # Parent bf461203504ca14bc417397a75f5c7cfed6419d8 Graphics32 upgrade diff -r bf461203504c -r f323278af2ff Src/Bitmap32/u_Bitmap32ByStaticBitmap.pas --- a/Src/Bitmap32/u_Bitmap32ByStaticBitmap.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Bitmap32/u_Bitmap32ByStaticBitmap.pas Sun Dec 08 19:07:06 2019 +0200 @@ -30,7 +30,6 @@ type TStaticBitmapBackend = class(TCustomBackend) private - FBufferFactory: IBitmap32BufferFactory; FBitmapStatic: IBitmap32Buffer; protected procedure InitializeSurface( @@ -40,9 +39,8 @@ procedure FinalizeSurface; override; public constructor Create( - Owner: TCustomBitmap32; - const ABufferFactory: IBitmap32BufferFactory - ); + Owner: TCustomBitmap32 + ); override; end; TBitmap32ByStaticBitmap = class(TCustomBitmap32) @@ -50,7 +48,6 @@ FBitmap32StaticFactory: IBitmap32StaticFactory; FBackEndByStatic: TStaticBitmapBackend; protected - procedure InitializeBackend; override; procedure SetBackend(const Backend: TCustomBackend); override; public function MakeAndClear: IBitmap32Static; @@ -68,13 +65,11 @@ { TStaticBitmapBackend } constructor TStaticBitmapBackend.Create( - Owner: TCustomBitmap32; - const ABufferFactory: IBitmap32BufferFactory + Owner: TCustomBitmap32 ); begin - Assert(ABufferFactory <> nil); + Assert(Owner is TBitmap32ByStaticBitmap); inherited Create(Owner); - FBufferFactory := ABufferFactory; end; procedure TStaticBitmapBackend.FinalizeSurface; @@ -88,11 +83,14 @@ NewWidth, NewHeight: Integer; ClearBuffer: Boolean ); +var + VBufferFactory: IBitmap32BufferFactory; begin + VBufferFactory := TBitmap32ByStaticBitmap(FOwner).FBitmap32StaticFactory.BufferFactory; if ClearBuffer then begin - FBitmapStatic := FBufferFactory.BuildEmptyClear(Types.Point(NewWidth, NewHeight), 0); + FBitmapStatic := VBufferFactory.BuildEmptyClear(Types.Point(NewWidth, NewHeight), 0); end else begin - FBitmapStatic := FBufferFactory.BuildEmpty(Types.Point(NewWidth, NewHeight)); + FBitmapStatic := VBufferFactory.BuildEmpty(Types.Point(NewWidth, NewHeight)); end; if FBitmapStatic <> nil then begin FBits := FBitmapStatic.Data; @@ -109,12 +107,7 @@ begin Assert(Assigned(ABitmap32StaticFactory)); FBitmap32StaticFactory := ABitmap32StaticFactory; - inherited Create; -end; - -procedure TBitmap32ByStaticBitmap.InitializeBackend; -begin - TStaticBitmapBackend.Create(Self, FBitmap32StaticFactory.BufferFactory); + inherited Create(TStaticBitmapBackend); end; function TBitmap32ByStaticBitmap.MakeAndClear: IBitmap32Static; @@ -129,6 +122,8 @@ if Backend is TStaticBitmapBackend then begin FBackEndByStatic := TStaticBitmapBackend(Backend); inherited; + end else begin + Assert(False, 'Bad backend for this bitmap class'); end; end; diff -r bf461203504c -r f323278af2ff Src/Bitmap32/u_Bitmap32StaticBuilderByGR32.pas --- a/Src/Bitmap32/u_Bitmap32StaticBuilderByGR32.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Bitmap32/u_Bitmap32StaticBuilderByGR32.pas Sun Dec 08 19:07:06 2019 +0200 @@ -104,16 +104,14 @@ procedure FinalizeSurface; override; public constructor Create( - Owner: TCustomBitmap32; - const ABitmapBuffer: IBitmap32Buffer - ); + Owner: TCustomBitmap32 + ); override; end; TBitmap32FixedBitmapBuffer = class(TCustomBitmap32) private FBitmapBuffer: IBitmap32Buffer; protected - procedure InitializeBackend; override; procedure SetBackend(const Backend: TCustomBackend); override; public constructor Create(const ABitmapBuffer: IBitmap32Buffer); reintroduce; @@ -122,13 +120,12 @@ { TFixedBufferBitmapBackend } constructor TFixedBufferBitmapBackend.Create( - Owner: TCustomBitmap32; - const ABitmapBuffer: IBitmap32Buffer + Owner: TCustomBitmap32 ); begin - Assert(Assigned(ABitmapBuffer)); + Assert(Owner is TBitmap32FixedBitmapBuffer); inherited Create(Owner); - FBitmapBuffer := ABitmapBuffer; + FBitmapBuffer := TBitmap32FixedBitmapBuffer(FOwner).FBitmapBuffer; end; procedure TFixedBufferBitmapBackend.FinalizeSurface; @@ -159,16 +156,10 @@ ); begin Assert(Assigned(ABitmapBuffer)); - inherited Create; + inherited Create(TFixedBufferBitmapBackend); FBitmapBuffer := ABitmapBuffer; end; -procedure TBitmap32FixedBitmapBuffer.InitializeBackend; -begin - inherited; - TFixedBufferBitmapBackend.Create(Self, FBitmapBuffer); -end; - procedure TBitmap32FixedBitmapBuffer.SetBackend(const Backend: TCustomBackend); begin Assert(Backend is TFixedBufferBitmapBackend); diff -r bf461203504c -r f323278af2ff Src/BitmapLayerProvider/u_BitmapLayerProviderByTrackPath.pas --- a/Src/BitmapLayerProvider/u_BitmapLayerProviderByTrackPath.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/BitmapLayerProvider/u_BitmapLayerProviderByTrackPath.pas Sun Dec 08 19:07:06 2019 +0200 @@ -103,6 +103,7 @@ Types, Math, GR32_Polygons, + GR32_VectorUtils, i_ProjectionType, u_Bitmap32ByStaticBitmap, u_GeometryFunc, @@ -233,19 +234,19 @@ ); var VSegmentColor: TColor32; - VLine: TArrayOfFixedPoint; - VLines: TArrayOfArrayOfFixedPoint; + VLine: TArrayOfFloatPoint; + VLines: TArrayOfArrayOfFloatPoint; begin if (APointPrev.x < 32767) and (APointPrev.x > -32767) and (APointPrev.y < 32767) and (APointPrev.y > -32767) then begin VSegmentColor := ATrackColorer.GetColorForSpeed(ASpeed); SetLength(VLine, 2); - VLine[0] := FixedPoint(APointPrev.X, APointPrev.Y); - VLine[1] := FixedPoint(APointCurr.X, APointCurr.Y); + VLine[0] := FloatPoint(APointPrev.X, APointPrev.Y); + VLine[1] := FloatPoint(APointCurr.X, APointCurr.Y); SetLength(VLines, 1); VLines[0] := VLine; VLines := BuildPolyPolyLine(VLines, False, ALineWidth); - PolyPolygonXS( + PolyPolygonFS( ATargetBmp, VLines, VSegmentColor diff -r bf461203504c -r f323278af2ff Src/Geometry/u_GeometryFunc.pas --- a/Src/Geometry/u_GeometryFunc.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Geometry/u_GeometryFunc.pas Sun Dec 08 19:07:06 2019 +0200 @@ -25,65 +25,27 @@ const AGeometry: IGeometryProjectedPolygon ): IGeometryProjectedSinglePolygon; -function BuildPolyPolyLine( - const APoints: TArrayOfArrayOfFixedPoint; - AClosed: Boolean; - AStrokeWidth: double -): TArrayOfArrayOfFixedPoint; - -procedure AppendArrayOfArrayOfFixedPoint( - var APoints1: TArrayOfArrayOfFixedPoint; - const APoints2: TArrayOfArrayOfFixedPoint +procedure AppendArrayOfArrayOfFloatPoint( + var APoints1: TArrayOfArrayOfFloatPoint; + const APoints2: TArrayOfArrayOfFloatPoint ); overload; -procedure AppendArrayOfArrayOfFixedPoint( - var APoints1: TArrayOfArrayOfFixedPoint; - const APoints2: TArrayOfFixedPoint +procedure AppendArrayOfArrayOfFloatPoint( + var APoints1: TArrayOfArrayOfFloatPoint; + const APoints2: TArrayOfFloatPoint ); overload; function ProjectedLine2ArrayOfArray( const ALine: IGeometryProjectedLine; const AMapRect: TRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; - -procedure ProjectedLine2GR32Polygon( - const ALine: IGeometryProjectedLine; - const ALocalConverter: ILocalCoordConverter; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; - -procedure ProjectedLine2GR32Polygon( - const ALine: IGeometryProjectedLine; - const AMapRect: TRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; function ProjectedPolygon2ArrayOfArray( const ALine: IGeometryProjectedSinglePolygon; const AMapRect: TRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; - -procedure ProjectedPolygon2GR32Polygon( - const ALine: IGeometryProjectedSinglePolygon; - const ALocalConverter: ILocalCoordConverter; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; - -procedure ProjectedPolygon2GR32Polygon( - const ALine: IGeometryProjectedSinglePolygon; - const AMapRect: TRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; function IsValidLonLatLine( const AGeometry: IGeometryLonLatLine @@ -463,51 +425,21 @@ end; end; -function BuildPolyPolyLine( - const APoints: TArrayOfArrayOfFixedPoint; - AClosed: Boolean; - AStrokeWidth: double -): TArrayOfArrayOfFixedPoint; -var - VPolygon: TPolygon32; -begin - VPolygon := TPolygon32.Create; - try - VPolygon.Closed := AClosed; - VPolygon.Points := APoints; - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(AStrokeWidth / 2), 0.5) do begin - try - Result := Points; - finally - Free; - end; - end; - finally - Free; - end; - end; - finally - VPolygon.Free; - end; -end; - -procedure AppendArrayOfArrayOfFixedPoint( - var APoints1: TArrayOfArrayOfFixedPoint; - const APoints2: TArrayOfArrayOfFixedPoint +procedure AppendArrayOfArrayOfFloatPoint( + var APoints1: TArrayOfArrayOfFloatPoint; + const APoints2: TArrayOfArrayOfFloatPoint ); overload; var i: Integer; begin for i := 0 to Length(APoints2) - 1 do begin - AppendArrayOfArrayOfFixedPoint(APoints1, APoints2[i]); + AppendArrayOfArrayOfFloatPoint(APoints1, APoints2[i]); end; end; -procedure AppendArrayOfArrayOfFixedPoint( - var APoints1: TArrayOfArrayOfFixedPoint; - const APoints2: TArrayOfFixedPoint +procedure AppendArrayOfArrayOfFloatPoint( + var APoints1: TArrayOfArrayOfFloatPoint; + const APoints2: TArrayOfFloatPoint ); overload; var VLen: Integer; @@ -521,8 +453,8 @@ const ALine: IGeometryProjectedSingleLine; const ARectWithDelta: TDoubleRect; const AMapRect: TDoubleRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; var VEnum: IEnumLocalPoint; VPoint: TDoublePoint; @@ -556,7 +488,7 @@ if VPointsProcessedCount + 1 >= Length(APointArray) then begin SetLength(APointArray, (VPointsProcessedCount + 1) * 2); end; - APointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); + APointArray[VPointsProcessedCount] := FloatPoint(VPoint.X, VPoint.Y); Inc(VPointsProcessedCount); end; end; @@ -569,134 +501,11 @@ end; end; -procedure SingleLine2GR32Polygon( - const ALine: IGeometryProjectedSingleLine; - const ALocalConverter: ILocalCoordConverter; - const ARectWithDelta: TDoubleRect; - const AMapRect: TDoubleRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VEnum: IEnumLocalPoint; - VPoint: TDoublePoint; - VPointsProcessedCount: Integer; -begin - if IsIntersecProjectedRect(AMapRect, ALine.Bounds) then begin - VEnum := - TEnumDoublePointMapPixelToLocalPixel.Create( - ALocalConverter, - ALine.GetEnum - ); - VEnum := - TEnumLocalPointClipByRect.Create( - False, - ARectWithDelta, - VEnum - ); - VEnum := TEnumLocalPointFilterEqual.Create(VEnum); - VPointsProcessedCount := 0; - while VEnum.Next(VPoint) do begin - if PointIsEmpty(VPoint) then begin - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := False; - end else begin - APolygon.NewLine; - end; - end; - end else begin - if VPointsProcessedCount + 1 >= Length(AFixedPointArray) then begin - SetLength(AFixedPointArray, (VPointsProcessedCount + 1) * 2); - end; - AFixedPointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); - Inc(VPointsProcessedCount); - end; - end; - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := False; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end; -end; - -procedure SingleLine2GR32Polygon( - const ALine: IGeometryProjectedSingleLine; - const ARectWithDelta: TDoubleRect; - const AMapRect: TDoubleRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VEnum: IEnumLocalPoint; - VPoint: TDoublePoint; - VPointsProcessedCount: Integer; -begin - if IsIntersecProjectedRect(AMapRect, ALine.Bounds) then begin - VEnum := - TEnumDoublePointMapPixelToLocalPixelSimple.Create( - AMapRect.TopLeft, - ALine.GetEnum - ); - VEnum := - TEnumLocalPointClipByRect.Create( - False, - ARectWithDelta, - VEnum - ); - VEnum := TEnumLocalPointFilterEqual.Create(VEnum); - VPointsProcessedCount := 0; - while VEnum.Next(VPoint) do begin - if PointIsEmpty(VPoint) then begin - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := False; - end else begin - APolygon.NewLine; - end; - end; - end else begin - if VPointsProcessedCount + 1 >= Length(AFixedPointArray) then begin - SetLength(AFixedPointArray, (VPointsProcessedCount + 1) * 2); - end; - AFixedPointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); - Inc(VPointsProcessedCount); - end; - end; - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := False; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end; -end; - function ProjectedLine2ArrayOfArray( const ALine: IGeometryProjectedLine; const AMapRect: TRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; var VMapRect: TDoubleRect; VLocalRect: TDoubleRect; @@ -704,7 +513,7 @@ VLineIndex: Integer; VSingleLine: IGeometryProjectedSingleLine; VMultiLine: IGeometryProjectedMultiLine; - VLines: TArrayOfArrayOfFixedPoint; + VLines: TArrayOfArrayOfFloatPoint; begin if Assigned(ALine) then begin VMapRect := DoubleRect(AMapRect); @@ -732,115 +541,7 @@ VMapRect, APointArray ); - AppendArrayOfArrayOfFixedPoint(Result, VLines); - end; - end; - end; - end; -end; - -procedure ProjectedLine2GR32Polygon( - const ALine: IGeometryProjectedLine; - const ALocalConverter: ILocalCoordConverter; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); -var - VMapRect: TDoubleRect; - VLocalRect: TDoubleRect; - VRectWithDelta: TDoubleRect; - VLineIndex: Integer; - VSingleLine: IGeometryProjectedSingleLine; - VMultiLine: IGeometryProjectedMultiLine; -begin - if Assigned(APolygon) then begin - APolygon.Clear; - end; - - if Assigned(ALine) then begin - VMapRect := ALocalConverter.GetRectInMapPixelFloat; - if IsIntersecProjectedRect(VMapRect, ALine.Bounds) then begin - VLocalRect := DoubleRect(ALocalConverter.GetLocalRect); - VRectWithDelta.Left := VLocalRect.Left - 10; - VRectWithDelta.Top := VLocalRect.Top - 10; - VRectWithDelta.Right := VLocalRect.Right + 10; - VRectWithDelta.Bottom := VLocalRect.Bottom + 10; - if Supports(ALine, IGeometryProjectedSingleLine, VSingleLine) then begin - SingleLine2GR32Polygon( - VSingleLine, - ALocalConverter, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - end else if Supports(ALine, IGeometryProjectedMultiLine, VMultiLine) then begin - for VLineIndex := 0 to VMultiLine.Count - 1 do begin - VSingleLine := VMultiLine.Item[VLineIndex]; - SingleLine2GR32Polygon( - VSingleLine, - ALocalConverter, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - end; - end; - end; - end; -end; - -procedure ProjectedLine2GR32Polygon( - const ALine: IGeometryProjectedLine; - const AMapRect: TRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VMapRect: TDoubleRect; - VLocalRect: TDoubleRect; - VRectWithDelta: TDoubleRect; - VLineIndex: Integer; - VSingleLine: IGeometryProjectedSingleLine; - VMultiLine: IGeometryProjectedMultiLine; -begin - if Assigned(APolygon) then begin - APolygon.Clear; - end; - - if Assigned(ALine) then begin - VMapRect := DoubleRect(AMapRect); - if IsIntersecProjectedRect(VMapRect, ALine.Bounds) then begin - VLocalRect := DoubleRect(0, 0, VMapRect.Right - VMapRect.Left, VMapRect.Bottom - VMapRect.Top); - VRectWithDelta.Left := VLocalRect.Left - 10; - VRectWithDelta.Top := VLocalRect.Top - 10; - VRectWithDelta.Right := VLocalRect.Right + 10; - VRectWithDelta.Bottom := VLocalRect.Bottom + 10; - if Supports(ALine, IGeometryProjectedSingleLine, VSingleLine) then begin - SingleLine2GR32Polygon( - VSingleLine, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - end else if Supports(ALine, IGeometryProjectedMultiLine, VMultiLine) then begin - for VLineIndex := 0 to VMultiLine.Count - 1 do begin - VSingleLine := VMultiLine.Item[VLineIndex]; - SingleLine2GR32Polygon( - VSingleLine, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); + AppendArrayOfArrayOfFloatPoint(Result, VLines); end; end; end; @@ -851,8 +552,8 @@ const ALine: IGeometryProjectedContour; const ARectWithDelta: TDoubleRect; const AMapRect: TDoubleRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; overload; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; overload; var VEnum: IEnumLocalPoint; VPoint: TDoublePoint; @@ -887,7 +588,7 @@ if VPointsProcessedCount + 1 >= Length(APointArray) then begin SetLength(APointArray, (VPointsProcessedCount + 1) * 2); end; - APointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); + APointArray[VPointsProcessedCount] := FloatPoint(VPoint.X, VPoint.Y); Inc(VPointsProcessedCount); end; end; @@ -901,146 +602,17 @@ end; end; -procedure SingleContour2GR32Polygon( - const ALine: IGeometryProjectedContour; - const ALocalConverter: ILocalCoordConverter; - const ARectWithDelta: TDoubleRect; - const AMapRect: TDoubleRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VEnum: IEnumLocalPoint; - VPoint: TDoublePoint; - VPointsProcessedCount: Integer; -begin - if IsIntersecProjectedRect(AMapRect, ALine.Bounds) then begin - VEnum := - TEnumDoublePointMapPixelToLocalPixel.Create( - ALocalConverter, - ALine.GetEnum - ); - VEnum := - TEnumLocalPointClipByRect.Create( - True, - ARectWithDelta, - VEnum - ); - VEnum := TEnumLocalPointFilterEqual.Create(VEnum); - VEnum := TEnumLocalPointClosePoly.Create(VEnum); - VPointsProcessedCount := 0; - while VEnum.Next(VPoint) do begin - if PointIsEmpty(VPoint) then begin - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := True; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end else begin - if VPointsProcessedCount + 1 >= Length(AFixedPointArray) then begin - SetLength(AFixedPointArray, (VPointsProcessedCount + 1) * 2); - end; - AFixedPointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); - Inc(VPointsProcessedCount); - end; - end; - - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := True; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end; -end; - -procedure SingleContour2GR32Polygon( - const ALine: IGeometryProjectedContour; - const ARectWithDelta: TDoubleRect; - const AMapRect: TDoubleRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VEnum: IEnumLocalPoint; - VPoint: TDoublePoint; - VPointsProcessedCount: Integer; -begin - if IsIntersecProjectedRect(AMapRect, ALine.Bounds) then begin - VEnum := - TEnumDoublePointMapPixelToLocalPixelSimple.Create( - AMapRect.TopLeft, - ALine.GetEnum - ); - VEnum := - TEnumLocalPointClipByRect.Create( - True, - ARectWithDelta, - VEnum - ); - VEnum := TEnumLocalPointFilterEqual.Create(VEnum); - VEnum := TEnumLocalPointClosePoly.Create(VEnum); - VPointsProcessedCount := 0; - while VEnum.Next(VPoint) do begin - if PointIsEmpty(VPoint) then begin - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := True; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end else begin - if VPointsProcessedCount + 1 >= Length(AFixedPointArray) then begin - SetLength(AFixedPointArray, (VPointsProcessedCount + 1) * 2); - end; - AFixedPointArray[VPointsProcessedCount] := FixedPoint(VPoint.X, VPoint.Y); - Inc(VPointsProcessedCount); - end; - end; - - if VPointsProcessedCount > 0 then begin - if APolygon = nil then begin - APolygon := TPolygon32.Create; - APolygon.Antialiased := AAntialiasMode <> amNone; - APolygon.AntialiasMode := AAntialiasMode; - APolygon.Closed := True; - end else begin - APolygon.NewLine; - end; - APolygon.AddPoints(AFixedPointArray[0], VPointsProcessedCount); - end; - end; -end; - function ProjectedPolygon2ArrayOfArray( const ALine: IGeometryProjectedSinglePolygon; const AMapRect: TRect; - var APointArray: TArrayOfFixedPoint -): TArrayOfArrayOfFixedPoint; + var APointArray: TArrayOfFloatPoint +): TArrayOfArrayOfFloatPoint; var VMapRect: TDoubleRect; VLocalRect: TDoubleRect; VRectWithDelta: TDoubleRect; VLineIndex: Integer; - VLines: TArrayOfArrayOfFixedPoint; + VLines: TArrayOfArrayOfFloatPoint; begin if Assigned(ALine) then begin VMapRect := DoubleRect(AMapRect); @@ -1065,103 +637,7 @@ VMapRect, APointArray ); - AppendArrayOfArrayOfFixedPoint(Result, VLines); - end; - end; - end; -end; - -procedure ProjectedPolygon2GR32Polygon( - const ALine: IGeometryProjectedSinglePolygon; - const ALocalConverter: ILocalCoordConverter; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); -var - VMapRect: TDoubleRect; - VLocalRect: TDoubleRect; - VRectWithDelta: TDoubleRect; - VLineIndex: Integer; -begin - if Assigned(APolygon) then begin - APolygon.Clear; - end; - - if Assigned(ALine) then begin - VMapRect := ALocalConverter.GetRectInMapPixelFloat; - if IsIntersecProjectedRect(VMapRect, ALine.Bounds) then begin - VLocalRect := DoubleRect(ALocalConverter.GetLocalRect); - VRectWithDelta.Left := VLocalRect.Left - 10; - VRectWithDelta.Top := VLocalRect.Top - 10; - VRectWithDelta.Right := VLocalRect.Right + 10; - VRectWithDelta.Bottom := VLocalRect.Bottom + 10; - SingleContour2GR32Polygon( - ALine.OuterBorder, - ALocalConverter, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - for VLineIndex := 0 to ALine.HoleCount - 1 do begin - SingleContour2GR32Polygon( - ALine.HoleBorder[VLineIndex], - ALocalConverter, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - end; - end; - end; -end; - -procedure ProjectedPolygon2GR32Polygon( - const ALine: IGeometryProjectedSinglePolygon; - const AMapRect: TRect; - const AAntialiasMode: TAntialiasMode; - var AFixedPointArray: TArrayOfFixedPoint; - var APolygon: TPolygon32 -); overload; -var - VMapRect: TDoubleRect; - VLocalRect: TDoubleRect; - VRectWithDelta: TDoubleRect; - VLineIndex: Integer; -begin - if Assigned(APolygon) then begin - APolygon.Clear; - end; - - if Assigned(ALine) then begin - VMapRect := DoubleRect(AMapRect); - if IsIntersecProjectedRect(VMapRect, ALine.Bounds) then begin - VLocalRect := DoubleRect(0, 0, VMapRect.Right - VMapRect.Left, VMapRect.Bottom - VMapRect.Top); - VRectWithDelta.Left := VLocalRect.Left - 10; - VRectWithDelta.Top := VLocalRect.Top - 10; - VRectWithDelta.Right := VLocalRect.Right + 10; - VRectWithDelta.Bottom := VLocalRect.Bottom + 10; - SingleContour2GR32Polygon( - ALine.OuterBorder, - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); - for VLineIndex := 0 to ALine.HoleCount - 1 do begin - SingleContour2GR32Polygon( - ALine.HoleBorder[VLineIndex], - VRectWithDelta, - VMapRect, - AAntialiasMode, - AFixedPointArray, - APolygon - ); + AppendArrayOfArrayOfFloatPoint(Result, VLines); end; end; end; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/GPSMarker/u_MapLayerGPSMarkerRings.pas --- a/Src/MapLayers/WindowLayers/GPSMarker/u_MapLayerGPSMarkerRings.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/GPSMarker/u_MapLayerGPSMarkerRings.pas Sun Dec 08 19:07:06 2019 +0200 @@ -289,7 +289,6 @@ TProjectedDrawableElementByPolygonSimpleEdge.Create( ALocalConverter.Projection, VCirclesProjected, - amNone, clRed32 ); end; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/GPSMarker/u_ProjectedDrawableElementByPolygon.pas --- a/Src/MapLayers/WindowLayers/GPSMarker/u_ProjectedDrawableElementByPolygon.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/GPSMarker/u_ProjectedDrawableElementByPolygon.pas Sun Dec 08 19:07:06 2019 +0200 @@ -39,7 +39,6 @@ FProjection: IProjection; FSource: IGeometryProjectedPolygon; FColor: TColor32; - FAntialiasMode: TAntialiasMode; private function GetProjection: IProjection; procedure Draw( @@ -50,27 +49,26 @@ constructor Create( const AProjection: IProjection; const ASource: IGeometryProjectedPolygon; - const AAntialiasMode: TAntialiasMode; const AColor: TColor32 ); end; TDrawableBaseByPoints = class(TBaseInterfacedObject) private - FPoints: TArrayOfArrayOfFixedPoint; + FPoints: TArrayOfArrayOfFloatPoint; FProjection: IProjection; FBaseRelativeRect: TDoubleRect; FCachedForLocalCoordConverter: ILocalCoordConverter; - FCachedPoints: TArrayOfArrayOfFixedPoint; + FCachedPoints: TArrayOfArrayOfFloatPoint; protected function GetProjection: IProjection; - function PreparePoints(const ALocalCoordConverter: ILocalCoordConverter): TArrayOfArrayOfFixedPoint; + function PreparePoints(const ALocalCoordConverter: ILocalCoordConverter): TArrayOfArrayOfFloatPoint; public constructor Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint + APoints: TArrayOfArrayOfFloatPoint ); end; @@ -87,7 +85,7 @@ constructor Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint; + APoints: TArrayOfArrayOfFloatPoint; const AClosed: Boolean; const AColor: TColor32 ); @@ -105,7 +103,7 @@ constructor Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint; + APoints: TArrayOfArrayOfFloatPoint; const AColor: TColor32 ); end; @@ -132,6 +130,7 @@ uses SysUtils, GR32_Math, + GR32_VectorUtils, u_GeometryFunc, u_GeoFunc; @@ -140,7 +139,6 @@ constructor TProjectedDrawableElementByPolygonSimpleEdge.Create( const AProjection: IProjection; const ASource: IGeometryProjectedPolygon; - const AAntialiasMode: TAntialiasMode; const AColor: TColor32 ); begin @@ -148,7 +146,6 @@ inherited Create; FProjection := AProjection; FSource := ASource; - FAntialiasMode := AAntialiasMode; FColor := AColor; end; @@ -158,8 +155,8 @@ ); var VDrawRect: TDoubleRect; - VPolygon: TPolygon32; - VPathFixedPoints: TArrayOfFixedPoint; + VPolygon: TArrayOfArrayOfFloatPoint; + VPathPoints: TArrayOfFloatPoint; VIntersectRect: TDoubleRect; i: integer; VProjectedMultiLine: IGeometryProjectedMultiPolygon; @@ -168,39 +165,19 @@ VDrawRect := ALocalConverter.LocalRect2MapRectFloat(ABitmap.ClipRect); if IntersecProjectedRect(VIntersectRect, VDrawRect, FSource.Bounds) then begin if DoubleRectsEqual(VIntersectRect, FSource.Bounds) or FSource.IsRectIntersectBorder(VDrawRect) then begin - VPolygon := TPolygon32.Create; - try - VPolygon.Closed := True; - if Supports(FSource, IGeometryProjectedSinglePolygon, VProjectedSingleLine) then begin - ProjectedPolygon2GR32Polygon( - VProjectedSingleLine, - ALocalConverter, - am4times, - VPathFixedPoints, - VPolygon - ); + if Supports(FSource, IGeometryProjectedSinglePolygon, VProjectedSingleLine) then begin + VPolygon := ProjectedPolygon2ArrayOfArray(VProjectedSingleLine, ALocalConverter.GetRectInMapPixel, VPathPoints); + if Assigned(VPolygon) then begin + PolyPolylineFS(ABitmap, VPolygon, FColor, True); + end; + end else if Supports(FSource, IGeometryProjectedMultiPolygon, VProjectedMultiLine) then begin + for i := 0 to VProjectedMultiLine.Count - 1 do begin + VProjectedSingleLine := VProjectedMultiLine.Item[i]; + VPolygon := ProjectedPolygon2ArrayOfArray(VProjectedSingleLine, ALocalConverter.GetRectInMapPixel, VPathPoints); if Assigned(VPolygon) then begin - VPolygon.DrawEdge(ABitmap, FColor); - end; - end else if Supports(FSource, IGeometryProjectedMultiPolygon, VProjectedMultiLine) then begin - for i := 0 to VProjectedMultiLine.Count - 1 do begin - VProjectedSingleLine := VProjectedMultiLine.Item[i]; - ProjectedPolygon2GR32Polygon( - VProjectedSingleLine, - ALocalConverter, - am4times, - VPathFixedPoints, - VPolygon - ); - if Assigned(VPolygon) then begin - VPolygon.DrawEdge(ABitmap, FColor); - end; + PolyPolylineFS(ABitmap, VPolygon, FColor, True); end; end; - - VPathFixedPoints := nil; - finally - VPolygon.Free; end; end; end; @@ -211,63 +188,12 @@ Result := FProjection; end; -// Scales to a polygon (TArrayOfFixedPoint) -function ScalePolygon(const Points: TArrayOfFixedPoint; ScaleX, ScaleY: TFixed): TArrayOfFixedPoint; -var - I, L: Integer; -begin - L := Length(Points); - SetLength(Result, L); - for I := 0 to L - 1 do - begin - Result[I].X := FixedMul(Points[I].X, ScaleX); - Result[I].Y := FixedMul(Points[I].Y, ScaleY); - end; -end; - -// Scales all sub polygons in a complex polygon (TArrayOfArrayOfFixedPoint) -function ScalePolyPolygon(const Points: TArrayOfArrayOfFixedPoint; - ScaleX, ScaleY: TFixed): TArrayOfArrayOfFixedPoint; -var - I, L: Integer; -begin - L := Length(Points); - SetLength(Result, L); - for I := 0 to L - 1 do - Result[I] := ScalePolygon(Points[I], ScaleX, ScaleY); -end; -// Translates a polygon (TArrayOfFixedPoint) -function TranslatePolygon(const Points: TArrayOfFixedPoint; - OffsetX, OffsetY: TFixed): TArrayOfFixedPoint; -var - I, Len: Integer; -begin - Len := Length(Points); - SetLength(Result, Len); - for I := 0 to Len - 1 do - begin - Result[I].X := Points[I].X + OffsetX; - Result[I].Y := Points[I].Y + OffsetY; - end; -end; -// Translates all sub polygons in a complex polygon (TArrayOfArrayOfFixedPoint) -function TranslatePolyPolygon(const Points: TArrayOfArrayOfFixedPoint; - OffsetX, OffsetY: TFixed): TArrayOfArrayOfFixedPoint; -var - I, L: Integer; -begin - L := Length(Points); - SetLength(Result, L); - for I := 0 to L - 1 do - Result[I] := TranslatePolygon(Points[I], OffsetX, OffsetY); -end; - { TDrawableBaseByPoints } constructor TDrawableBaseByPoints.Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint + APoints: TArrayOfArrayOfFloatPoint ); begin Assert(Assigned(AProjection)); @@ -285,7 +211,7 @@ function TDrawableBaseByPoints.PreparePoints( const ALocalCoordConverter: ILocalCoordConverter -): TArrayOfArrayOfFixedPoint; +): TArrayOfArrayOfFloatPoint; var VTranslateDelta: TDoublePoint; VTargetRect: TDoubleRect; @@ -302,12 +228,12 @@ VTargetRect := ALocalCoordConverter.MapRectFloat2LocalRectFloat(ALocalCoordConverter.Projection.RelativeRect2PixelRectFloat(FBaseRelativeRect)); VScale := RectSize(VTargetRect); if (VScale.X <> 1.0) or (VScale.Y <> 1.0) then begin - FCachedPoints := ScalePolyPolygon(FCachedPoints, Fixed(VScale.X), Fixed(VScale.Y)); + FCachedPoints := ScalePolyPolygon(FCachedPoints, VScale.X, VScale.Y); end; VTranslateDelta := VTargetRect.TopLeft; if (Abs(VTranslateDelta.X) > 0.0001) or (Abs(VTranslateDelta.Y) > 0.0001) then begin - FCachedPoints := TranslatePolyPolygon(FCachedPoints, Fixed(VTranslateDelta.X), Fixed(VTranslateDelta.Y)); + FCachedPoints := TranslatePolyPolygon(FCachedPoints, VTranslateDelta.X, VTranslateDelta.Y); end; FCachedForLocalCoordConverter := ALocalCoordConverter; Result := FCachedPoints; @@ -318,7 +244,7 @@ constructor TDrawableSimpleLine.Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint; + APoints: TArrayOfArrayOfFloatPoint; const AClosed: Boolean; const AColor: TColor32 ); @@ -333,10 +259,10 @@ const ALocalCoordConverter: ILocalCoordConverter ); var - VPoints: TArrayOfArrayOfFixedPoint; + VPoints: TArrayOfArrayOfFloatPoint; begin VPoints := PreparePoints(ALocalCoordConverter); - PolyPolylineXS(ABitmap, VPoints, FColor, FClosed); + PolyPolylineFS(ABitmap, VPoints, FColor, FClosed); end; { TDrawablePolygonFill } @@ -344,7 +270,7 @@ constructor TDrawablePolygonFill.Create( const AProjection: IProjection; const AMapPixelAtLocalZero: TPoint; - APoints: TArrayOfArrayOfFixedPoint; + APoints: TArrayOfArrayOfFloatPoint; const AColor: TColor32 ); begin @@ -357,10 +283,10 @@ const ALocalCoordConverter: ILocalCoordConverter ); var - VPoints: TArrayOfArrayOfFixedPoint; + VPoints: TArrayOfArrayOfFloatPoint; begin VPoints := PreparePoints(ALocalCoordConverter); - PolyPolygonXS(ABitmap, VPoints, FColor, pfWinding, am4times); + PolyPolygonFS(ABitmap, VPoints, FColor, pfWinding); end; { TDrawableByList } diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/Polygon/u_MapLayerSingleGeometry.pas --- a/Src/MapLayers/WindowLayers/Polygon/u_MapLayerSingleGeometry.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/Polygon/u_MapLayerSingleGeometry.pas Sun Dec 08 19:07:06 2019 +0200 @@ -153,6 +153,7 @@ uses Types, SysUtils, + GR32_VectorUtils, i_InterfaceListSimple, u_SimpleFlagWithInterlock, u_InterfaceListSimple, @@ -350,8 +351,8 @@ var VLonLatLine: IGeometryLonLatLine; VProjectedLine: IGeometryProjectedLine; - VPathPoints: TArrayOfFixedPoint; - VPolygon: TArrayOfArrayOfFixedPoint; + VPathPoints: TArrayOfFloatPoint; + VPolygon: TArrayOfArrayOfFloatPoint; begin Result := nil; if (AlphaComponent(FLineColor) = 0) or (FLineWidth < 1) then begin @@ -430,8 +431,8 @@ var ADrawableList: IInterfaceListSimple ); var - VPathPoints: TArrayOfFixedPoint; - VPolygon: TArrayOfArrayOfFixedPoint; + VPathPoints: TArrayOfFloatPoint; + VPolygon: TArrayOfArrayOfFloatPoint; VFill: IProjectedDrawableElement; VBorder: IProjectedDrawableElement; begin diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/i_SunCalcShapesGenerator.pas --- a/Src/MapLayers/WindowLayers/SunCalc/i_SunCalcShapesGenerator.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/i_SunCalcShapesGenerator.pas Sun Dec 08 19:07:06 2019 +0200 @@ -48,25 +48,25 @@ ); procedure GetCirclePoints( - out ACirclePoints: TArrayOfFixedPoint + out ACirclePoints: TArrayOfFloatPoint ); procedure GetMinMaxAltitudePoints( - out AMinAltitudePoints: TArrayOfFixedPoint; - out AMaxAltitudePoints: TArrayOfFixedPoint; - out AMinMaxAltitudePolygon: TArrayOfFixedPoint + out AMinAltitudePoints: TArrayOfFloatPoint; + out AMaxAltitudePoints: TArrayOfFloatPoint; + out AMinMaxAltitudePolygon: TArrayOfFloatPoint ); procedure GetDayInfoPoints( - out ADayPoints: TArrayOfArrayOfFixedPoint; - out ARise: TFixedPoint; - out ASet: TFixedPoint; - out ACenter: TFixedPoint + out ADayPoints: TArrayOfArrayOfFloatPoint; + out ARise: TFloatPoint; + out ASet: TFloatPoint; + out ACenter: TFloatPoint ); procedure GetTimeInfoPoints( - out APos: TFixedPoint; - out ACenter: TFixedPoint + out APos: TFloatPoint; + out ACenter: TFloatPoint ); end; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/u_SunCalcDrawTools.pas --- a/Src/MapLayers/WindowLayers/SunCalc/u_SunCalcDrawTools.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/u_SunCalcDrawTools.pas Sun Dec 08 19:07:06 2019 +0200 @@ -27,14 +27,14 @@ procedure ThickLine( ABitmap: TBitmap32; - const AStart, AEnd: TFixedPoint; + const AStart, AEnd: TFloatPoint; const AColor: TColor32; const AWidth: Integer ); procedure ThickPolyLine( ABitmap: TBitmap32; - const APoints: TArrayOfFixedPoint; + const APoints: TArrayOfFloatPoint; const AColor: TColor32 ); @@ -50,86 +50,44 @@ procedure ThickLine( ABitmap: TBitmap32; - const AStart, AEnd: TFixedPoint; + const AStart, AEnd: TFloatPoint; const AColor: TColor32; const AWidth: Integer ); var I: Integer; P1, P2: TPoint; - VPolygon: TPolygon32; + VPolygon: TArrayOfFloatPoint; begin I := AWidth div 2; P1 := GR32.Point(AStart); P2 := GR32.Point(AEnd); - VPolygon := TPolygon32.Create; - try - VPolygon.Add(FixedPoint(P1.X - I, P1.Y)); - VPolygon.Add(FixedPoint(P1.X + I, P1.Y)); - VPolygon.Add(FixedPoint(P2.X + I, P2.Y)); - VPolygon.Add(FixedPoint(P2.X - I, P2.Y)); + SetLength(VPolygon, 4); - if GUsePolygonAntiAliasing then begin - try - PolyPolygonXS(ABitmap, VPolygon.Points, AColor); - except - GUsePolygonAntiAliasing := False; - end; - end else begin - PolyPolygonTS(ABitmap, VPolygon.Points, AColor); - end; + VPolygon[0] := FloatPoint(P1.X - I, P1.Y); + VPolygon[1] := FloatPoint(P1.X + I, P1.Y); + VPolygon[2] := FloatPoint(P2.X + I, P2.Y); + VPolygon[3] := FloatPoint(P2.X - I, P2.Y); - VPolygon.Clear; - - VPolygon.Add(FixedPoint(P1.X, P1.Y + I)); - VPolygon.Add(FixedPoint(P1.X, P1.Y - I)); - VPolygon.Add(FixedPoint(P2.X, P2.Y - I)); - VPolygon.Add(FixedPoint(P2.X, P2.Y + I)); + PolygonFS(ABitmap, VPolygon, AColor); - if GUsePolygonAntiAliasing then begin - try - PolyPolygonXS(ABitmap, VPolygon.Points, AColor); - except - GUsePolygonAntiAliasing := False; - end; - end else begin - PolyPolygonTS(ABitmap, VPolygon.Points, AColor); - end; - finally - VPolygon.Free; - end; + VPolygon[0] := FloatPoint(P1.X, P1.Y + I); + VPolygon[1] := FloatPoint(P1.X, P1.Y - I); + VPolygon[2] := FloatPoint(P2.X, P2.Y - I); + VPolygon[3] := FloatPoint(P2.X, P2.Y + I); + + PolygonFS(ABitmap, VPolygon, AColor); end; procedure ThickPolyLine( ABitmap: TBitmap32; - const APoints: TArrayOfFixedPoint; + const APoints: TArrayOfFloatPoint; const AColor: TColor32 ); -var - I: Integer; - VPolygon, VTmp: TPolygon32; begin - VPolygon := TPolygon32.Create; - try - VPolygon.Closed := False; - VPolygon.AddPoints(APoints[0], Length(APoints)); - for I := -2 to 1 do begin - if I = 0 then begin - PolylineXS(ABitmap, APoints, AColor, False); - end else begin - VTmp := VPolygon.Grow(Fixed(I)); - try - PolyPolyLineXS(ABitmap, VTmp.Points, AColor, False); - finally - VTmp.Free; - end; - end; - end; - finally - VPolygon.Free; - end; + PolylineFS(ABitmap, APoints, AColor, False, 4); end; end. diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/u_SunCalcShapesGenerator.pas --- a/Src/MapLayers/WindowLayers/SunCalc/u_SunCalcShapesGenerator.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/u_SunCalcShapesGenerator.pas Sun Dec 08 19:07:06 2019 +0200 @@ -47,22 +47,22 @@ FEndOfTheDay: TDateTime; FDataProvider: ISunCalcDataProvider; - FCirclePoints: TArrayOfFixedPoint; + FCirclePoints: TArrayOfFloatPoint; FIsCirclePointsValid: Boolean; FMinAltitude: Double; - FMaxAltitudeDayPoints: TArrayOfFixedPoint; - FMinAltitudeDayPoints: TArrayOfFixedPoint; - FMinMaxAltitudePoly: TArrayOfFixedPoint; + FMaxAltitudeDayPoints: TArrayOfFloatPoint; + FMinAltitudeDayPoints: TArrayOfFloatPoint; + FMinMaxAltitudePoly: TArrayOfFloatPoint; FIsAltitudePointsValid: Boolean; - FDayPoints: TArrayOfArrayOfFixedPoint; - FRisePoint: TFixedPoint; - FSetPoint: TFixedPoint; + FDayPoints: TArrayOfArrayOfFloatPoint; + FRisePoint: TFloatPoint; + FSetPoint: TFloatPoint; FIsDayInfoPointsValid: Boolean; - FCurrentPos: TFixedPoint; + FCurrentPos: TFloatPoint; FIsCurrentPosValid: Boolean; FLocalCoordConverter: ILocalCoordConverterChangeable; @@ -73,12 +73,12 @@ function GetPointPosition( const ADate: TDateTime; out AAltitude: Double - ): TFixedPoint; inline; + ): TFloatPoint; inline; function GenerateCurvePoints( const AStartOfTheDay: TDateTime; const AEndOfTheDay: TDateTime - ): TArrayOfArrayOfFixedPoint; + ): TArrayOfArrayOfFloatPoint; procedure UpdateMinAltitude( const AStartOfTheDay: TDateTime; @@ -103,25 +103,25 @@ ); procedure GetCirclePoints( - out ACirclePoints: TArrayOfFixedPoint + out ACirclePoints: TArrayOfFloatPoint ); procedure GetMinMaxAltitudePoints( - out AMinAltitudePoints: TArrayOfFixedPoint; - out AMaxAltitudePoints: TArrayOfFixedPoint; - out AMinMaxAltitudePolygon: TArrayOfFixedPoint + out AMinAltitudePoints: TArrayOfFloatPoint; + out AMaxAltitudePoints: TArrayOfFloatPoint; + out AMinMaxAltitudePolygon: TArrayOfFloatPoint ); procedure GetDayInfoPoints( - out ADayPoints: TArrayOfArrayOfFixedPoint; - out ARise: TFixedPoint; - out ASet: TFixedPoint; - out ACenter: TFixedPoint + out ADayPoints: TArrayOfArrayOfFloatPoint; + out ARise: TFloatPoint; + out ASet: TFloatPoint; + out ACenter: TFloatPoint ); procedure GetTimeInfoPoints( - out APos: TFixedPoint; - out ACenter: TFixedPoint + out APos: TFloatPoint; + out ACenter: TFloatPoint ); public constructor Create( @@ -178,7 +178,7 @@ function GenerateCircle( const ACenter: TFloatPoint; const ARadius: TFloat -): TArrayOfFixedPoint; +): TArrayOfFloatPoint; const cSteps: Integer = 72; var @@ -190,8 +190,8 @@ M := 2 * System.Pi / cSteps; // first item - Result[0].X := Fixed(ARadius + ACenter.X); - Result[0].Y := Fixed(ACenter.Y); + Result[0].X := ARadius + ACenter.X; + Result[0].Y := ACenter.Y; // calculate complex offset GR32_Math.SinCos(M, C.Y, C.X); @@ -199,20 +199,20 @@ D.Y := ARadius * C.Y; // second item - Result[1].X := Fixed(D.X + ACenter.X); - Result[1].Y := Fixed(D.Y + ACenter.Y); + Result[1].X := D.X + ACenter.X; + Result[1].Y := D.Y + ACenter.Y; // other items for I := 2 to cSteps - 1 do begin D := FloatPoint(D.X * C.X - D.Y * C.Y, D.Y * C.X + D.X * C.Y); - Result[I].X := Fixed(D.X + ACenter.X); - Result[I].Y := Fixed(D.Y + ACenter.Y); + Result[I].X := D.X + ACenter.X; + Result[I].Y := D.Y + ACenter.Y; end; end; procedure TSunCalcShapesGenerator.GetCirclePoints( - out ACirclePoints: TArrayOfFixedPoint + out ACirclePoints: TArrayOfFloatPoint ); begin if not IsValidSate then begin @@ -232,7 +232,7 @@ function TSunCalcShapesGenerator.GetPointPosition( const ADate: TDateTime; out AAltitude: Double -): TFixedPoint; +): TFloatPoint; var VPos: TSunCalcProviderPosition; VAngle: Double; @@ -240,23 +240,23 @@ begin if ADate = 0 then begin AAltitude := 0; - Result := FixedPoint(0, 0); + Result := FloatPoint(0, 0); Exit; end; VPos := FDataProvider.GetPosition(ADate, FLocation); VAngle := Pi / 2 + VPos.Azimuth; R := FRadius * Cos(VPos.Altitude); AAltitude := VPos.Altitude; - Result.X := Fixed(FCenter.X + R * Cos(VAngle)); - Result.Y := Fixed(FCenter.Y + R * Sin(VAngle)); + Result.X := FCenter.X + R * Cos(VAngle); + Result.Y := FCenter.Y + R * Sin(VAngle); end; function TSunCalcShapesGenerator.GenerateCurvePoints( const AStartOfTheDay: TDateTime; const AEndOfTheDay: TDateTime -): TArrayOfArrayOfFixedPoint; +): TArrayOfArrayOfFloatPoint; - function GetInterval(const AStart, AEnd: TDateTime): TArrayOfFixedPoint; + function GetInterval(const AStart, AEnd: TDateTime): TArrayOfFloatPoint; const cStep = 20; // minutes var @@ -347,9 +347,9 @@ function GenerateCircleSegment( const ACenter: TFloatPoint; const ARadius: Integer; - const AStart: TFixedPoint; - const AEnd: TFixedPoint -): TArrayOfFixedPoint; + const AStart: TFloatPoint; + const AEnd: TFloatPoint +): TArrayOfFloatPoint; const cStep: Double = 0.0873; // 5 degree var @@ -361,8 +361,8 @@ begin P := ACenter; - P1 := FloatPoint(AStart); - P2 := FloatPoint(AEnd); + P1 := AStart; + P2 := AEnd; A1 := ArcTan2(-(P1.Y - P.Y), P1.X - P.X); A2 := ArcTan2(-(P2.Y - P.Y), P2.X - P.X); @@ -379,28 +379,28 @@ D.X := P1.X - P.X; D.Y := P1.Y - P.Y; - Result[0].X := Fixed(D.X + P.X); - Result[0].Y := Fixed(D.Y + P.Y); + Result[0].X := D.X + P.X; + Result[0].Y := D.Y + P.Y; for I := 1 to VSteps - 1 do begin D := FloatPoint(D.X * C.X - D.Y * C.Y, D.Y * C.X + D.X * C.Y); - Result[I].X := Fixed(D.X + P.X); - Result[I].Y := Fixed(D.Y + P.Y); + Result[I].X := D.X + P.X; + Result[I].Y := D.Y + P.Y; end; end; procedure TSunCalcShapesGenerator.GetMinMaxAltitudePoints( - out AMinAltitudePoints: TArrayOfFixedPoint; - out AMaxAltitudePoints: TArrayOfFixedPoint; - out AMinMaxAltitudePolygon: TArrayOfFixedPoint + out AMinAltitudePoints: TArrayOfFloatPoint; + out AMaxAltitudePoints: TArrayOfFloatPoint; + out AMinMaxAltitudePolygon: TArrayOfFloatPoint ); var I, J: Integer; VDay: TDateTime; - VPoints: TArrayOfArrayOfFixedPoint; + VPoints: TArrayOfArrayOfFloatPoint; VLen1, VLen2, VLen3, VLen4: Integer; - VSeg1, VSeg2: TArrayOfFixedPoint; + VSeg1, VSeg2: TArrayOfFloatPoint; begin if not IsValidSate then begin SetLength(AMinAltitudePoints, 0); @@ -454,7 +454,7 @@ SetLength(FMinMaxAltitudePoly, VLen1 + VLen2 + VLen3 + VLen4); - Move(FMaxAltitudeDayPoints[0], FMinMaxAltitudePoly[0], VLen1 * SizeOf(TFixedPoint)); + Move(FMaxAltitudeDayPoints[0], FMinMaxAltitudePoly[0], VLen1 * SizeOf(TFloatPoint)); J := VLen1; @@ -485,19 +485,19 @@ end; procedure TSunCalcShapesGenerator.GetDayInfoPoints( - out ADayPoints: TArrayOfArrayOfFixedPoint; - out ARise, ASet, ACenter: TFixedPoint + out ADayPoints: TArrayOfArrayOfFloatPoint; + out ARise, ASet, ACenter: TFloatPoint ); var VTimes: TSunCalcProviderTimes; VAltitude: Double; begin - ACenter := FixedPoint(FCenter); + ACenter := FCenter; if not IsValidSate then begin SetLength(ADayPoints, 0); - ARise := FixedPoint(0, 0); - ASet := FixedPoint(0, 0); + ARise := FloatPoint(0, 0); + ASet := FloatPoint(0, 0); Exit; end; @@ -517,14 +517,14 @@ end; procedure TSunCalcShapesGenerator.GetTimeInfoPoints( - out APos, ACenter: TFixedPoint + out APos, ACenter: TFloatPoint ); var VAltitude: Double; begin if not IsValidSate then begin - APos := FixedPoint(0, 0); - ACenter := FixedPoint(0, 0); + APos := FloatPoint(0, 0); + ACenter := FloatPoint(0, 0); Exit; end; @@ -536,7 +536,7 @@ if VAltitude < FMinAltitude then begin UpdateMinAltitude(FStartOfTheDay, FEndOfTheDay); if VAltitude < FMinAltitude then begin - FCurrentPos := FixedPoint(0, 0); + FCurrentPos := FloatPoint(0, 0); end; end; @@ -544,7 +544,7 @@ end; APos := FCurrentPos; - ACenter := FixedPoint(FCenter); + ACenter := FCenter; end; procedure TSunCalcShapesGenerator.UpdateMinAltitude( @@ -553,7 +553,7 @@ ); var VAlt: Double; - VPoint: TFixedPoint; + VPoint: TFloatPoint; VTimes: TSunCalcProviderTimes; begin FMinAltitude := 0; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcDayInfo.pas --- a/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcDayInfo.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcDayInfo.pas Sun Dec 08 19:07:06 2019 +0200 @@ -52,10 +52,10 @@ procedure TWindowLayerSunCalcDayInfo.PaintLayer(ABuffer: TBitmap32); var I: Integer; - VDayPoints: TArrayOfArrayOfFixedPoint; - VRisePoint: TFixedPoint; - VSetPoint: TFixedPoint; - VCenter: TFixedPoint; + VDayPoints: TArrayOfArrayOfFloatPoint; + VRisePoint: TFloatPoint; + VSetPoint: TFloatPoint; + VCenter: TFloatPoint; begin if not FShapesGenerator.IsIntersectScreenRect then begin Exit; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcTimeInfo.pas --- a/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcTimeInfo.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcTimeInfo.pas Sun Dec 08 19:07:06 2019 +0200 @@ -128,8 +128,8 @@ procedure TWindowLayerSunCalcTimeInfo.PaintLayer(ABuffer: TBitmap32); var - VCenter: TFixedPoint; - VCurrentPos: TFixedPoint; + VCenter: TFloatPoint; + VCurrentPos: TFloatPoint; begin if not FShapesGenerator.IsIntersectScreenRect then begin Exit; diff -r bf461203504c -r f323278af2ff Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcYearInfo.pas --- a/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcYearInfo.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/MapLayers/WindowLayers/SunCalc/u_WindowLayerSunCalcYearInfo.pas Sun Dec 08 19:07:06 2019 +0200 @@ -52,7 +52,7 @@ procedure TWindowLayerSunCalcYearInfo.PaintLayer(ABuffer: TBitmap32); var - VCircle, VMaxAlt, VMinAlt, VPoly: TArrayOfFixedPoint; + VCircle, VMaxAlt, VMinAlt, VPoly: TArrayOfFloatPoint; begin if not FShapesGenerator.IsIntersectScreenRect then begin Exit; @@ -65,23 +65,23 @@ // Background circle FShapesGenerator.GetCirclePoints(VCircle); if Length(VCircle) > 0 then begin - PolylineXS(ABuffer, VCircle, FShapesColors.YearCircleColor, True); + PolylineFS(ABuffer, VCircle, FShapesColors.YearCircleColor, True); end; // Min/Max altitude FShapesGenerator.GetMinMaxAltitudePoints(VMinAlt, VMaxAlt, VPoly); if Length(VMinAlt) > 0 then begin - PolylineXS(ABuffer, VMinAlt, FShapesColors.YearPolyLinesColor, False); + PolylineFS(ABuffer, VMinAlt, FShapesColors.YearPolyLinesColor, False); end; if Length(VMaxAlt) > 0 then begin - PolylineXS(ABuffer, VMaxAlt, FShapesColors.YearPolyLinesColor, False); + PolylineFS(ABuffer, VMaxAlt, FShapesColors.YearPolyLinesColor, False); end; // Draw transparent polygon betwen min and max altitude curves if Length(VPoly) > 0 then begin - PolygonTS(ABuffer, VPoly, FShapesColors.YearPolygonFillColor); + PolygonFS(ABuffer, VPoly, FShapesColors.YearPolygonFillColor); end; finally diff -r bf461203504c -r f323278af2ff Src/Marker/u_MarkerDrawableSimpleArrow.pas --- a/Src/Marker/u_MarkerDrawableSimpleArrow.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Marker/u_MarkerDrawableSimpleArrow.pas Sun Dec 08 19:07:06 2019 +0200 @@ -54,7 +54,7 @@ const AAngle: Double ): Boolean; var - VPolygon: TPolygon32; + VPolygon: TArrayOfFloatPoint; VTransform: TAffineTransformation; VHalfSize: Double; VWidth: Double; @@ -82,20 +82,12 @@ VTransform := TAffineTransformation.Create; try VTransform.Rotate(APosition.X, APosition.Y, -AAngle); - VPolygon := TPolygon32.Create; - try - VPolygon.Closed := True; - VPolygon.Antialiased := true; - VPolygon.AntialiasMode := am2times; - VPolygon.Add(VTransform.Transform(FixedPoint(APosition.X, APosition.Y - VHalfSize))); - VPolygon.Add(VTransform.Transform(FixedPoint(APosition.X - VWidth, APosition.Y + VHalfSize))); - VPolygon.Add(VTransform.Transform(FixedPoint(APosition.X + VWidth, APosition.Y + VHalfSize))); - - VPolygon.DrawFill(ABitmap, Config.MarkerColor); - VPolygon.DrawEdge(ABitmap, Config.BorderColor); - finally - VPolygon.Free; - end; + SetLength(VPolygon, 3); + VPolygon[0] := VTransform.Transform(FloatPoint(APosition.X, APosition.Y - VHalfSize)); + VPolygon[1] := VTransform.Transform(FloatPoint(APosition.X - VWidth, APosition.Y + VHalfSize)); + VPolygon[2] := VTransform.Transform(FloatPoint(APosition.X + VWidth, APosition.Y + VHalfSize)); + PolygonFS(ABitmap, VPolygon, Config.MarkerColor); + PolylineFS(ABitmap, VPolygon, Config.BorderColor, True); finally VTransform.Free; end; diff -r bf461203504c -r f323278af2ff Src/Marker/u_MarkerDrawableSimpleCircle.pas --- a/Src/Marker/u_MarkerDrawableSimpleCircle.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Marker/u_MarkerDrawableSimpleCircle.pas Sun Dec 08 19:07:06 2019 +0200 @@ -57,7 +57,7 @@ function GenerateCirclePoints( const ACenter: TFloatPoint; const ARadius: TFloat -): TArrayOfFixedPoint; +): TArrayOfFloatPoint; var I: Integer; M: TFloat; @@ -70,8 +70,8 @@ M := 2 * System.Pi / VSteps; // first item - Result[0].X := Fixed(ARadius + ACenter.X); - Result[0].Y := Fixed(ACenter.Y); + Result[0].X := ARadius + ACenter.X; + Result[0].Y := ACenter.Y; // calculate complex offset GR32_Math.SinCos(M, C.Y, C.X); @@ -79,15 +79,15 @@ D.Y := ARadius * C.Y; // second item - Result[1].X := Fixed(D.X + ACenter.X); - Result[1].Y := Fixed(D.Y + ACenter.Y); + Result[1].X := D.X + ACenter.X; + Result[1].Y := D.Y + ACenter.Y; // other items for I := 2 to VSteps - 1 do begin D := FloatPoint(D.X * C.X - D.Y * C.Y, D.Y * C.X + D.X * C.Y); - Result[I].X := Fixed(D.X + ACenter.X); - Result[I].Y := Fixed(D.Y + ACenter.Y); + Result[I].X := D.X + ACenter.X; + Result[I].Y := D.Y + ACenter.Y; end; end; @@ -102,7 +102,7 @@ VDoubleRect: TDoubleRect; VRect: TRect; VTargetRect: TRect; - VCirclePoints: TArrayOfFixedPoint; + VCirclePoints: TArrayOfFloatPoint; begin VHalfSize := Config.MarkerSize / 2; VDoubleRect.Left := APosition.X - VHalfSize; @@ -124,9 +124,9 @@ VHalfSize ); if Length(VCirclePoints) > 0 then begin - PolygonTS(ABitmap, VCirclePoints, Config.MarkerColor); + PolygonFS(ABitmap, VCirclePoints, Config.MarkerColor); if Config.MarkerColor <> Config.BorderColor then begin - PolylineXS(ABitmap, VCirclePoints, Config.BorderColor, True); + PolylineFS(ABitmap, VCirclePoints, Config.BorderColor, True); end; end; end else begin diff -r bf461203504c -r f323278af2ff Src/Marker/u_MarkerDrawableSimpleCross.pas --- a/Src/Marker/u_MarkerDrawableSimpleCross.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/Marker/u_MarkerDrawableSimpleCross.pas Sun Dec 08 19:07:06 2019 +0200 @@ -54,7 +54,7 @@ var VCrossHalfWidth: Double; VHalfSize: Double; - VPolygon: TPolygon32; + VPolygon: TArrayOfFloatPoint; VTargetRect: TRect; VTargetDoubleRect: TDoubleRect; begin @@ -74,29 +74,21 @@ if not ABitmap.MeasuringMode then begin ABitmap.BeginUpdate; try - VPolygon := TPolygon32.Create; - try - VPolygon.Closed := True; - VPolygon.Antialiased := true; - VPolygon.AntialiasMode := am2times; - VPolygon.Add(FixedPoint(APosition.X - VCrossHalfWidth, APosition.Y - VHalfSize)); - VPolygon.Add(FixedPoint(APosition.X + VCrossHalfWidth, APosition.Y - VHalfSize)); - VPolygon.Add(FixedPoint(APosition.X + VCrossHalfWidth, APosition.Y - VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X + VHalfSize, APosition.Y - VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X + VHalfSize, APosition.Y + VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X + VCrossHalfWidth, APosition.Y + VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X + VCrossHalfWidth, APosition.Y + VHalfSize)); - VPolygon.Add(FixedPoint(APosition.X - VCrossHalfWidth, APosition.Y + VHalfSize)); - VPolygon.Add(FixedPoint(APosition.X - VCrossHalfWidth, APosition.Y + VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X - VHalfSize, APosition.Y + VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X - VHalfSize, APosition.Y - VCrossHalfWidth)); - VPolygon.Add(FixedPoint(APosition.X - VCrossHalfWidth, APosition.Y - VCrossHalfWidth)); - - VPolygon.DrawFill(ABitmap, Config.MarkerColor); - VPolygon.DrawEdge(ABitmap, Config.BorderColor); - finally - VPolygon.Free; - end; + SetLength(VPolygon, 12); + VPolygon[0] := FloatPoint(APosition.X - VCrossHalfWidth, APosition.Y - VHalfSize); + VPolygon[1] := FloatPoint(APosition.X + VCrossHalfWidth, APosition.Y - VHalfSize); + VPolygon[2] := FloatPoint(APosition.X + VCrossHalfWidth, APosition.Y - VCrossHalfWidth); + VPolygon[3] := FloatPoint(APosition.X + VHalfSize, APosition.Y - VCrossHalfWidth); + VPolygon[4] := FloatPoint(APosition.X + VHalfSize, APosition.Y + VCrossHalfWidth); + VPolygon[5] := FloatPoint(APosition.X + VCrossHalfWidth, APosition.Y + VCrossHalfWidth); + VPolygon[6] := FloatPoint(APosition.X + VCrossHalfWidth, APosition.Y + VHalfSize); + VPolygon[7] := FloatPoint(APosition.X - VCrossHalfWidth, APosition.Y + VHalfSize); + VPolygon[8] := FloatPoint(APosition.X - VCrossHalfWidth, APosition.Y + VCrossHalfWidth); + VPolygon[9] := FloatPoint(APosition.X - VHalfSize, APosition.Y + VCrossHalfWidth); + VPolygon[10] := FloatPoint(APosition.X - VHalfSize, APosition.Y - VCrossHalfWidth); + VPolygon[11] := FloatPoint(APosition.X - VCrossHalfWidth, APosition.Y - VCrossHalfWidth); + PolygonFS(ABitmap, VPolygon, Config.MarkerColor); + PolylineFS(ABitmap, VPolygon, Config.BorderColor, True); finally ABitmap.EndUpdate; end; diff -r bf461203504c -r f323278af2ff Src/TileProvider/u_VectorTileRenderer.pas --- a/Src/TileProvider/u_VectorTileRenderer.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/TileProvider/u_VectorTileRenderer.pas Sun Dec 08 19:07:06 2019 +0200 @@ -58,7 +58,7 @@ ATargetBmp: TCustomBitmap32; const AProjection: IProjection; const AMapRect: TRect; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawPoint( var ABitmapInited: Boolean; @@ -75,7 +75,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const ALine: IGeometryLonLatLine; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawPoly( var ABitmapInited: Boolean; @@ -84,7 +84,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryLonLatPolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawSinglePolygon( var ABitmapInited: Boolean; @@ -92,7 +92,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryProjectedSinglePolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; procedure InitBitmap( ATargetBmp: TCustomBitmap32; @@ -210,67 +210,30 @@ const AMapRect: TRect; const AAppearance: IAppearance; const ALine: IGeometryLonLatLine; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var - VPolygon: TPolygon32; + VPolygon: TArrayOfArrayOfFloatPoint; VProjected: IGeometryProjectedLine; VAppearanceLine: IAppearanceLine; begin Result := False; - VPolygon := nil; VProjected := FProjectedCache.GetProjectedPath(AProjection, ALine); - ProjectedLine2GR32Polygon( - VProjected, - AMapRect, - am4times, - AFixedPointArray, - VPolygon - ); - try - if Assigned(VPolygon) then begin - if not ABitmapInited then begin - InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); - ABitmapInited := True; - end; + VPolygon := ProjectedLine2ArrayOfArray(VProjected, AMapRect, APointArray); + if Assigned(VPolygon) then begin + if not ABitmapInited then begin + InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); + ABitmapInited := True; + end; - if Supports(AAppearance, IAppearanceLine, VAppearanceLine) then begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(VAppearanceLine.LineWidth / 2), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, VAppearanceLine.LineColor); - finally - free; - end; - end; - finally - free; - end; - end; - end else begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(0.5), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, FColorBG); - finally - free; - end; - end; - finally - free; - end; - end; - VPolygon.DrawEdge(ATargetBmp, FColorMain); - end; + if Supports(AAppearance, IAppearanceLine, VAppearanceLine) then begin + PolyPolylineFS(ATargetBmp, VPolygon, VAppearanceLine.LineColor, False, VAppearanceLine.LineWidth); + end else begin + PolyPolylineFS(ATargetBmp, VPolygon, FColorBG, False, 2); + PolyPolylineFS(ATargetBmp, VPolygon, FColorMain, False, 1); + end; - Result := True; - end; - finally - VPolygon.Free; + Result := True; end; end; @@ -280,69 +243,32 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryProjectedSinglePolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var - VPolygon: TPolygon32; + VPolygon: TArrayOfArrayOfFloatPoint; VAppearanceBorder: IAppearancePolygonBorder; VAppearanceFill: IAppearancePolygonFill; begin Result := False; - VPolygon := nil; - try - ProjectedPolygon2GR32Polygon( - APoly, - AMapRect, - am4times, - AFixedPointArray, - VPolygon - ); - if VPolygon <> nil then begin - if not ABitmapInited then begin - InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); - ABitmapInited := True; + VPolygon := ProjectedPolygon2ArrayOfArray(APoly, AMapRect, APointArray); + if VPolygon <> nil then begin + if not ABitmapInited then begin + InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); + ABitmapInited := True; + end; + if Assigned(AAppearance) then begin + if Supports(AAppearance, IAppearancePolygonFill, VAppearanceFill) then begin + PolyPolygonFS(ATargetBmp, VPolygon, VAppearanceFill.FillColor, pfWinding); end; - if Assigned(AAppearance) then begin - if Supports(AAppearance, IAppearancePolygonFill, VAppearanceFill) then begin - VPolygon.DrawFill(ATargetBmp, VAppearanceFill.FillColor); - end; - if Supports(AAppearance, IAppearancePolygonBorder, VAppearanceBorder) then begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(VAppearanceBorder.LineWidth / 2), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, VAppearanceBorder.LineColor); - finally - free; - end; - end; - finally - free; - end; - end; - end; - end else begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(0.5), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, FColorBG); - finally - free; - end; - end; - finally - free; - end; - end; - VPolygon.DrawEdge(ATargetBmp, FColorMain); + if Supports(AAppearance, IAppearancePolygonBorder, VAppearanceBorder) then begin + PolyPolylineFS(ATargetBmp, VPolygon, VAppearanceBorder.LineColor, True, VAppearanceBorder.LineWidth); end; - Result := True; + end else begin + PolyPolylineFS(ATargetBmp, VPolygon, FColorBG, True, 2); + PolyPolylineFS(ATargetBmp, VPolygon, FColorMain, True, 1); end; - finally - VPolygon.Free; + Result := True; end; end; @@ -353,7 +279,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryLonLatPolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var VProjected: IGeometryProjectedPolygon; @@ -365,11 +291,11 @@ VProjected := FProjectedCache.GetProjectedPolygon(AProjection, APoly); if Assigned(VProjected) then begin if Supports(VProjected, IGeometryProjectedSinglePolygon, VProjectedSingle) then begin - Result := DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, AFixedPointArray); + Result := DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, APointArray); end else if Supports(VProjected, IGeometryProjectedMultiPolygon, VProjectedMulti) then begin for i := 0 to VProjectedMulti.Count - 1 do begin VProjectedSingle := VProjectedMulti.Item[i]; - if DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, AFixedPointArray) then begin + if DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, APointArray) then begin Result := True; end; end; @@ -386,7 +312,7 @@ ATargetBmp: TCustomBitmap32; const AProjection: IProjection; const AMapRect: TRect; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var VEnumMarks: IEnumUnknown; @@ -405,7 +331,7 @@ Break; end; if Supports(VMark.Geometry, IGeometryLonLatPolygon, VPoly) then begin - if DrawPoly(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VPoly, AFixedPointArray) then begin + if DrawPoly(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VPoly, APointArray) then begin Result := True; end; end; @@ -416,7 +342,7 @@ Break; end; if Supports(VMark.Geometry, IGeometryLonLatLine, VLine) then begin - if DrawPath(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VLine, AFixedPointArray) then begin + if DrawPath(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VLine, APointArray) then begin Result := True; end; end; @@ -444,14 +370,14 @@ var VMapRect: TRect; VBitmap: TBitmap32ByStaticBitmap; - VFixedPointArray: TArrayOfFixedPoint; + VPointArray: TArrayOfFloatPoint; begin Result := nil; if Assigned(ASource) and not ASource.IsEmpty then begin VBitmap := TBitmap32ByStaticBitmap.Create(FBitmap32StaticFactory); try VMapRect := AProjection.TilePos2PixelRect(ATile); - if DrawSubset(AOperationID, ACancelNotifier, ASource, VBitmap, AProjection, VMapRect, VFixedPointArray) then begin + if DrawSubset(AOperationID, ACancelNotifier, ASource, VBitmap, AProjection, VMapRect, VPointArray) then begin Result := VBitmap.MakeAndClear; end; finally diff -r bf461203504c -r f323278af2ff Src/TileProvider/u_VectorTileRendererForMarks.pas --- a/Src/TileProvider/u_VectorTileRendererForMarks.pas Sat Dec 07 16:54:46 2019 +0300 +++ b/Src/TileProvider/u_VectorTileRendererForMarks.pas Sun Dec 08 19:07:06 2019 +0200 @@ -56,7 +56,7 @@ ATargetBmp: TCustomBitmap32; const AProjection: IProjection; const AMapRect: TRect; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawPoint( var ABitmapInited: Boolean; @@ -73,7 +73,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const ALine: IGeometryLonLatLine; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawPoly( var ABitmapInited: Boolean; @@ -82,7 +82,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryLonLatPolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; function DrawSinglePolygon( var ABitmapInited: Boolean; @@ -90,7 +90,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryProjectedSinglePolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; procedure InitBitmap( @@ -183,49 +183,25 @@ const AMapRect: TRect; const AAppearance: IAppearance; const ALine: IGeometryLonLatLine; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var - VPolygon: TPolygon32; + VPolygon: TArrayOfArrayOfFloatPoint; VProjected: IGeometryProjectedLine; VAppearanceLine: IAppearanceLine; begin Result := False; - VPolygon := nil; VProjected := FProjectedCache.GetProjectedPath(AProjection, ALine); - ProjectedLine2GR32Polygon( - VProjected, - AMapRect, - am4times, - AFixedPointArray, - VPolygon - ); - try - if Assigned(VPolygon) then begin - if not ABitmapInited then begin - InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); - ABitmapInited := True; - end; - if Supports(AAppearance, IAppearanceLine, VAppearanceLine) then begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(VAppearanceLine.LineWidth / 2), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, VAppearanceLine.LineColor); - finally - free; - end; - end; - finally - free; - end; - end; - end; - Result := True; + VPolygon := ProjectedLine2ArrayOfArray(VProjected, AMapRect, APointArray); + if Assigned(VPolygon) then begin + if not ABitmapInited then begin + InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); + ABitmapInited := True; end; - finally - VPolygon.Free; + if Supports(AAppearance, IAppearanceLine, VAppearanceLine) then begin + PolyPolylineFS(ATargetBmp, VPolygon, VAppearanceLine.LineColor, False, VAppearanceLine.LineWidth); + end; + Result := True; end; end; @@ -235,51 +211,27 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryProjectedSinglePolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var - VPolygon: TPolygon32; + VPolygon: TArrayOfArrayOfFloatPoint; VAppearanceBorder: IAppearancePolygonBorder; VAppearanceFill: IAppearancePolygonFill; begin Result := False; - VPolygon := nil; - try - ProjectedPolygon2GR32Polygon( - APoly, - AMapRect, - am4times, - AFixedPointArray, - VPolygon - ); - if VPolygon <> nil then begin - if not ABitmapInited then begin - InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); - ABitmapInited := True; - end; - if Supports(AAppearance, IAppearancePolygonFill, VAppearanceFill) then begin - VPolygon.DrawFill(ATargetBmp, VAppearanceFill.FillColor); - end; - if Supports(AAppearance, IAppearancePolygonBorder, VAppearanceBorder) then begin - with VPolygon.Outline do begin - try - with Grow(GR32.Fixed(VAppearanceBorder.LineWidth / 2), 0.5) do begin - try - FillMode := pfWinding; - DrawFill(ATargetBmp, VAppearanceBorder.LineColor); - finally - free; - end; - end; - finally - free; - end; - end; - end; - Result := True; + VPolygon := ProjectedPolygon2ArrayOfArray(APoly, AMapRect, APointArray); + if VPolygon <> nil then begin + if not ABitmapInited then begin + InitBitmap(ATargetBmp, Types.Point(AMapRect.Right - AMapRect.Left, AMapRect.Bottom - AMapRect.Top)); + ABitmapInited := True; end; - finally - VPolygon.Free; + if Supports(AAppearance, IAppearancePolygonFill, VAppearanceFill) then begin + PolyPolygonFS(ATargetBmp, VPolygon, VAppearanceFill.FillColor); + end; + if Supports(AAppearance, IAppearancePolygonBorder, VAppearanceBorder) then begin + PolyPolylineFS(ATargetBmp, VPolygon, VAppearanceBorder.LineColor, True, VAppearanceBorder.LineWidth); + end; + Result := True; end; end; @@ -290,7 +242,7 @@ const AMapRect: TRect; const AAppearance: IAppearance; const APoly: IGeometryLonLatPolygon; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var VProjected: IGeometryProjectedPolygon; @@ -302,11 +254,11 @@ VProjected := FProjectedCache.GetProjectedPolygon(AProjection, APoly); if Assigned(VProjected) then begin if Supports(VProjected, IGeometryProjectedSinglePolygon, VProjectedSingle) then begin - Result := DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, AFixedPointArray); + Result := DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, APointArray); end else if Supports(VProjected, IGeometryProjectedMultiPolygon, VProjectedMulti) then begin for i := 0 to VProjectedMulti.Count - 1 do begin VProjectedSingle := VProjectedMulti.Item[i]; - if DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, AFixedPointArray) then begin + if DrawSinglePolygon(ABitmapInited, ATargetBmp, AMapRect, AAppearance, VProjectedSingle, APointArray) then begin Result := True; end; end; @@ -323,7 +275,7 @@ ATargetBmp: TCustomBitmap32; const AProjection: IProjection; const AMapRect: TRect; - var AFixedPointArray: TArrayOfFixedPoint + var APointArray: TArrayOfFloatPoint ): Boolean; var VEnumMarks: IEnumUnknown; @@ -342,7 +294,7 @@ Break; end; if Supports(VMark.Geometry, IGeometryLonLatPolygon, VPoly) then begin - if DrawPoly(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VPoly, AFixedPointArray) then begin + if DrawPoly(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VPoly, APointArray) then begin Result := True; end; end; @@ -353,7 +305,7 @@ Break; end; if Supports(VMark.Geometry, IGeometryLonLatLine, VLine) then begin - if DrawPath(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VLine, AFixedPointArray) then begin + if DrawPath(VBitmapInited, ATargetBmp, AProjection, AMapRect, VMark.Appearance, VLine, APointArray) then begin Result := True; end; end; @@ -381,7 +333,7 @@ var VMapRect: TRect; VBitmap: TBitmap32ByStaticBitmap; - VFixedPointArray: TArrayOfFixedPoint; + VFixedPointArray: TArrayOfFloatPoint; begin Result := nil; if Assigned(ASource) and not ASource.IsEmpty then begin