This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] add a generic porter duff blend foreground shader. #41098
Merged
Merged
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3fc2b35
[Impeller] blender filter investigation
1ba540c
++
ed0d261
++
66d6772
[Impeller] add an inline pipeline blend
af07248
++
e8397ab
++
6ec2f59
++
c2cc542
++
07445d6
Merge branch 'master' of github.com:flutter/engine into blender_filter
0c2793f
++
a5228c1
Merge branch 'main' into blender_filter
0a7eb9f
++
900a4ca
Merge branch 'blender_filter' of github.com:jonahwilliams/engine into…
a490fac
licenses
a6b6a9b
++
7cf5333
Merge branch 'main' into blender_filter
7f12453
++
dcc202d
Merge branch 'blender_filter' of github.com:jonahwilliams/engine into…
1221a84
Merge branch 'main' into blender_filter
630a194
malioc diff
6a22ec3
Merge branch 'blender_filter' of github.com:jonahwilliams/engine into…
ee32ab7
require absorbing opacity
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,76 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <impeller/blending.glsl> | ||
| #include <impeller/color.glsl> | ||
| #include <impeller/texture.glsl> | ||
| #include <impeller/types.glsl> | ||
|
|
||
| uniform f16sampler2D texture_sampler_dst; | ||
|
|
||
| // This must be kept in sync with the values in impeller/geometry/color.h | ||
| // clear, src, dst are excluded as these do not require blending. | ||
|
|
||
| const float16_t kSourceOver = 3.0hf; | ||
| const float16_t kDestinationOver = 4.0hf; | ||
| const float16_t kSourceIn = 5.0hf; | ||
| const float16_t kDestinationIn = 6.0hf; | ||
| const float16_t kSourceOut = 7.0hf; | ||
| const float16_t kDestinationOut = 8.0hf; | ||
| const float16_t kSourceATop = 9.0hf; | ||
| const float16_t kDestinationATop = 10.0hf; | ||
| const float16_t kXor = 11.0hf; | ||
| const float16_t kPlus = 12.0hf; | ||
| const float16_t kModulate = 13.0hf; | ||
|
|
||
| uniform FragInfo { | ||
| float16_t operation; | ||
| float16_t input_alpha; | ||
| f16vec4 color; | ||
| } | ||
| frag_info; | ||
|
|
||
| in vec2 v_texture_coords; | ||
|
|
||
| out f16vec4 frag_color; | ||
|
|
||
| f16vec4 Sample(f16sampler2D texture_sampler, vec2 texture_coords) { | ||
| // gles 2.0 is the only backend without native decal support. | ||
| #ifdef IMPELLER_TARGET_OPENGLES | ||
| return IPSampleDecal(texture_sampler, texture_coords); | ||
| #else | ||
| return texture(texture_sampler, texture_coords); | ||
| #endif | ||
| } | ||
|
|
||
| // Note: this shader reduces the number of branches required by conditionally | ||
| // modifying the foreground color. | ||
| void main() { | ||
| f16vec4 dst_color = | ||
| texture(texture_sampler_dst, v_texture_coords) * frag_info.input_alpha; | ||
|
|
||
| if (frag_info.operation == kSourceOver) { | ||
| frag_color = IPBlendSourceOver(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kDestinationOver) { | ||
| frag_color = IPBlendDestinationOver(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kSourceIn) { | ||
| frag_color = IPBlendSourceIn(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kDestinationIn) { | ||
| frag_color = IPBlendDestinationIn(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kSourceOut) { | ||
| frag_color = IPBlendSourceOut(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kDestinationOut) { | ||
| frag_color = IPBlendDestinationOut(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kSourceATop) { | ||
| frag_color = IPBlendSourceATop(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kDestinationATop) { | ||
| frag_color = IPBlendDestinationATop(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kXor) { | ||
| frag_color = IPBlendXOR(frag_info.color, dst_color); | ||
| } else if (frag_info.operation == kPlus) { | ||
| frag_color = IPBlendPlus(frag_info.color, dst_color); | ||
| } else { | ||
| frag_color = IPBlendModulate(frag_info.color, dst_color); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.