-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for layer blend mode "bm" for NORMAL, SCREEN, OVERLAY, DA…
…RKEN, LIGHTEN, and ADD (#2408) 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](https://github.com/airbnb/lottie-android/assets/141772/faad31e8-2fd7-496c-9304-ca81451c6d46) ![Screenshot 2023-10-30 at 12 27 39](https://github.com/airbnb/lottie-android/assets/141772/746ef507-284d-4eec-a632-ad5fe59eaaa0) Co-authored-by: Gabriel Peal <[email protected]>
- Loading branch information
Showing
23 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
lottie/src/main/java/com/airbnb/lottie/model/content/LBlendMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.airbnb.lottie.model.content; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.core.graphics.BlendModeCompat; | ||
|
||
/** | ||
* Lottie BlendMode, | ||
* not to be confused with Paint.BlendMode in android graphics core, | ||
* which we will rely on for rendering. | ||
*/ | ||
public enum LBlendMode { | ||
NORMAL, | ||
MULTIPLY, | ||
SCREEN, | ||
OVERLAY, | ||
DARKEN, | ||
LIGHTEN, | ||
COLOR_DODGE, | ||
COLOR_BURN, | ||
HARD_LIGHT, | ||
SOFT_LIGHT, | ||
DIFFERENCE, | ||
EXCLUSION, | ||
HUE, | ||
SATURATION, | ||
COLOR, | ||
LUMINOSITY, | ||
ADD, | ||
HARD_MIX; | ||
|
||
@Nullable | ||
public BlendModeCompat toNativeBlendMode() { | ||
switch (this) { | ||
case NORMAL: | ||
return null; | ||
case SCREEN: | ||
return BlendModeCompat.SCREEN; | ||
case OVERLAY: | ||
return BlendModeCompat.OVERLAY; | ||
case DARKEN: | ||
return BlendModeCompat.DARKEN; | ||
case LIGHTEN: | ||
return BlendModeCompat.LIGHTEN; | ||
case ADD: | ||
return BlendModeCompat.PLUS; | ||
|
||
// Blend modes below were not added to the platform until Q. | ||
// To prevent unexpected issues where animations look correct | ||
// during development but silently break for users with older devices | ||
// we won't support any of these until Q is widely used. | ||
case MULTIPLY: | ||
case COLOR_DODGE: | ||
case COLOR_BURN: | ||
case HARD_LIGHT: | ||
case SOFT_LIGHT: | ||
case DIFFERENCE: | ||
case EXCLUSION: | ||
case HUE: | ||
case SATURATION: | ||
case COLOR: | ||
case LUMINOSITY: | ||
case HARD_MIX: | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"v":"5.7.1","ip":0,"op":180,"nm":"Animation","mn":"{429ff333-f31c-4124-91c5-5e861412a004}","fr":60,"w":512,"h":512,"assets":[],"layers":[{"ddd":0,"ty":4,"ind":1,"st":0,"ip":0,"op":180,"nm":"Layer","mn":"{625eab7e-4758-4d4b-b37c-d89115b1442b}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":77}},"shapes":[{"ty":"gr","nm":"Ellipse","mn":"{dd57d763-ff3b-420f-a94d-eb5503e7faa7}","it":[{"ty":"el","nm":"Ellipse","mn":"{fa5c495c-00d1-4253-b30c-cc8cb1b855b2}","p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[195.15223880597017,180.53731343283584]}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{89437b5f-dca9-42d4-aff9-c57ce08c8c1e}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{352559ca-ebe9-4b11-acdd-09e155612598}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.3411764705882353,0.01568627450980392]},"r":1},{"ty":"tr","a":{"a":0,"k":[400.1910447761194,240.71641791044777]},"p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"PolyStar","mn":"{b6000853-a4d3-4b13-acdd-2e4f1a192760}","it":[{"ty":"sr","nm":"PolyStar","mn":"{d647a149-8105-4e08-b395-c8de40669fb0}","p":{"a":0,"k":[110.90149253731343,216.644776119403]},"or":{"a":0,"k":121.5619125366211},"ir":{"a":0,"k":60.78095626831055},"r":{"a":0,"k":143.04905700683594},"pt":{"a":0,"k":5},"sy":1,"os":{"a":0,"k":0},"is":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{67a87e2b-afff-4f55-9004-4cc274cefe07}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{39b8d13c-45cf-4ad7-972a-ef5169f1ffbf}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"r":1},{"ty":"tr","a":{"a":0,"k":[110.90149253731343,216.644776119403]},"p":{"a":0,"k":[159.9044776119403,247.59402985074627]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"bm":0},{"ddd":0,"ty":4,"ind":0,"st":0,"ip":0,"op":180,"nm":"Layer 1","mn":"{d74c9dcc-e7af-45c3-9eab-554c7b93f6b6}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","nm":"Rectangle 1","mn":"{b22ddad1-738b-471a-86eb-1f072fa45799}","it":[{"ty":"rc","nm":"Rectangle 1","mn":"{0c09bd21-59ab-4f1e-bd3d-547613eb3e2a}","p":{"a":0,"k":[241.57611940298506,357.6358208955224]},"s":{"a":0,"k":[383.4268656716418,211.4865671641791]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{8cd4fca9-3480-49fa-947f-04bc40ed74f5}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{050089d8-44c4-4312-8e23-3c89df7615aa}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.7686274509803922,0.8509803921568627,0.9607843137254902]},"r":1},{"ty":"tr","a":{"a":0,"k":[241.57611940298506,357.6358208955224]},"p":{"a":0,"k":[226.1014925373134,131.53432835820894]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"Rectangle","mn":"{700bfca8-0e45-42e9-8559-15ac0ebe93b2}","it":[{"ty":"rc","nm":"Rectangle","mn":"{0e3ac2ac-22c8-4310-8208-f5d5ba9cd6d9}","p":{"a":0,"k":[277.68358208955226,148.2985074626866]},"s":{"a":0,"k":[335.2835820895522,162.48358208955224]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{af0c691f-7815-414e-a988-ac2eb6e32128}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{059d8c4e-de02-4fa7-99fe-c069b73218be}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.19607843137254902,0.3137254901960784,0.6901960784313725]},"r":1},{"ty":"tr","a":{"a":0,"k":[277.68358208955226,148.2985074626866]},"p":{"a":0,"k":[277.68358208955226,366.6626865671642]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}]}],"meta":{"g":"Glaxnimate 0.4.6-32-gb62899be"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"v":"5.7.1","ip":0,"op":180,"nm":"Animation","mn":"{429ff333-f31c-4124-91c5-5e861412a004}","fr":60,"w":512,"h":512,"assets":[],"layers":[{"ddd":0,"ty":4,"ind":1,"st":0,"ip":0,"op":180,"nm":"Layer","mn":"{625eab7e-4758-4d4b-b37c-d89115b1442b}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":77}},"shapes":[{"ty":"gr","nm":"Ellipse","mn":"{dd57d763-ff3b-420f-a94d-eb5503e7faa7}","it":[{"ty":"el","nm":"Ellipse","mn":"{fa5c495c-00d1-4253-b30c-cc8cb1b855b2}","p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[195.15223880597017,180.53731343283584]}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{89437b5f-dca9-42d4-aff9-c57ce08c8c1e}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{352559ca-ebe9-4b11-acdd-09e155612598}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.3411764705882353,0.01568627450980392]},"r":1},{"ty":"tr","a":{"a":0,"k":[400.1910447761194,240.71641791044777]},"p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"PolyStar","mn":"{b6000853-a4d3-4b13-acdd-2e4f1a192760}","it":[{"ty":"sr","nm":"PolyStar","mn":"{d647a149-8105-4e08-b395-c8de40669fb0}","p":{"a":0,"k":[110.90149253731343,216.644776119403]},"or":{"a":0,"k":121.5619125366211},"ir":{"a":0,"k":60.78095626831055},"r":{"a":0,"k":143.04905700683594},"pt":{"a":0,"k":5},"sy":1,"os":{"a":0,"k":0},"is":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{67a87e2b-afff-4f55-9004-4cc274cefe07}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{39b8d13c-45cf-4ad7-972a-ef5169f1ffbf}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"r":1},{"ty":"tr","a":{"a":0,"k":[110.90149253731343,216.644776119403]},"p":{"a":0,"k":[159.9044776119403,247.59402985074627]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"bm":1},{"ddd":0,"ty":4,"ind":0,"st":0,"ip":0,"op":180,"nm":"Layer 1","mn":"{d74c9dcc-e7af-45c3-9eab-554c7b93f6b6}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","nm":"Rectangle 1","mn":"{b22ddad1-738b-471a-86eb-1f072fa45799}","it":[{"ty":"rc","nm":"Rectangle 1","mn":"{0c09bd21-59ab-4f1e-bd3d-547613eb3e2a}","p":{"a":0,"k":[241.57611940298506,357.6358208955224]},"s":{"a":0,"k":[383.4268656716418,211.4865671641791]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{8cd4fca9-3480-49fa-947f-04bc40ed74f5}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{050089d8-44c4-4312-8e23-3c89df7615aa}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.7686274509803922,0.8509803921568627,0.9607843137254902]},"r":1},{"ty":"tr","a":{"a":0,"k":[241.57611940298506,357.6358208955224]},"p":{"a":0,"k":[226.1014925373134,131.53432835820894]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"Rectangle","mn":"{700bfca8-0e45-42e9-8559-15ac0ebe93b2}","it":[{"ty":"rc","nm":"Rectangle","mn":"{0e3ac2ac-22c8-4310-8208-f5d5ba9cd6d9}","p":{"a":0,"k":[277.68358208955226,148.2985074626866]},"s":{"a":0,"k":[335.2835820895522,162.48358208955224]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{af0c691f-7815-414e-a988-ac2eb6e32128}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{059d8c4e-de02-4fa7-99fe-c069b73218be}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.19607843137254902,0.3137254901960784,0.6901960784313725]},"r":1},{"ty":"tr","a":{"a":0,"k":[277.68358208955226,148.2985074626866]},"p":{"a":0,"k":[277.68358208955226,366.6626865671642]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}]}],"meta":{"g":"Glaxnimate 0.4.6-32-gb62899be"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"v":"5.7.1","ip":0,"op":180,"nm":"Animation","mn":"{429ff333-f31c-4124-91c5-5e861412a004}","fr":60,"w":512,"h":512,"assets":[],"layers":[{"ddd":0,"ty":4,"ind":1,"st":0,"ip":0,"op":180,"nm":"Layer","mn":"{625eab7e-4758-4d4b-b37c-d89115b1442b}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":77}},"shapes":[{"ty":"gr","nm":"Ellipse","mn":"{dd57d763-ff3b-420f-a94d-eb5503e7faa7}","it":[{"ty":"el","nm":"Ellipse","mn":"{fa5c495c-00d1-4253-b30c-cc8cb1b855b2}","p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[195.15223880597017,180.53731343283584]}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{89437b5f-dca9-42d4-aff9-c57ce08c8c1e}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{352559ca-ebe9-4b11-acdd-09e155612598}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.3411764705882353,0.01568627450980392]},"r":1},{"ty":"tr","a":{"a":0,"k":[400.1910447761194,240.71641791044777]},"p":{"a":0,"k":[400.1910447761194,240.71641791044777]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"PolyStar","mn":"{b6000853-a4d3-4b13-acdd-2e4f1a192760}","it":[{"ty":"sr","nm":"PolyStar","mn":"{d647a149-8105-4e08-b395-c8de40669fb0}","p":{"a":0,"k":[110.90149253731343,216.644776119403]},"or":{"a":0,"k":121.5619125366211},"ir":{"a":0,"k":60.78095626831055},"r":{"a":0,"k":143.04905700683594},"pt":{"a":0,"k":5},"sy":1,"os":{"a":0,"k":0},"is":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{67a87e2b-afff-4f55-9004-4cc274cefe07}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{39b8d13c-45cf-4ad7-972a-ef5169f1ffbf}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"r":1},{"ty":"tr","a":{"a":0,"k":[110.90149253731343,216.644776119403]},"p":{"a":0,"k":[159.9044776119403,247.59402985074627]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}],"bm":10},{"ddd":0,"ty":4,"ind":0,"st":0,"ip":0,"op":180,"nm":"Layer 1","mn":"{d74c9dcc-e7af-45c3-9eab-554c7b93f6b6}","ks":{"a":{"a":0,"k":[256,256]},"p":{"a":0,"k":[256,256]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}},"shapes":[{"ty":"gr","nm":"Rectangle 1","mn":"{b22ddad1-738b-471a-86eb-1f072fa45799}","it":[{"ty":"rc","nm":"Rectangle 1","mn":"{0c09bd21-59ab-4f1e-bd3d-547613eb3e2a}","p":{"a":0,"k":[241.57611940298506,357.6358208955224]},"s":{"a":0,"k":[383.4268656716418,211.4865671641791]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{8cd4fca9-3480-49fa-947f-04bc40ed74f5}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{050089d8-44c4-4312-8e23-3c89df7615aa}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.7686274509803922,0.8509803921568627,0.9607843137254902]},"r":1},{"ty":"tr","a":{"a":0,"k":[241.57611940298506,357.6358208955224]},"p":{"a":0,"k":[226.1014925373134,131.53432835820894]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]},{"ty":"gr","nm":"Rectangle","mn":"{700bfca8-0e45-42e9-8559-15ac0ebe93b2}","it":[{"ty":"rc","nm":"Rectangle","mn":"{0e3ac2ac-22c8-4310-8208-f5d5ba9cd6d9}","p":{"a":0,"k":[277.68358208955226,148.2985074626866]},"s":{"a":0,"k":[335.2835820895522,162.48358208955224]},"r":{"a":0,"k":0}},{"ty":"st","hd":true,"nm":"Stroke","mn":"{af0c691f-7815-414e-a988-ac2eb6e32128}","o":{"a":0,"k":100},"c":{"a":0,"k":[1,0.9803921568627451,0.2823529411764706]},"lc":2,"lj":2,"ml":0,"w":{"a":0,"k":30}},{"ty":"fl","nm":"Fill","mn":"{059d8c4e-de02-4fa7-99fe-c069b73218be}","o":{"a":0,"k":100},"c":{"a":0,"k":[0.19607843137254902,0.3137254901960784,0.6901960784313725]},"r":1},{"ty":"tr","a":{"a":0,"k":[277.68358208955226,148.2985074626866]},"p":{"a":0,"k":[277.68358208955226,366.6626865671642]},"s":{"a":0,"k":[100,100]},"r":{"a":0,"k":0},"o":{"a":0,"k":100}}]}]}],"meta":{"g":"Glaxnimate 0.4.6-32-gb62899be"}} |
Oops, something went wrong.