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

Add support for layer blend mode "bm" for NORMAL, SCREEN, OVERLAY, DARKEN, LIGHTEN, and ADD #2408

Merged
merged 19 commits into from Nov 18, 2023

Conversation

kudanai
Copy link
Contributor

@kudanai kudanai commented Oct 30, 2023

Adds support for "bm" (BlendMode) on layers. Possibly addresses #1055
Might need a little bit of a refactor. Relies on Paint.setBlendMode() available in android Q and up.

Sample before & after

IMAGE 2023-10-30 12:28:18
Screenshot 2023-10-30 at 12 27 39

Copy link
Collaborator

@gpeal gpeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a stab at this!

I want to land this but in the past, I have been hesitant to launch feature that require new platforms until the usage of that platform is very high. About 75% of Android phones are on Q and above but most apps aren't there with their minSdk yet.

The use case I'm concerned about is somebody landing an animation that looks correct during development but looks completely broken for end users with old phones.

The only other time I've launched something like this was enableMergePathsForKitKatAndAbove in which it's opt-in and the API makes it very clear what the platform restrictions are.

Also, if you add animations to this folder, they will automatically be picked up by snapshot tests.

@github-actions
Copy link

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

kudanai and others added 3 commits October 30, 2023 21:38
…ontent.java

Co-authored-by: Gabriel Peal <gpeal@users.noreply.github.com>
Co-authored-by: Gabriel Peal <gpeal@users.noreply.github.com>
…e.java

Co-authored-by: Gabriel Peal <gpeal@users.noreply.github.com>
@kudanai
Copy link
Contributor Author

kudanai commented Oct 30, 2023

Thank you for the feedback.

I understand what you mean by the version check. I could suggest rolling back a little and only supporting the blend modes that have lower minsdk requirements, and continue working on it from there. Does that seem like a more prudent approach?

Also I wasn't entirely sure about the structure of that enum, it feels overly verbose to me. However since bm can also appear for shapes, figured it might be useful to leave the enum itself in place.

Done! Meanwhile, I will collect some sample lotties with specific blend modes and drop them in the directory.

Copy link

github-actions bot commented Nov 2, 2023

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

@kudanai
Copy link
Contributor Author

kudanai commented Nov 7, 2023

Pushing new changes:

  • Separate out the backwards compatible blend modes and ones that are only Q+
    • They've been moved out into a separate (unused for now) method
    • we'll be enabling 6/18 blend modes: NORMAL, SCREEN, OVERLAY, DARKEN, LIGHTEN, and ADD
  • Removed API version guard while actually applying the layer blend mode

# Conflicts:
#	lottie/src/main/java/com/airbnb/lottie/animation/content/FillContent.java
#	lottie/src/main/java/com/airbnb/lottie/model/content/LBlendMode.java
Copy link

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

@kudanai kudanai changed the title Add support for "bm" (BlendMode) for Android Q and up Add support for layer blend mode "bm" for NORMAL, SCREEN, OVERLAY, DARKEN, LIGHTEN, and ADD Nov 14, 2023
@kudanai
Copy link
Contributor Author

kudanai commented Nov 15, 2023

The supported modes look consistent to me on 23 and 31 now

Copy link

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

Copy link
Collaborator

@gpeal gpeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

@gpeal gpeal merged commit 1256d26 into airbnb:master Nov 18, 2023
6 checks passed
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 this pull request may close these issues.

None yet

2 participants