LCL: changed SetDeviceScaleRatio HGDIOBJ param to HDC to be inline with cocoa abilities.

This commit is contained in:
zeljan1 2025-01-02 12:08:47 +01:00
parent 8ec63ba013
commit 4510285762
8 changed files with 22 additions and 16 deletions

View File

@ -3429,7 +3429,7 @@ begin
AScale := Application.MainForm.GetCanvasScaleFactor;
PaintBufferBitmap.Width := Round(FClientRect.Right * AScale);
PaintBufferBitmap.Height := Round(FClientRect.Bottom * AScale);
LCLIntf.SetDeviceScaleRatio(PaintBufferBitmap.Handle, AScale);
LCLIntf.SetDeviceScaleRatio(PaintBufferBitmap.Canvas.Handle, AScale);
PaintBuffer := PaintBufferBitmap.Canvas;
end;
FTarget := PaintBuffer;

View File

@ -643,8 +643,8 @@ end;
//This routine is used only by platforms which uses Scale instead of font DPI changes (or both).
//Currently cocoa, qt5, qt6 and gtk3 are known to support this. Without proper scale ratio
//setup, bitmap text rendering is blurred.See iphtml.pas, procedure TIpHtml.Render() how
//we use it.Param aObj is TQtImage under qt5 and qt6, under cocoa it's TBitmapContext.
procedure TWidgetSet.SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double);
//we use it.Param DC is device context with selected bitmap/image into.
procedure TWidgetSet.SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double);
begin
end;

View File

@ -423,9 +423,9 @@ procedure SendCachedLCLMessages;
begin
end;
procedure SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double);
procedure SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double);
begin
WidgetSet.SetDeviceScaleRatio(aObj, AScaleRatio);
WidgetSet.SetDeviceScaleRatio(DC, AScaleRatio);
end;
function SetCaretRespondToFocus(Handle: hWnd; ShowHideOnFocus: boolean):Boolean;

View File

@ -109,7 +109,7 @@ procedure RemovePipeEventHandler(var AHandler: PPipeEventHandler); {$IFDEF IF_BA
function RequestInput(const InputCaption, InputPrompt : String; MaskInput : Boolean; var Value : String) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure SendCachedLCLMessages; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetCaretRespondToFocus(handle: HWND; ShowHideOnFocus: boolean): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetComboMinDropDownSize(Handle: HWND; MinItemsWidth, MinItemsHeight, MinItemCount: integer): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure SetEventHandlerFlags(AHandler: PEventHandler; NewFlags: dword); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}

View File

@ -868,12 +868,15 @@ begin
// todo
end;
procedure TQtWidgetSet.SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double);
procedure TQtWidgetSet.SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double);
var
QtDc: TQtDeviceContext absolute DC;
begin
if aObj <> 0 then
if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then
begin
if TObject(aObj) is TQtImage then
QImage_setDevicePixelRatio(TQtImage(aObj).Handle, AScaleRatio);
QPainter_end(QtDC.Widget);
QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleRatio);
QPainter_begin(QtDC.Widget, QtDC.vImage.Handle);
end;
end;

View File

@ -73,7 +73,7 @@ procedure RemovePipeEventHandler(var AHandler: PPipeEventHandler); override;
procedure RemoveProcessEventHandler(var AHandler: PProcessEventHandler); override;
procedure SetEventHandlerFlags(AHandler: PEventHandler; NewFlags: dword); override;
procedure SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double); override;
procedure SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double); override;
function SetComboMinDropDownSize(Handle: HWND; MinItemsWidth, MinItemsHeight, MinItemCount: integer): boolean; override;
procedure SetRubberBandRect(const ARubberBand: HWND; const ARect: TRect); override;

View File

@ -887,12 +887,15 @@ begin
// todo
end;
procedure TQtWidgetSet.SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double);
procedure TQtWidgetSet.SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double);
var
QtDc: TQtDeviceContext absolute DC;
begin
if IsValidGDIObject(aObj) then
if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then
begin
if TObject(aObj) is TQtImage then
QImage_setDevicePixelRatio(TQtImage(aObj).Handle, AScaleRatio);
QPainter_end(QtDC.Widget);
QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleRatio);
QPainter_begin(QtDC.Widget, QtDC.vImage.Handle);
end;
end;

View File

@ -73,7 +73,7 @@ procedure RemovePipeEventHandler(var AHandler: PPipeEventHandler); override;
procedure RemoveProcessEventHandler(var AHandler: PProcessEventHandler); override;
procedure SetEventHandlerFlags(AHandler: PEventHandler; NewFlags: dword); override;
procedure SetDeviceScaleRatio(aObj: HGDIOBJ; const AScaleRatio: double); override;
procedure SetDeviceScaleRatio(DC: HDC; const AScaleRatio: double); override;
function SetComboMinDropDownSize(Handle: HWND; MinItemsWidth, MinItemsHeight, MinItemCount: integer): boolean; override;
procedure SetRubberBandRect(const ARubberBand: HWND; const ARect: TRect); override;