Changeset 518


Ignore:
Timestamp:
Jan 6, 2024, 12:07:04 AM (12 months ago)
Author:
chronos
Message:
  • Fixed: Make fractional scaling work also on Windows.
  • Modified: By default use system DPI setting.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Select.pas

    r508 r518  
    16751675
    16761676  Kind := ListKind;
    1677   ModalIndication := not(Kind in MustChooseKind);
     1677  ModalIndication := not (Kind in MustChooseKind);
    16781678  case Kind of
    16791679    kProject:
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r515 r518  
    892892begin
    893893  {$IFDEF WINDOWS}
    894   // LCLIntf.BitBlt is slower than direct Windows BitBlt
    895   Result := Windows.BitBlt(DestCanvas.Handle, ScaleToNative(X), ScaleToNative(Y),
    896     ScaleToNative(Width), ScaleToNative(Height), SrcCanvas.Handle,
    897     ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     894    {$IFDEF DPI}
     895    Result := BitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
     896    {$ELSE}
     897    // LCLIntf.BitBlt is slower than direct Windows BitBlt
     898    Result := Windows.BitBlt(DestCanvas.Handle, ScaleToNative(X), ScaleToNative(Y),
     899      ScaleToNative(Width), ScaleToNative(Height), SrcCanvas.Handle,
     900      ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     901    {$ENDIF}
    898902  {$ELSE}
    899903  Result := BitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
     
    17881792    {$IFDEF DPI}
    17891793    if CustomDpiEnabled then Screen.Dpi := CustomDpi
    1790       else Screen.Dpi := 96; //Screen.GetSystemDpi;
     1794      else Screen.Dpi := Screen.GetSystemDpi;
    17911795    {$ENDIF}
    17921796  finally
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r516 r518  
    186186  SrcWidth, SrcHeight: Integer;
    187187begin
    188   {$IFDEF WINDOWS}
    189   // LCLIntf.BitBlt is slower than direct Windows BitBlt
    190   Result := Windows.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    191     ScaleToNative(Width), ScaleToNative(Height), SrcDC,
    192     ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
    193   {$ELSE}
    194 
    195188  DstWidth := ScaleToNativeDist(X, Width);
    196189  DstHeight := ScaleToNativeDist(Y, Height);
    197190  SrcWidth := ScaleToNativeDist(XSrc, Width);
    198191  SrcHeight := ScaleToNativeDist(YSrc, Height);
     192
    199193  if (DstWidth = SrcWidth) and (DstHeight = SrcHeight) then begin
     194    {$IFDEF WINDOWS}
     195    // On Windows LCLIntf.BitBlt is slower than direct Windows BitBlt
     196    Result := Windows.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
     197      DstWidth, DstHeight, SrcDC,
     198      ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     199    {$ELSE}
    200200    Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    201201      DstWidth, DstHeight, SrcDC,
    202202      ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     203    {$ENDIF}
    203204  end else begin
     205    {$IFDEF WINDOWS}
     206    // On Windows LCLIntf.BitBlt is slower than direct Windows BitBlt
     207    Result := Windows.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
     208      Min(SrcWidth, DstWidth), Min(DstHeight, SrcHeight), SrcDC,
     209      ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     210
     211    // Instead calling StretchBlt for entire region try to draw missing part with BitBlt
     212    if DstWidth > SrcWidth then begin
     213      Windows.BitBlt(DestDC, ScaleToNative(X) + SrcWidth, ScaleToNative(Y),
     214        DstWidth - SrcWidth, DstHeight, SrcDC,
     215        ScaleToNative(XSrc) + SrcWidth - (DstWidth - SrcWidth), ScaleToNative(YSrc), Rop);
     216    end;
     217    if DstHeight > SrcHeight then begin
     218      Windows.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y) + SrcHeight,
     219        DstWidth, DstHeight - SrcHeight, SrcDC,
     220        ScaleToNative(XSrc), ScaleToNative(YSrc) + SrcHeight - (DstHeight - SrcHeight), Rop);
     221    end;
     222    {$ELSE}
    204223    Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    205       SrcWidth, SrcHeight, SrcDC,
     224      Min(SrcWidth, DstWidth), Min(DstHeight, SrcHeight), SrcDC,
    206225      ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
    207226
     
    217236        ScaleToNative(XSrc), ScaleToNative(YSrc) + SrcHeight - (DstHeight - SrcHeight), Rop);
    218237    end;
    219   {  Result := LCLIntf.StretchBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    220       DstWidth, DstHeight, SrcDC,
    221       ScaleToNative(XSrc), ScaleToNative(YSrc),
    222       SrcWidth, SrcHeight, Rop);}
     238    {$ENDIF}
    223239  end;
    224 
    225 {  Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    226     ScaleToNative(Width), ScaleToNative(Height), SrcDC,
    227     ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
    228  }
    229   {$ENDIF}
    230240end;
    231241
Note: See TracChangeset for help on using the changeset viewer.