Changeset 522 for GraphicTest/Packages/Graphics32/GR32_Rasterizers.pas
- Timestamp:
- Apr 17, 2019, 10:42:18 AM (5 years ago)
- Location:
- GraphicTest/Packages/Graphics32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/Graphics32
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
GraphicTest/Packages/Graphics32/GR32_Rasterizers.pas
r450 r522 47 47 Windows, 48 48 {$ENDIF} 49 Classes, GR32, GR32_Blend , GR32_OrdinalMaps;49 Classes, GR32, GR32_Blend; 50 50 51 51 type … … 184 184 185 185 uses 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; 187 188 188 189 type 189 T ThreadPersistentAccess = class(TThreadPersistent);190 TCustomBitmap32Access = class(TCustomBitmap32); 190 191 191 192 TLineRasterizerData = record … … 292 293 R: TRect; 293 294 begin 294 UpdateCount := T ThreadPersistentAccess(Dst).UpdateCount;295 UpdateCount := TCustomBitmap32Access(Dst).UpdateCount; 295 296 if Assigned(FSampler) then 296 297 begin … … 302 303 DoRasterize(Dst, R); 303 304 finally 304 while T ThreadPersistentAccess(Dst).UpdateCount > UpdateCount do305 T ThreadPersistentAccess(Dst).EndUpdate;305 while TCustomBitmap32Access(Dst).UpdateCount > UpdateCount do 306 TCustomBitmap32Access(Dst).EndUpdate; 306 307 FSampler.FinalizeSampling; 307 308 end; … … 430 431 Size := NextPowerOf2(Max(W, H)); 431 432 432 SetLength(ForwardBuffer, Size );433 SetLength(ForwardBuffer, Size + 1); 433 434 434 435 I := 2; 435 while I < Size do436 while I <= Size do 436 437 begin 437 438 ForwardBuffer[I] := ForwardBuffer[I shr 1] + 1; … … 452 453 P2.X := L + P1.X; 453 454 P2.Y := T + P1.Y; 455 454 456 AssignColor(Dst.Bits[P2.X + P2.Y * RowSize], GetSample(P2.X, P2.Y)); 455 457 … … 482 484 FUpdateRows := True; 483 485 end; 486 487 {$DEFINE UseInternalFill} 484 488 485 489 procedure TProgressiveRasterizer.DoRasterize(Dst: TCustomBitmap32; … … 491 495 Step: Integer; 492 496 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 501 procedure IntFillRect(X1, Y1, X2, Y2: Integer; C: TColor32); 502 var 503 Y: Integer; 504 P: PColor32Array; 505 begin 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; 511 end; 512 {$ENDIF} 513 514 begin 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 530 573 begin 531 574 X := DstRect.Left + I shl Shift; 575 {$IFDEF UseInternalFill} 576 IntFillRect(X, Y, X + Step, B, GetSample(X, Y)); 577 {$ELSE} 532 578 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; 548 592 end; 549 593
Note:
See TracChangeset
for help on using the changeset viewer.