Changeset 494 for GraphicTest/Packages/bgrabitmap/bgrafillinfo.pas
- Timestamp:
- Dec 22, 2016, 8:49:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/bgrafillinfo.pas
r472 r494 37 37 function GetBounds: TRect; override; 38 38 39 //compute min-max to be drawn on destination bitmap according to cliprect. Returns false if40 //there is nothing to draw41 function ComputeMinMax(out minx,miny,maxx,maxy: integer; bmpDest: TBGRACustomBitmap): boolean; override;42 43 39 //check if the point is inside the filling zone 44 40 function IsPointInside(x,y: single; windingMode: boolean): boolean; override; … … 54 50 procedure ComputeAndSort(cury: single; var inter: ArrayOfTIntersectionInfo; out nbInter: integer; windingMode: boolean); override; 55 51 52 //can be called after ComputeAndSort or ComputeIntersection to determine the current horizontal slice 53 //so that it can be checked if the intermediates scanlines can be skipped 54 function GetSliceIndex: integer; override; 55 56 56 end; 57 57 … … 61 61 private 62 62 FX, FY, FRX, FRY: single; 63 FSliceIndex: integer; 63 64 function GetCenter: TPointF; 64 65 protected … … 71 72 function GetBounds: TRect; override; 72 73 function SegmentsCurved: boolean; override; 74 function GetSliceIndex: integer; override; 73 75 property Center: TPointF read GetCenter; 74 76 property RadiusX: single read FRX; … … 90 92 function SegmentsCurved: boolean; override; 91 93 destructor Destroy; override; 94 function GetSliceIndex: integer; override; 92 95 property InnerBorder: TFillEllipseInfo read FInnerBorder; 93 96 property OuterBorder: TFillEllipseInfo read FOuterBorder; … … 179 182 constructor Create(const points: array of TPointF); 180 183 destructor Destroy; override; 184 function GetSliceIndex: integer; override; 181 185 end; 182 186 … … 208 212 FFirstWaiting, FFirstDrawing: POnePassRecord; 209 213 FShouldInitializeDrawing: boolean; 214 FSliceIndex: integer; 210 215 procedure ComputeIntersection(cury: single; 211 216 var inter: ArrayOfTIntersectionInfo; var nbInter: integer); override; … … 213 218 constructor Create(const points: array of TPointF); 214 219 function CreateIntersectionArray: ArrayOfTIntersectionInfo; override; 220 function GetSliceIndex: integer; override; 215 221 destructor Destroy; override; 216 222 end; … … 243 249 function IsPointInRectangle(x1, y1, x2, y2: single; point: TPointF): boolean; 244 250 251 function BGRAShapeComputeMinMax(AShape: TBGRACustomFillInfo; out minx, miny, maxx, maxy: integer; 252 bmpDest: TBGRACustomBitmap): boolean; 253 245 254 implementation 246 255 247 256 uses Math; 257 258 function BGRAShapeComputeMinMax(AShape: TBGRACustomFillInfo; out minx, miny, maxx, maxy: integer; 259 bmpDest: TBGRACustomBitmap): boolean; 260 var clip,bounds: TRect; 261 begin 262 result := true; 263 bounds := AShape.GetBounds; 264 265 if (bounds.Right <= bounds.left) or (bounds.bottom <= bounds.top) then 266 begin 267 result := false; 268 exit; 269 end; 270 271 miny := bounds.top; 272 maxy := bounds.bottom - 1; 273 minx := bounds.left; 274 maxx := bounds.right - 1; 275 276 clip := bmpDest.ClipRect; 277 278 if minx < clip.Left then 279 minx := clip.Left; 280 if maxx < clip.Left then 281 result := false; 282 283 if maxx > clip.Right - 1 then 284 maxx := clip.Right- 1; 285 if minx > clip.Right - 1 then 286 result := false; 287 288 if miny < clip.Top then 289 miny := clip.Top; 290 if maxy < clip.Top then 291 result := false; 292 293 if maxy > clip.Bottom - 1 then 294 maxy := clip.Bottom - 1; 295 if miny > clip.Bottom - 1 then 296 result := false; 297 end; 248 298 249 299 procedure ComputeAliasedRowBounds(x1,x2: single; minx,maxx: integer; out ix1,ix2: integer); … … 345 395 end; 346 396 347 function TFillShapeInfo.ComputeMinMax(out minx, miny, maxx, maxy: integer;348 bmpDest: TBGRACustomBitmap): boolean;349 var clip,bounds: TRect;350 begin351 result := true;352 bounds := GetBounds;353 354 if (bounds.Right <= bounds.left) or (bounds.bottom <= bounds.top) then355 begin356 result := false;357 exit;358 end;359 360 miny := bounds.top;361 maxy := bounds.bottom - 1;362 minx := bounds.left;363 maxx := bounds.right - 1;364 365 clip := bmpDest.ClipRect;366 367 if minx < clip.Left then368 minx := clip.Left;369 if maxx < clip.Left then370 result := false;371 372 if maxx > clip.Right - 1 then373 maxx := clip.Right- 1;374 if minx > clip.Right - 1 then375 result := false;376 377 if miny < clip.Top then378 miny := clip.Top;379 if maxy < clip.Top then380 result := false;381 382 if maxy > clip.Bottom - 1 then383 maxy := clip.Bottom - 1;384 if miny > clip.Bottom - 1 then385 result := false;386 end;387 397 388 398 function TFillShapeInfo.IsPointInside(x, y: single; windingMode: boolean … … 489 499 SortIntersection(inter,nbInter); 490 500 if windingMode then ConvertFromNonZeroWinding(inter,nbInter); 501 end; 502 503 function TFillShapeInfo.GetSliceIndex: integer; 504 begin 505 result := 0; 491 506 end; 492 507 … … 886 901 end; 887 902 903 function TFillPolyInfo.GetSliceIndex: integer; 904 begin 905 Result:= FCurSlice; 906 end; 907 888 908 { TOnePassFillPolyInfo } 889 909 … … 983 1003 p^.nextDrawing := FFirstDrawing; 984 1004 FFirstDrawing := p; 1005 inc(FSliceIndex); 985 1006 end; 986 1007 end … … 1013 1034 FFirstDrawing:= pnext; 1014 1035 p := pnext; 1036 Inc(FSliceIndex); 1015 1037 continue; 1016 1038 end; … … 1056 1078 1057 1079 SortByY; 1080 FSliceIndex := 0; 1058 1081 end; 1059 1082 … … 1086 1109 1087 1110 setlength(result, NbMaxIntersection); 1111 for i := 0 to high(result) do 1112 result[i] := nil; 1113 end; 1114 1115 function TOnePassFillPolyInfo.GetSliceIndex: integer; 1116 begin 1117 Result:= FSliceIndex; 1088 1118 end; 1089 1119 … … 1154 1184 FRY := abs(ry); 1155 1185 WindingFactor := 1; 1186 FSliceIndex:= -1; 1156 1187 end; 1157 1188 … … 1164 1195 begin 1165 1196 Result:= true; 1197 end; 1198 1199 function TFillEllipseInfo.GetSliceIndex: integer; 1200 begin 1201 Result:= FSliceIndex; 1166 1202 end; 1167 1203 … … 1190 1226 inter[nbinter].SetValues( FX + d, windingFactor, 1); 1191 1227 Inc(nbinter); 1228 FSliceIndex := 0; 1229 end else 1230 begin 1231 if cury < FY then 1232 FSliceIndex:= -1 1233 else 1234 FSliceIndex:= 1; 1192 1235 end; 1193 1236 end; … … 1241 1284 FInnerBorder.Free; 1242 1285 inherited Destroy; 1286 end; 1287 1288 function TFillBorderEllipseInfo.GetSliceIndex: integer; 1289 begin 1290 Result:= FOuterBorder.GetSliceIndex; 1243 1291 end; 1244 1292
Note:
See TracChangeset
for help on using the changeset viewer.