Ignore:
Timestamp:
Apr 24, 2024, 10:28:34 AM (3 weeks ago)
Author:
chronos
Message:
  • Modified: Optimized high DPI scaling. Use lookup table for scaled values. Draw only terrain textures with precise scaling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r547 r552  
    1515  XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
    1616function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer; Src: TBitmap;
    17   XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
     17  XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY; Precise: Boolean = False): Boolean;
    1818function CreateRectRgn(X1, Y1, X2, Y2: Integer): HRGN;
    1919{$IFDEF WINDOWS}
     
    5656
    5757function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer;
    58   Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
     58  Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY;
     59  Precise: Boolean = False): Boolean;
    5960var
    6061  SrcPixel: TPixelPointer;
     
    6566  NewX, NewY: Integer;
    6667begin
    67   if Frac(ScreenInfo.Dpi / 96) = 0 then
    68   begin
     68  if not Precise or (Frac(ScreenInfo.Dpi / 96) = 0) then begin
    6969    // Use faster non-fractional scaling
    7070    Result := BitBlt(Dest.Canvas.Handle, X, Y, Width, Height, Src.Canvas.Handle,
     
    238238function ScaleToNative(Value: Integer): Integer;
    239239begin
    240   // Round function is faster than Ceil and Floor
    241   Result := Round(Value * ScreenInfo.ToNative);
     240  Result := ScreenInfo.Lookup[Value];
     241  // Round and Trunc are fast. Ceil and Floor slow.
     242  // Without lookup table we would use:
     243  // Result := Ceil(Value * ScreenInfo.ToNative);
    242244end;
    243245
     
    249251function ScaleFromNative(Value: Integer): Integer;
    250252begin
    251   Result := Floor(Value * ScreenInfo.FromNative);
     253  Result := Trunc(Value * ScreenInfo.FromNative);
    252254end;
    253255
Note: See TracChangeset for help on using the changeset viewer.