Bug 38844 - Reduce XOR rendering (search RasterOp::Xor)
Summary: Reduce XOR rendering (search RasterOp::Xor)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: reviewed:2023
Keywords: difficultyMedium, easyHack, skillCpp, topicCleanup
Depends on: 156365 122970
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2011-06-30 09:39 UTC by Björn Michaelsen
Modified: 2024-03-17 11:59 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michaelsen 2011-06-30 09:39:36 UTC
Reduce XOR rendering

Background: Back in the stone age, a fast way to do masking was to XOR render a rectangular texture onto the screen, then draw a shape on it in black; then re-XOR render the texture rectangle - thus removing it everywhere except where the shape was drawn: bingo, a filled shape. Unfortunately, this works really very poorly on modern graphics hardware, cannot be anti-aliased etc. So - it would be great to go through the code (search ROP_XOR) and re-work code portions to render an alpha mask, that can be rendered with instead - for eg. complex gradient cases etc. Some ROP_XOR invocations are still needed for legacy meta-files though, avoid poking them. In some cases these have already been special cased for Mac (no XOR mode), which should mostly be a matter of simply using the Mac conditional everywhere.

Skills: C++, graphics etc
Comment 1 Florian Reisinger 2012-05-18 09:00:40 UTC
Deteted "Easyhack" from summary
Comment 2 Björn Michaelsen 2013-10-04 18:47:07 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 3 Commit Notification 2014-03-28 11:59:21 UTC
Krisztian Pinter committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=06db1edf617b537d774f487e0ab7d3528c5626df

fdo#38844 Remove XOR rendering code from canvas module



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Chris Sherlock 2014-04-07 07:00:04 UTC
I've made a change to vcl/source/gdi/outdev4.cxx around gradient clipping:

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8659d189ec04aca78c8ffff97fcca507ca0a9ec3

I check have seperated out XOR clipping for gradients into ClipAndDrawGradient and XORClipAndDrawGradient. 

Possibly we can mark the XORClipAndDrawGradient as deprecated and remove it eventually. I did this change without knowing about this bug, btw :-)
Comment 5 Commit Notification 2014-04-12 18:17:14 UTC
Chris Sherlock committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bb5c7d6a79309236d4f19bb2498f2e850f735a2f

