LCL-GTK3: Improve canvas artifacts, swapped RGB colors etc. Issue #36374, patch from Anton Kavalenka + Alexey Tor.

git-svn-id: trunk@62356 -
This commit is contained in:
juha 2019-12-08 19:45:58 +00:00
parent 4213fd0677
commit ffa116207f
2 changed files with 33 additions and 14 deletions

View File

@ -1329,17 +1329,15 @@ procedure TGtk3DeviceContext.drawRect(x1: Integer; y1: Integer; w: Integer;
begin
cairo_save(Widget);
try
applyPen;
// strange about adding +1 -1 to rectangle, but this works ok.
//cairo_rectangle(Widget, x1 + 1, y1 + 1, w - 1, h -1);
ApplyPen;
cairo_rectangle(Widget, x1, y1, w, h);
cairo_stroke(Widget);
if AFill then
begin
cairo_stroke_preserve(Widget);
applyBrush;
cairo_fill_preserve(Widget);
end else
cairo_stroke(Widget);
cairo_rectangle(Widget, x1, y1, w - 1, h - 1);
ApplyBrush;
cairo_fill(Widget);
end;
finally
cairo_restore(Widget);
end;
@ -1422,8 +1420,29 @@ end;
procedure TGtk3DeviceContext.drawEllipse(x: Integer; y: Integer; w: Integer;
h: Integer);
var
save_matrix:cairo_matrix_t;
begin
cairo_save(Widget);
cairo_get_matrix(Widget, @save_matrix);
cairo_translate (Widget, x + w / 2.0, y + h / 2.0);
cairo_scale (Widget, w / 2.0, h / 2.0);
cairo_new_path(Widget);
cairo_arc
(
(*cr =*) Widget,
(*xc =*) 0,
(*yc =*) 0,
(*radius =*) 1,
(*angle1 =*) 0,
(*angle2 =*) 2 * Pi
);
cairo_close_path(Widget);
ApplyBrush;
cairo_fill_preserve(Widget);
cairo_restore(Widget);
ApplyPen;
cairo_stroke(Widget);
end;
procedure TGtk3DeviceContext.drawSurface(targetRect: PRect;

View File

@ -1053,10 +1053,8 @@ end;
function TGtk3WidgetSet.Ellipse(DC: HDC; x1, y1, x2, y2: Integer): Boolean;
begin
{$IFDEF GTK3DEBUGNOTIMPLEMENTED}
DebugLn('WARNING: TGtk3WidgetSet.Ellipse not implemented ...');
{$ENDIF}
Result:=inherited Ellipse(DC, x1, y1, x2, y2);
TGtk3DeviceContext(DC).drawEllipse(x1,y1,x2-x1,y2-y1);
Result:=true;
end;
function TGtk3WidgetSet.EnableScrollBar(Wnd: HWND; wSBflags, wArrows: Cardinal
@ -3265,7 +3263,9 @@ begin
R := NormalizeRect(Rect(X1, Y1, X2, Y2));
if IsRectEmpty(R) then Exit(True);
with R do
TGtk3DeviceContext(DC).drawRect(Left, Top, Right - Left, Bottom - Top, false);
TGtk3DeviceContext(DC).drawRect(Left, Top, Right - Left, Bottom - Top,
TGtk3DeviceContext(DC).CurrentBrush.Style<>BS_NULL{bsClear}
);
Result := True;
end;