Ignore:
Timestamp:
Apr 17, 2019, 10:42:18 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated Graphics32 library.
Location:
GraphicTest/Packages/Graphics32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/Graphics32

    • Property svn:ignore set to
      lib
  • GraphicTest/Packages/Graphics32/GR32_Rasterizers.pas

    r450 r522  
    4747  Windows,
    4848{$ENDIF}
    49   Classes, GR32, GR32_Blend, GR32_OrdinalMaps;
     49  Classes, GR32, GR32_Blend;
    5050
    5151type
     
    184184
    185185uses
    186   GR32_Resamplers, GR32_Containers, GR32_System, Math, GR32_Math, SysUtils;
     186  Math, SysUtils, GR32_Math, GR32_System, GR32_LowLevel, GR32_Resamplers,
     187  GR32_Containers, GR32_OrdinalMaps;
    187188
    188189type
    189   TThreadPersistentAccess = class(TThreadPersistent);
     190  TCustomBitmap32Access = class(TCustomBitmap32);
    190191
    191192  TLineRasterizerData = record
     
    292293  R: TRect;
    293294begin
    294   UpdateCount := TThreadPersistentAccess(Dst).UpdateCount;
     295  UpdateCount := TCustomBitmap32Access(Dst).UpdateCount;
    295296  if Assigned(FSampler) then
    296297  begin
     
    302303      DoRasterize(Dst, R);
    303304    finally
    304       while TThreadPersistentAccess(Dst).UpdateCount > UpdateCount do
    305         TThreadPersistentAccess(Dst).EndUpdate;
     305      while TCustomBitmap32Access(Dst).UpdateCount > UpdateCount do
     306        TCustomBitmap32Access(Dst).EndUpdate;
    306307      FSampler.FinalizeSampling;
    307308    end;
     
    430431  Size := NextPowerOf2(Max(W, H));
    431432
    432   SetLength(ForwardBuffer, Size);
     433  SetLength(ForwardBuffer, Size + 1);
    433434
    434435  I := 2;
    435   while I < Size do
     436  while I <= Size do
    436437  begin
    437438    ForwardBuffer[I] := ForwardBuffer[I shr 1] + 1;
     
    452453    P2.X := L + P1.X;
    453454    P2.Y := T + P1.Y;
     455
    454456    AssignColor(Dst.Bits[P2.X + P2.Y * RowSize], GetSample(P2.X, P2.Y));
    455457
     
    482484  FUpdateRows := True;
    483485end;
     486
     487{$DEFINE UseInternalFill}
    484488
    485489procedure TProgressiveRasterizer.DoRasterize(Dst: TCustomBitmap32;
     
    491495  Step: Integer;
    492496  GetSample: TGetSampleInt;
    493 begin
    494     GetSample := FSampler.GetSampleInt;
    495     OnChanged := Dst.OnAreaChanged;
    496     DoUpdate := (TThreadPersistentAccess(Dst).UpdateCount = 0) and Assigned(OnChanged);
    497     W := DstRect.Right - DstRect.Left;
    498     H := DstRect.Bottom - DstRect.Top;
    499     J := DstRect.Top;
    500     Step := 1 shl FSteps;
    501     while J < DstRect.Bottom do
    502     begin
    503       I := DstRect.Left;
    504       B := Min(J + Step, DstRect.Bottom);
    505       while I < DstRect.Right - Step do
    506       begin
    507         Dst.FillRect(I, J, I + Step, B, GetSample(I, J));
    508         Inc(I, Step);
    509       end;
    510       Dst.FillRect(I, J, DstRect.Right, B, GetSample(I, J));
    511       if DoUpdate and FUpdateRows then
    512         OnChanged(Dst, Rect(DstRect.Left, J, DstRect.Right, B), AREAINFO_RECT);
    513       Inc(J, Step);
    514     end;
    515     if DoUpdate and (not FUpdateRows) then OnChanged(Dst, DstRect, AREAINFO_RECT);
    516 
    517     Shift := FSteps;
    518     while Step > 1 do
    519     begin
    520       Dec(Shift);
    521       Step := Step div 2;
    522       Wk := W div Step - 1;
    523       Hk := H div Step;
    524       for J := 0 to Hk do
    525       begin
    526         Y := DstRect.Top + J shl Shift;
    527         B := Min(Y + Step, DstRect.Bottom);
    528         if Odd(J) then
    529           for I := 0 to Wk do
     497
     498{$IFDEF UseInternalFill}
     499  Bits: PColor32Array;
     500
     501procedure IntFillRect(X1, Y1, X2, Y2: Integer; C: TColor32);
     502var
     503  Y: Integer;
     504  P: PColor32Array;
     505begin
     506  for Y := Y1 to Y2 - 1 do
     507  begin
     508    P := Pointer(@Bits[Y * W]);
     509    FillLongword(P[X1], X2 - X1, C);
     510  end;
     511end;
     512{$ENDIF}
     513
     514begin
     515  GetSample := FSampler.GetSampleInt;
     516  OnChanged := Dst.OnAreaChanged;
     517{$IFDEF UseInternalFill}
     518  Bits := Dst.Bits;
     519{$ENDIF}
     520  DoUpdate := (TCustomBitmap32Access(Dst).UpdateCount = 0) and Assigned(OnChanged);
     521  W := DstRect.Right - DstRect.Left;
     522  H := DstRect.Bottom - DstRect.Top;
     523  J := DstRect.Top;
     524  Step := 1 shl FSteps;
     525  while J < DstRect.Bottom do
     526  begin
     527    I := DstRect.Left;
     528    B := Min(J + Step, DstRect.Bottom);
     529    while I < DstRect.Right - Step do
     530    begin
     531      {$IFDEF UseInternalFill}
     532      IntFillRect(I, J, I + Step, B, GetSample(I, J));
     533      {$ELSE}
     534      Dst.FillRect(I, J, I + Step, B, GetSample(I, J));
     535      {$ENDIF}
     536      Inc(I, Step);
     537    end;
     538    {$IFDEF UseInternalFill}
     539    IntFillRect(I, J, DstRect.Right, B, GetSample(I, J));
     540    if DoUpdate and FUpdateRows then
     541      OnChanged(Dst, Rect(DstRect.Left, J, DstRect.Right, B), AREAINFO_RECT);
     542    {$ELSE}
     543    Dst.FillRect(I, J, DstRect.Right, B, GetSample(I, J));
     544    {$ENDIF}
     545    Inc(J, Step);
     546  end;
     547  if DoUpdate and (not FUpdateRows) then OnChanged(Dst, DstRect, AREAINFO_RECT);
     548
     549  Shift := FSteps;
     550  while Step > 1 do
     551  begin
     552    Dec(Shift);
     553    Step := Step div 2;
     554    Wk := W div Step - 1;
     555    Hk := H div Step;
     556    for J := 0 to Hk do
     557    begin
     558      Y := DstRect.Top + J shl Shift;
     559      B := Min(Y + Step, DstRect.Bottom);
     560      if Odd(J) then
     561        for I := 0 to Wk do
     562        begin
     563          X := DstRect.Left + I shl Shift;
     564          {$IFDEF UseInternalFill}
     565          IntFillRect(X, Y, X + Step, B, GetSample(X, Y));
     566          {$ELSE}
     567          Dst.FillRect(X, Y, X + Step, B, GetSample(X, Y));
     568          {$ENDIF}
     569        end
     570      else
     571        for I := 0 to Wk do
     572          if Odd(I) then
    530573          begin
    531574            X := DstRect.Left + I shl Shift;
     575            {$IFDEF UseInternalFill}
     576            IntFillRect(X, Y, X + Step, B, GetSample(X, Y));
     577            {$ELSE}
    532578            Dst.FillRect(X, Y, X + Step, B, GetSample(X, Y));
    533           end
    534         else
    535           for I := 0 to Wk do
    536             if Odd(I) then
    537             begin
    538               X := DstRect.Left + I shl Shift;
    539               Dst.FillRect(X, Y, X + Step, B, GetSample(X, Y));
    540             end;
    541         X := DstRect.Left + Wk shl Shift;
    542         Dst.FillRect(X, Y, DstRect.Right, B, GetSample(X, Y));
    543         if FUpdateRows and DoUpdate then
    544           OnChanged(Dst, Rect(DstRect.Left, Y, DstRect.Right, B), AREAINFO_RECT);
    545       end;
    546       if DoUpdate and (not FUpdateRows) then OnChanged(Dst, DstRect, AREAINFO_RECT);
    547     end;
     579            {$ENDIF}
     580          end;
     581      X := DstRect.Left + Wk shl Shift;
     582      {$IFDEF UseInternalFill}
     583      IntFillRect(X, Y, DstRect.Right, B, GetSample(X, Y));
     584      if FUpdateRows and DoUpdate then
     585        OnChanged(Dst, Rect(DstRect.Left, Y, DstRect.Right, B), AREAINFO_RECT);
     586      {$ELSE}
     587      Dst.FillRect(X, Y, DstRect.Right, B, GetSample(X, Y));
     588      {$ENDIF}
     589    end;
     590    if DoUpdate and (not FUpdateRows) then OnChanged(Dst, DstRect, AREAINFO_RECT);
     591  end;
    548592end;
    549593
Note: See TracChangeset for help on using the changeset viewer.