fdo#38844 Reduce XOR clipping for gradients



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Stefan Weiberg 2014-09-08 08:20:00 UTC
Is this EasyHack resolved and fixed?
Comment 7 tommy27 2015-10-15 05:38:40 UTC
(In reply to Stefan Weiberg from comment #6)
> Is this EasyHack resolved and fixed?

please answer
Comment 8 How can I remove my account? 2015-10-15 06:31:21 UTC
Read what the initial comment says. "search ROP_XOR". Do you find any?
Comment 9 tommy27 2015-10-15 08:43:03 UTC
I don't know. I'm not a developer and I don't understand anything about the code.

I just wondered if the work was done in this area or if it's still a work in progress easy hack just like tehe "remove genrman comments" thing
Comment 10 How can I remove my account? 2015-10-15 08:51:02 UTC
There are still ROP_XORs in the code, so I would assume this is not fixed.
Comment 11 Robinson Tryon (qubit) 2015-12-14 06:31:59 UTC Comment hidden (noise)
Comment 12 Robinson Tryon (qubit) 2016-02-18 14:51:39 UTC Comment hidden (noise)
Comment 13 charan 2016-12-13 05:46:03 UTC
i want to work on this
Comment 14 jani 2017-01-13 08:02:18 UTC Comment hidden (obsolete)
Comment 15 charan 2017-01-15 04:09:06 UTC
(In reply to jan iversen from comment #14)
> A polite ping, still working on this bug ?

yes
Comment 16 Naeil ZOUEIDI 2017-06-20 12:07:38 UTC
Another polite ping, @charan, still working on it?
Comment 17 Ashis Paul 2018-03-02 09:38:42 UTC
I am assigned to this bug but I have no idea about the source code. Can anyone help me with the bug details and master code?
Comment 18 Xisco Faulí 2018-04-02 02:26:12 UTC Comment hidden (obsolete)
Comment 19 Xisco Faulí 2018-05-03 02:38:49 UTC
A polite ping, still working on this bug?
Comment 20 Xisco Faulí 2018-06-03 02:39:21 UTC Comment hidden (obsolete)
Comment 21 Xisco Faulí 2018-07-04 02:45:28 UTC Comment hidden (obsolete)
Comment 22 Xisco Faulí 2018-08-04 02:36:55 UTC Comment hidden (obsolete)
Comment 23 Xisco Faulí 2018-09-04 02:51:20 UTC Comment hidden (obsolete)
Comment 24 Xisco Faulí 2018-10-05 02:50:31 UTC Comment hidden (obsolete)
Comment 25 Xisco Faulí 2018-11-05 03:41:15 UTC Comment hidden (obsolete)
Comment 26 Xisco Faulí 2018-12-06 03:56:14 UTC Comment hidden (obsolete)
Comment 27 Xisco Faulí 2019-01-06 04:17:36 UTC Comment hidden (obsolete)
Comment 28 Xisco Faulí 2019-02-06 03:48:42 UTC Comment hidden (obsolete)
Comment 29 Xisco Faulí 2019-03-09 03:39:37 UTC Comment hidden (obsolete)
Comment 30 Xisco Faulí 2019-03-10 03:17:17 UTC Comment hidden (obsolete)
Comment 31 Xisco Faulí 2019-06-10 14:52:14 UTC
Dear Ashis Paul,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assigned it back to yourself if you're still working on this.
Comment 32 oo.o+libreoffice 2019-07-22 11:13:02 UTC
Hello,

I did a search with
grep -ri ROP_XOR .
and got no hit.
See the original ticket description (https://bugs.documentfoundation.org/show_bug.cgi?id=38844#c0).
Comment 33 Tomaz Vajngerl 2019-07-22 12:08:58 UTC
(In reply to oo.o+libreoffice from comment #32)
> Hello,
> 
> I did a search with
> grep -ri ROP_XOR .
> and got no hit.
> See the original ticket description
> (https://bugs.documentfoundation.org/show_bug.cgi?id=38844#c0).

That's because ROP_XOR was changed to RasterOp::Xor

The issue is definitely not resolved yet... unfortunately.
Comment 34 Hossein 2022-06-16 13:54:55 UTC
Re-evaluating the EasyHack in 2022

This enhancement is still relevant. Searching for RasterOp::Xor gives several (38) results.
Comment 35 dipamt1729 2023-02-02 06:07:22 UTC
I would like to work on this issue.
Comment 36 Hossein 2023-06-07 08:51:05 UTC
Re-evaluating the EasyHack in 2022

This enhancement is still relevant. I revised the searching for RasterOp::Xor, excluding those related to emf/wmf, and workbenches. It's around 21 instances, mostly in vcl:

$ git grep RasterOp::Xor|grep -v wmf|grep -v emf|grep -v workben
drawinglayer/source/processor2d/vclhelperbufferdevice.cxx:    // copy RasterOp (e.g. may be RasterOp::Xor on destination)
drawinglayer/source/processor2d/vclhelperbufferdevice.cxx:    // during painting the buffer, disable evtl. set RasterOp (may be RasterOp::Xor)
drawinglayer/source/processor2d/vclpixelprocessor2d.cxx:    mpOutputDevice->SetRasterOp(RasterOp::Xor);
svx/source/xoutdev/_xoutbmp.cxx:                        pVDev->SetRasterOp( RasterOp::Xor );
sw/source/uibase/utlui/shdwcrsr.cxx:    m_pWin->GetOutDev()->SetRasterOp( RasterOp::Xor );
vcl/backendtest/outputdevice/outputdevice.cxx:    mpVirtualDevice->SetRasterOp(RasterOp::Xor);
vcl/backendtest/outputdevice/outputdevice.cxx:    mpVirtualDevice->SetRasterOp(RasterOp::Xor);
vcl/backendtest/outputdevice/outputdevice.cxx:    mpVirtualDevice->SetRasterOp(RasterOp::Xor);
vcl/qa/cppunit/outdev.cxx:    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
vcl/qa/cppunit/outdev.cxx:    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
vcl/qa/cppunit/svm/svmtest.cxx:    pVirtualDev->SetRasterOp(RasterOp::Xor);
vcl/source/filter/imet/ios2met.cxx:        case 0x04: return RasterOp::Xor;
vcl/source/filter/imet/ios2met.cxx:        case 0x0b: return RasterOp::Xor;
vcl/source/filter/ipict/ipict.cxx:            case 2: eActROP=RasterOp::Xor;       break; // Xor
vcl/source/filter/ipict/ipict.cxx:            case 6: eActROP=RasterOp::Xor;       break; // notXor
vcl/source/filter/svm/SvmConverter.cxx:                        eRasterOp = RasterOp::Xor;
vcl/source/gdi/mtfxmldump.cxx:        case RasterOp::Xor:       return "xor";
vcl/source/gdi/print.cxx:        mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );
vcl/source/gdi/virdev.cxx:        mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );
vcl/source/outdev/gradient.cxx:    SetRasterOp( RasterOp::Xor );
vcl/source/outdev/gradient.cxx:    SetRasterOp( RasterOp::Xor );
vcl/source/outdev/outdev.cxx:            mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );
vcl/source/window/window.cxx:        mpGraphics->SetXORMode( (RasterOp::Invert == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert == meRasterOp );

There are several other instances that may not be directly related, but worth taking a look:

$ git grep XOR *.cxx|wc -l
237
Comment 37 Buovjaga 2024-03-16 19:16:23 UTC
Multi-hack, not assigned.
Comment 38 Devansh Varshney 2024-03-17 11:59:35 UTC
(In reply to Hossein from comment #36)
> $ git grep RasterOp::Xor|grep -v wmf|grep -v emf|grep -v workben

> vcl/source/gdi/print.cxx:        mpGraphics->SetXORMode( (RasterOp::Invert
> == meRasterOp) || (RasterOp::Xor == meRasterOp), RasterOp::Invert ==
> meRasterOp );


In this one it sets the XOR mode on the acquired graphics object based on the current raster operation (meRasterOp).

So, can we replace the SetXORMode() function with SetCompositionMode() to transition away from XOR rendering in the Skia backend?


got some idea after searching -

https://cpp.hotexamples.com/examples/-/QPainter/setCompositionMode/cpp-qpainter-setcompositionmode-method-examples.html


Or is there any other way?