mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
Gtk3: use same technique for R2_NOTXORPEN.
This commit is contained in:
parent
0562c5f1ec
commit
1a62d278d6
@ -232,8 +232,8 @@ type
|
|||||||
procedure ApplyPen;
|
procedure ApplyPen;
|
||||||
procedure FillAndStroke;
|
procedure FillAndStroke;
|
||||||
procedure SetCanvasScaleFactor(const AValue: double);
|
procedure SetCanvasScaleFactor(const AValue: double);
|
||||||
procedure SetXorMode(var xorSurface: Pcairo_surface_t); // SetRasterOp
|
procedure SetXorMode(var xorSurface: Pcairo_surface_t; AMap: Tcairo_operator_t); // SetRasterOp
|
||||||
procedure ApplyXorDrawing(xorSurface: Pcairo_surface_t); // after each paint
|
procedure ApplyXorDrawing(xorSurface: Pcairo_surface_t; AMap: Tcairo_operator_t); // after each paint
|
||||||
protected
|
protected
|
||||||
FCairo: Pcairo_t;
|
FCairo: Pcairo_t;
|
||||||
FXorCairo: PCairo_t;
|
FXorCairo: PCairo_t;
|
||||||
@ -529,7 +529,7 @@ begin
|
|||||||
|
|
||||||
DSTINVERT,
|
DSTINVERT,
|
||||||
R2_NOTXORPEN:
|
R2_NOTXORPEN:
|
||||||
Result := CAIRO_OPERATOR_DIFFERENCE;
|
Result := CAIRO_OPERATOR_XOR; //just for testing CAIRO_OPERATOR_DIFFERENCE;
|
||||||
|
|
||||||
WHITENESS,
|
WHITENESS,
|
||||||
R2_WHITE:
|
R2_WHITE:
|
||||||
@ -1515,10 +1515,10 @@ var
|
|||||||
begin
|
begin
|
||||||
if MapCairoRasterOpToRasterOp(cairo_get_operator(pcr)) = AValue then
|
if MapCairoRasterOpToRasterOp(cairo_get_operator(pcr)) = AValue then
|
||||||
exit;
|
exit;
|
||||||
if (AValue <> R2_XORPEN) and FXorMode then
|
if FXorMode and ((AValue <> R2_XORPEN) and (AValue <> R2_NOTXORPEN)) then
|
||||||
begin
|
begin
|
||||||
FXorMode := False;
|
FXorMode := False;
|
||||||
ApplyXorDrawing(FXorSurface);
|
ApplyXorDrawing(FXorSurface, cairo_get_operator(FXorCairo));
|
||||||
if FXorCairo <> nil then
|
if FXorCairo <> nil then
|
||||||
begin
|
begin
|
||||||
cairo_destroy(FXorCairo);
|
cairo_destroy(FXorCairo);
|
||||||
@ -1546,11 +1546,14 @@ begin
|
|||||||
cairo_surface_destroy(FXorSurface);
|
cairo_surface_destroy(FXorSurface);
|
||||||
FXorSurface := nil;
|
FXorSurface := nil;
|
||||||
end;
|
end;
|
||||||
SetXorMode(FXorSurface);
|
if AValue = R2_NOTXORPEN then
|
||||||
|
AMap := CAIRO_OPERATOR_OVER;
|
||||||
|
SetXorMode(FXorSurface, AMap);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk3DeviceContext.SetXorMode(var xorSurface: Pcairo_surface_t);
|
procedure TGtk3DeviceContext.SetXorMode(var xorSurface: Pcairo_surface_t;
|
||||||
|
AMap: Tcairo_operator_t);
|
||||||
var
|
var
|
||||||
R: TGdkRectangle;
|
R: TGdkRectangle;
|
||||||
begin
|
begin
|
||||||
@ -1561,13 +1564,14 @@ begin
|
|||||||
|
|
||||||
xorSurface := cairo_image_surface_create(CAIRO_FORMAT_ARGB32, R.width, R.height);
|
xorSurface := cairo_image_surface_create(CAIRO_FORMAT_ARGB32, R.width, R.height);
|
||||||
FXorCairo := cairo_create(xorSurface);
|
FXorCairo := cairo_create(xorSurface);
|
||||||
//cairo_set_source_rgba(FXorCairo, 0, 0, 0, 0);
|
cairo_set_source_rgba(FXorCairo, 0, 0, 0, 0);
|
||||||
//cairo_set_operator(FXorCairo, CAIRO_OPERATOR_CLEAR);
|
cairo_set_operator(FXorCairo, CAIRO_OPERATOR_CLEAR);
|
||||||
//cairo_paint(FXorCairo);
|
cairo_paint(FXorCairo);
|
||||||
cairo_set_operator(FXorCairo, CAIRO_OPERATOR_XOR);
|
cairo_set_operator(FXorCairo, AMap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtk3DeviceContext.ApplyXorDrawing(xorSurface: Pcairo_surface_t);
|
procedure TGtk3DeviceContext.ApplyXorDrawing(xorSurface: Pcairo_surface_t;
|
||||||
|
AMap: Tcairo_operator_t);
|
||||||
var
|
var
|
||||||
width, height: Integer;
|
width, height: Integer;
|
||||||
AOperator: Tcairo_operator_t;
|
AOperator: Tcairo_operator_t;
|
||||||
@ -1575,7 +1579,10 @@ begin
|
|||||||
AOperator := cairo_get_operator(FCairo);
|
AOperator := cairo_get_operator(FCairo);
|
||||||
cairo_surface_flush(xorSurface);
|
cairo_surface_flush(xorSurface);
|
||||||
cairo_set_source_surface(FCairo, xorSurface, 0, 0);
|
cairo_set_source_surface(FCairo, xorSurface, 0, 0);
|
||||||
cairo_set_operator(FCairo, CAIRO_OPERATOR_DIFFERENCE);
|
if aMap = CAIRO_OPERATOR_XOR then
|
||||||
|
cairo_set_operator(FCairo, CAIRO_OPERATOR_DIFFERENCE)
|
||||||
|
else
|
||||||
|
cairo_set_operator(FCairo, CAIRO_OPERATOR_OVER);
|
||||||
cairo_paint(FCairo);
|
cairo_paint(FCairo);
|
||||||
cairo_set_operator(FCairo, AOperator);
|
cairo_set_operator(FCairo, AOperator);
|
||||||
end;
|
end;
|
||||||
@ -1649,7 +1656,6 @@ var
|
|||||||
begin
|
begin
|
||||||
SetSourceColor(FCurrentPen.Color);
|
SetSourceColor(FCurrentPen.Color);
|
||||||
(*
|
(*
|
||||||
//something is wrong with this. XOR does not work, so we setup stuff in SetRasterOp()
|
|
||||||
case FCurrentPen.Mode of
|
case FCurrentPen.Mode of
|
||||||
pmBlack: begin
|
pmBlack: begin
|
||||||
SetSourceColor(clBlack);
|
SetSourceColor(clBlack);
|
||||||
@ -1661,7 +1667,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
pmCopy: cairo_set_operator(pcr, CAIRO_OPERATOR_OVER);
|
pmCopy: cairo_set_operator(pcr, CAIRO_OPERATOR_OVER);
|
||||||
pmXor: cairo_set_operator(pcr, CAIRO_OPERATOR_XOR);
|
pmXor: cairo_set_operator(pcr, CAIRO_OPERATOR_XOR);
|
||||||
pmNotXor: cairo_set_operator(pcr, CAIRO_OPERATOR_XOR);
|
pmNotXor: cairo_set_operator(pcr, CAIRO_OPERATOR_DIFFERENCE);
|
||||||
{pmNop,
|
{pmNop,
|
||||||
pmNot,
|
pmNot,
|
||||||
pmCopy,
|
pmCopy,
|
||||||
@ -1718,6 +1724,7 @@ begin
|
|||||||
pjsBevel: cairo_set_line_join(pcr, CAIRO_LINE_JOIN_BEVEL);
|
pjsBevel: cairo_set_line_join(pcr, CAIRO_LINE_JOIN_BEVEL);
|
||||||
pjsMiter: cairo_set_line_join(pcr, CAIRO_LINE_JOIN_MITER);
|
pjsMiter: cairo_set_line_join(pcr, CAIRO_LINE_JOIN_MITER);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TGtk3DeviceContext.Create(AWidget: PGtkWidget;
|
constructor TGtk3DeviceContext.Create(AWidget: PGtkWidget;
|
||||||
|
Loading…
Reference in New Issue
Block a user