Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blend modes seem configured differently on iOS and Android #10

Closed
wcandillon opened this issue Dec 9, 2021 · 9 comments · Fixed by #198
Closed

Blend modes seem configured differently on iOS and Android #10

wcandillon opened this issue Dec 9, 2021 · 9 comments · Fixed by #198
Assignees

Comments

@wcandillon
Copy link
Contributor

wcandillon commented Dec 9, 2021

And Android and RN web, blend modes behave the same (as expected except for some blend modes: #5)

https://skia.org/docs/user/api/skblendmode_overview/

Screenshot 2021-12-09 at 23 02 51

On iOS, only a few blend modes are working (blend mode test is in #5).
IMG_95BB2CB7EB9F-1
IMG_3291

@wcandillon
Copy link
Contributor Author

One thing I tried is to set the blendmode directly (to make sure that this is not an issue with the JSI API):

   getObject()->setBlendMode(SkBlendMode::kMultiply);

This produces the same result on iOS. To be investigated further.

@wcandillon
Copy link
Contributor Author

wcandillon commented Feb 14, 2022

This is the test code I am running in C++ directly:

canvas->clear(SK_ColorTRANSPARENT);
SkPaint paint;
paint.setBlendMode(SkBlendMode::kMultiply);
auto width = 256 * _context->getPixelDensity();
auto height = 256 * _context->getPixelDensity();
auto r = 128 * _context->getPixelDensity();
SkPaint cyan(paint);
cyan.setColor(SK_ColorCYAN);
canvas->drawCircle(r, r, r, cyan);
// Magenta Circle
SkPaint magenta(paint);
magenta.setColor(SK_ColorMAGENTA);
canvas->drawCircle(width - r, r, r, magenta);
// Yellow Circle
SkPaint yellow(paint);
yellow.setColor(SK_ColorYELLOW);
canvas->drawCircle(width/2, height - r, r, magenta);
canvas->drawCircle(0, 0, r, yellow);
canvas->flush();

The example looks quite strange on iOS, changing the blendmode does changes the color, not sure if it's an issue with the porterduff mode.
Another lead we had was to try to change the settings on Android to try to reproduce the same result on Android as well but I was not able to.
One thing that seems to work well is the porterduff mode. For instance paint.setBlendMode(SkBlendMode::kDstOver); would work as expected.

@wcandillon
Copy link
Contributor Author

Here's the gist of the example above: https://gist.github.com/wcandillon/98c254161b78f274f224a0c8fa6df561

@chrfalch
Copy link
Contributor

Android:
image

@chrfalch
Copy link
Contributor

chrfalch commented Feb 14, 2022

iOS Simulator:
image

iOS Device (iPhone 12):
IMG_0709

@chrfalch
Copy link
Contributor

@chrfalch
Copy link
Contributor

Link to discussion about blend modes on Skia Discuss: https://groups.google.com/g/skia-discuss/c/3qKDPB7jb-0/m/PBcMf_ImBgAJ

@wcandillon
Copy link
Contributor Author

When looking at the multiply blendmode, there is a difference between the simulator (where the color is multiplied by magenta #ff00ff no matter what) and on the physical device where the color is multiplied by black no matter what.

This seems to be consistent with the image filter blending issue which is magenta on simulator and transparent on the physical device.

@wcandillon
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants