зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1594128 - Add brush_mix_blend to the multi-brush infrastructure. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D53994 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9d0844f71b
Коммит
f13c3cb330
|
@ -225,6 +225,12 @@ void main(void) {
|
|||
blend_brush_vs(BRUSH_VS_PARAMS);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef WR_FEATURE_MIX_BLEND_BRUSH
|
||||
case BRUSH_KIND_MIX_BLEND:
|
||||
mix_blend_brush_vs(BRUSH_VS_PARAMS);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -279,6 +285,12 @@ void main(void) {
|
|||
frag = blend_brush_fs();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef WR_FEATURE_MIX_BLEND_BRUSH
|
||||
case BRUSH_KIND_MIX_BLEND: {
|
||||
frag = mix_blend_brush_fs();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
|
||||
#include shared,prim_shared,brush
|
||||
|
||||
varying vec3 vSrcUv;
|
||||
varying vec3 vBackdropUv;
|
||||
flat varying int vOp;
|
||||
#define V_SRC_UV varying_vec4_0.xy
|
||||
#define V_SRC_LAYER varying_vec4_0.w
|
||||
|
||||
#define V_BACKDROP_UV varying_vec4_1.xy
|
||||
#define V_BACKDROP_LAYER varying_vec4_1.w
|
||||
|
||||
#define V_OP flat_varying_ivec4_0.x
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
|
||||
|
@ -35,19 +39,21 @@ void mix_blend_brush_vs(
|
|||
) {
|
||||
vec2 snapped_device_pos = snap_device_pos(vi, pic_task.device_pixel_scale);
|
||||
vec2 texture_size = vec2(textureSize(sPrevPassColor, 0));
|
||||
vOp = prim_user_data.x;
|
||||
V_OP = prim_user_data.x;
|
||||
|
||||
PictureTask src_task = fetch_picture_task(prim_user_data.z);
|
||||
vec2 src_uv = snapped_device_pos +
|
||||
src_task.common_data.task_rect.p0 -
|
||||
src_task.content_origin;
|
||||
vSrcUv = vec3(src_uv / texture_size, src_task.common_data.texture_layer_index);
|
||||
V_SRC_UV = src_uv / texture_size;
|
||||
V_SRC_LAYER = src_task.common_data.texture_layer_index;
|
||||
|
||||
RenderTaskCommonData backdrop_task = fetch_render_task_common_data(prim_user_data.y);
|
||||
vec2 backdrop_uv = snapped_device_pos +
|
||||
backdrop_task.task_rect.p0 -
|
||||
src_task.content_origin;
|
||||
vBackdropUv = vec3(backdrop_uv / texture_size, backdrop_task.texture_layer_index);
|
||||
V_BACKDROP_UV = backdrop_uv / texture_size;
|
||||
V_BACKDROP_LAYER = backdrop_task.texture_layer_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -210,8 +216,8 @@ const int MixBlendMode_Color = 14;
|
|||
const int MixBlendMode_Luminosity = 15;
|
||||
|
||||
Fragment mix_blend_brush_fs() {
|
||||
vec4 Cb = textureLod(sPrevPassColor, vBackdropUv, 0.0);
|
||||
vec4 Cs = textureLod(sPrevPassColor, vSrcUv, 0.0);
|
||||
vec4 Cb = textureLod(sPrevPassColor, vec3(V_BACKDROP_UV, V_BACKDROP_LAYER), 0.0);
|
||||
vec4 Cs = textureLod(sPrevPassColor, vec3(V_SRC_UV, V_SRC_LAYER), 0.0);
|
||||
|
||||
// The mix-blend-mode functions assume no premultiplied alpha
|
||||
if (Cb.a != 0.0) {
|
||||
|
@ -225,7 +231,7 @@ Fragment mix_blend_brush_fs() {
|
|||
// Return yellow if none of the branches match (shouldn't happen).
|
||||
vec4 result = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
|
||||
switch (vOp) {
|
||||
switch (V_OP) {
|
||||
case MixBlendMode_Multiply:
|
||||
result.rgb = Multiply(Cb.rgb, Cs.rgb);
|
||||
break;
|
||||
|
@ -289,3 +295,10 @@ Fragment mix_blend_brush_fs() {
|
|||
return Fragment(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Undef macro names that could be re-defined by other shaders.
|
||||
#undef V_SRC_UV
|
||||
#undef V_SRC_LAYER
|
||||
#undef V_BACKDROP_UV
|
||||
#undef V_BACKDROP_LAYER
|
||||
#undef V_OP
|
||||
|
|
|
@ -28,6 +28,14 @@ int vecs_per_brush(int brush_kind);
|
|||
#include brush_blend
|
||||
#endif
|
||||
|
||||
#undef VECS_PER_SPECIFIC_BRUSH
|
||||
#undef WR_BRUSH_VS_FUNCTION
|
||||
#undef WR_BRUSH_FS_FUNCTION
|
||||
|
||||
#ifdef WR_FEATURE_MIX_BLEND_BRUSH
|
||||
#include brush_mix_blend
|
||||
#endif
|
||||
|
||||
int vecs_per_brush(int brush_kind) {
|
||||
int result;
|
||||
switch (brush_kind) {
|
||||
|
@ -48,6 +56,12 @@ int vecs_per_brush(int brush_kind) {
|
|||
result = VECS_PER_BLEND_BRUSH;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef WR_FEATURE_MIX_BLEND_BRUSH
|
||||
case BRUSH_KIND_MIX_BLEND:
|
||||
result = VECS_PER_MIX_BLEND_BRUSH;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Загрузка…
Ссылка в новой задаче