Ignore:
Timestamp:
Dec 22, 2016, 8:49:19 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Updated BGRABitmap package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/bgrafillinfo.pas

    r472 r494  
    3737      function GetBounds: TRect; override;
    3838
    39       //compute min-max to be drawn on destination bitmap according to cliprect. Returns false if
    40       //there is nothing to draw
    41       function ComputeMinMax(out minx,miny,maxx,maxy: integer; bmpDest: TBGRACustomBitmap): boolean; override;
    42 
    4339      //check if the point is inside the filling zone
    4440      function IsPointInside(x,y: single; windingMode: boolean): boolean; override;
     
    5450      procedure ComputeAndSort(cury: single; var inter: ArrayOfTIntersectionInfo; out nbInter: integer; windingMode: boolean); override;
    5551
     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
    5656  end;
    5757
     
    6161  private
    6262    FX, FY, FRX, FRY: single;
     63    FSliceIndex: integer;
    6364    function GetCenter: TPointF;
    6465  protected
     
    7172    function GetBounds: TRect; override;
    7273    function SegmentsCurved: boolean; override;
     74    function GetSliceIndex: integer; override;
    7375    property Center: TPointF read GetCenter;
    7476    property RadiusX: single read FRX;
     
    9092    function SegmentsCurved: boolean; override;
    9193    destructor Destroy; override;
     94    function GetSliceIndex: integer; override;
    9295    property InnerBorder: TFillEllipseInfo read FInnerBorder;
    9396    property OuterBorder: TFillEllipseInfo read FOuterBorder;
     
    179182    constructor Create(const points: array of TPointF);
    180183    destructor Destroy; override;
     184    function GetSliceIndex: integer; override;
    181185  end;
    182186
     
    208212    FFirstWaiting, FFirstDrawing: POnePassRecord;
    209213    FShouldInitializeDrawing: boolean;
     214    FSliceIndex: integer;
    210215    procedure ComputeIntersection(cury: single;
    211216      var inter: ArrayOfTIntersectionInfo; var nbInter: integer); override;
     
    213218    constructor Create(const points: array of TPointF);
    214219    function CreateIntersectionArray: ArrayOfTIntersectionInfo; override;
     220    function GetSliceIndex: integer; override;
    215221    destructor Destroy; override;
    216222  end;
     
    243249function IsPointInRectangle(x1, y1, x2, y2: single; point: TPointF): boolean;
    244250
     251function BGRAShapeComputeMinMax(AShape: TBGRACustomFillInfo; out minx, miny, maxx, maxy: integer;
     252  bmpDest: TBGRACustomBitmap): boolean;
     253
    245254implementation
    246255
    247256uses Math;
     257
     258function BGRAShapeComputeMinMax(AShape: TBGRACustomFillInfo; out minx, miny, maxx, maxy: integer;
     259  bmpDest: TBGRACustomBitmap): boolean;
     260var clip,bounds: TRect;
     261begin
     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;
     297end;
    248298
    249299procedure ComputeAliasedRowBounds(x1,x2: single; minx,maxx: integer; out ix1,ix2: integer);
     
    345395end;
    346396
    347 function TFillShapeInfo.ComputeMinMax(out minx, miny, maxx, maxy: integer;
    348   bmpDest: TBGRACustomBitmap): boolean;
    349 var clip,bounds: TRect;
    350 begin
    351   result := true;
    352   bounds := GetBounds;
    353 
    354   if (bounds.Right <= bounds.left) or (bounds.bottom <= bounds.top) then
    355   begin
    356     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 then
    368     minx := clip.Left;
    369   if maxx < clip.Left then
    370     result := false;
    371 
    372   if maxx > clip.Right - 1 then
    373     maxx := clip.Right- 1;
    374   if minx > clip.Right - 1 then
    375     result := false;
    376 
    377   if miny < clip.Top then
    378     miny := clip.Top;
    379   if maxy < clip.Top then
    380     result := false;
    381 
    382   if maxy > clip.Bottom - 1 then
    383     maxy := clip.Bottom - 1;
    384   if miny > clip.Bottom - 1 then
    385     result := false;
    386 end;
    387397
    388398function TFillShapeInfo.IsPointInside(x, y: single; windingMode: boolean
     
    489499  SortIntersection(inter,nbInter);
    490500  if windingMode then ConvertFromNonZeroWinding(inter,nbInter);
     501end;
     502
     503function TFillShapeInfo.GetSliceIndex: integer;
     504begin
     505  result := 0;
    491506end;
    492507
     
    886901end;
    887902
     903function TFillPolyInfo.GetSliceIndex: integer;
     904begin
     905  Result:= FCurSlice;
     906end;
     907
    888908{ TOnePassFillPolyInfo }
    889909
     
    9831003        p^.nextDrawing := FFirstDrawing;
    9841004        FFirstDrawing := p;
     1005        inc(FSliceIndex);
    9851006      end;
    9861007    end
     
    10131034        FFirstDrawing:= pnext;
    10141035      p := pnext;
     1036      Inc(FSliceIndex);
    10151037      continue;
    10161038    end;
     
    10561078
    10571079  SortByY;
     1080  FSliceIndex := 0;
    10581081end;
    10591082
     
    10861109
    10871110  setlength(result, NbMaxIntersection);
     1111  for i := 0 to high(result) do
     1112    result[i] := nil;
     1113end;
     1114
     1115function TOnePassFillPolyInfo.GetSliceIndex: integer;
     1116begin
     1117  Result:= FSliceIndex;
    10881118end;
    10891119
     
    11541184  FRY := abs(ry);
    11551185  WindingFactor := 1;
     1186  FSliceIndex:= -1;
    11561187end;
    11571188
     
    11641195begin
    11651196  Result:= true;
     1197end;
     1198
     1199function TFillEllipseInfo.GetSliceIndex: integer;
     1200begin
     1201  Result:= FSliceIndex;
    11661202end;
    11671203
     
    11901226    inter[nbinter].SetValues( FX + d, windingFactor, 1);
    11911227    Inc(nbinter);
     1228    FSliceIndex := 0;
     1229  end else
     1230  begin
     1231    if cury < FY then
     1232      FSliceIndex:= -1
     1233    else
     1234      FSliceIndex:= 1;
    11921235  end;
    11931236end;
     
    12411284    FInnerBorder.Free;
    12421285  inherited Destroy;
     1286end;
     1287
     1288function TFillBorderEllipseInfo.GetSliceIndex: integer;
     1289begin
     1290  Result:= FOuterBorder.GetSliceIndex;
    12431291end;
    12441292
Note: See TracChangeset for help on using the changeset viewer.