Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333391

Summary: Remove the @deprecated tag from GC#setXORMode()
Product: [Eclipse Project] Platform Reporter: Scott Kovatch <skovatch>
Component: SWTAssignee: Eric Williams <ericwill>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andre.saibel, arunkumar.thondapu, eclipse.felipe, ericwill, gheorghe, nyssen, pwebster, Silenio_Quarti
Version: 3.7Keywords: triaged
Target Milestone: 4.14 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/152338
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=1af84db9d9097f2c1d4b3b33cc3dc258334486cb
Whiteboard:

Description Scott Kovatch CLA 2011-01-02 16:30:13 EST
I recently fixed Cocoa so it uses kCGBlendModeDifference for XOR drawing, just like Carbon does, and with the same results as Win32. Given that, I think we should remove the @deprecated tag, as it is no longer correct. 

This assumes, of course, that other platforms handle setXORMode properly, but the comment implies that Mac OS X was the only platform with an issue.
Comment 1 Silenio Quarti CLA 2011-01-04 14:53:10 EST
GTK/Motif when in advanced mode (running cairo) does not support XOR mode either. We would have to determine if cairo has added API for this. I had a quick look and it seems cairo_set_operator() with CAIRO_OPERATOR_XOR should do what we want, but we have to test.

http://cairographics.org/manual/cairo-cairo-t.html#cairo-set-operator
Comment 2 Scott Kovatch CLA 2011-01-04 15:01:08 EST
The description of CAIRO_OPERATOR_XOR at http://cairographics.org/operators/ looks correct. They also have CAIRO_OPERATOR_DIFFERENCE, but there's no docs on what it does. Presumably it's the same as Carbon/Cocoa.
Comment 3 Scott Kovatch CLA 2011-02-02 18:19:12 EST
*** Bug 336167 has been marked as a duplicate of this bug. ***
Comment 4 Andre Saibel CLA 2012-06-20 04:15:15 EDT
No messages for one and a half years ... what is the state of affairs?
Comment 5 Arun Thondapu CLA 2012-06-20 07:52:43 EDT
As far as I understand, we still do not have support for XOR mode on Linux with Cairo because the CAIRO_OPERATOR_XOR referred to in comment 1 does not provide a bit-wise XOR functionality.

Bogdan/Silenio, can you please confirm?

Thanks!
Comment 6 Silenio Quarti CLA 2012-06-21 17:45:16 EDT
I think we implement XOR on linux not to long ago, but it only works with gtk 2.4.
Comment 7 Andre Saibel CLA 2012-08-06 08:57:43 EDT
I'm not sure if CAIRO_OPERATOR_DIFFERENCE is the right operator – is CAIRO_OPERATOR_XOR not the appropriate one?
Does the topic only affect the cairo "path" of SWT on Linux
Comment 8 Silenio Quarti CLA 2012-08-08 22:18:16 EDT
(In reply to comment #7)
> I'm not sure if CAIRO_OPERATOR_DIFFERENCE is the right operator – is
> CAIRO_OPERATOR_XOR not the appropriate one?
> Does the topic only affect the cairo "path" of SWT on Linux

I confirmed that we have implemented GC.setXORMode() on GTK. The implementation only works with cairo >= 1.10.

I believe CAIRO_OPERATOR_DIFFERENCE is the right operator. We use kCGBlendModeDifference on cocoa.

It should affect fillRectangle, fillArc, fillPath, drawRectangle, drawArc, etc, drawImage as well.

This snippet works for me:


import org.eclipse.swt.SWT;
/* 
 * example snippet: Hello World
 *
 * For a list of all SWT example snippets see
 * http://www.eclipse.org/swt/snippets/
 */
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;

public class Snippet1 {

public static void main (String [] args) {
	final Display display = new Display ();
	Shell shell = new Shell(display);
	shell.addListener(SWT.Paint, new Listener() {
		public void handleEvent(Event event) {
				GC gc = event.gc;
				gc.setAdvanced(true);
				System.out.println(gc.getAdvanced());
				gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
				gc.fillRectangle(10, 10, 200, 200);
				gc.setXORMode(true);
				gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
				gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
				Image image = new Image(display, 100, 100);
				GC gc2 = new GC(image);
				gc2.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
				gc2.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
				gc2.fillRectangle(0 ,0, 100, 100);
				gc2.dispose();
//				gc.drawImage(image, 20, 20);
				image.dispose();
//				gc.fillRectangle(20, 20, 100, 100);
				gc.drawRectangle(0, 20, 100, 100);
		}
	});
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}
Comment 9 Andre Saibel CLA 2012-08-09 04:12:13 EDT
Alright. What does that mean for the request?
Comment 10 Andre Saibel CLA 2012-11-20 10:31:08 EST
still @deprecated?
Comment 11 Eclipse Genie CLA 2019-11-07 15:17:48 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 12 Andre Saibel CLA 2019-11-08 02:17:51 EST
XOR is a basic graphics feature so for me there is no reason to keep the @deprecated tag just because this feature is not supported on older Linux resp. Cairo < 1.10.
Comment 13 Eric Williams CLA 2019-11-08 09:15:28 EST
(In reply to Andre Saibel from comment #12)
> XOR is a basic graphics feature so for me there is no reason to keep the
> @deprecated tag just because this feature is not supported on older Linux
> resp. Cairo < 1.10.

Agreed, we don't support GTK3 versions with Cairo < 1.12, so we can definitely remove this tag.
Comment 14 Eclipse Genie CLA 2019-11-08 10:38:01 EST
New Gerrit change created: https://git.eclipse.org/r/152338
Comment 16 Eric Williams CLA 2019-11-08 16:52:17 EST
(In reply to Eclipse Genie from comment #15)
> Gerrit change https://git.eclipse.org/r/152338 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=1af84db9d9097f2c1d4b3b33cc3dc258334486cb

In master now.
Comment 17 Eric Williams CLA 2019-11-19 08:55:05 EST
Verified in I20191119-0510.