Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit a66358d

Browse files
dekonoplyovAlexey Ushakov
authored andcommitted
8251033: Background texture is not visible when Alpha Composite is enabled
1 parent 2f883fe commit a66358d

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/java.desktop/macosx/native/libawt_lwawt/awt/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct GradFrameUniforms {
6262
vector_float4 color1;
6363
vector_float4 color2;
6464
int isCyclic;
65+
float extraAlpha;
6566
};
6667

6768
struct LinGradFrameUniforms {
@@ -70,6 +71,7 @@ struct LinGradFrameUniforms {
7071
vector_float4 color[GRAD_MAX_FRACTIONS];
7172
int numFracts;
7273
int cycleMethod;
74+
float extraAlpha;
7375
};
7476

7577
struct RadGradFrameUniforms {
@@ -80,6 +82,7 @@ struct RadGradFrameUniforms {
8082
vector_float3 m0;
8183
vector_float3 m1;
8284
vector_float3 precalc;
85+
float extraAlpha;
8386
};
8487

8588
struct Vertex {

src/java.desktop/macosx/native/libawt_lwawt/awt/shaders.metal

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fragment half4 frag_txt_grad(GradShaderInOut in [[stage_in]],
291291
return half4(c.r*renderColor.a,
292292
c.g*renderColor.a,
293293
c.b*renderColor.a,
294-
c.a*renderColor.a);
294+
c.a*renderColor.a) * uniforms.extraAlpha;
295295
}
296296

297297
fragment half4 frag_txt_lin_grad(GradShaderInOut in [[stage_in]],
@@ -327,7 +327,7 @@ fragment half4 frag_txt_lin_grad(GradShaderInOut in [[stage_in]],
327327
return half4(c.r*renderColor.a,
328328
c.g*renderColor.a,
329329
c.b*renderColor.a,
330-
c.a*renderColor.a);
330+
c.a*renderColor.a) * uniforms.extraAlpha;
331331
}
332332

333333
fragment half4 frag_txt_rad_grad(GradShaderInOut in [[stage_in]],
@@ -367,7 +367,7 @@ fragment half4 frag_txt_rad_grad(GradShaderInOut in [[stage_in]],
367367
return half4(c.r*renderColor.a,
368368
c.g*renderColor.a,
369369
c.b*renderColor.a,
370-
c.a*renderColor.a);
370+
c.a*renderColor.a) * uniforms.extraAlpha;
371371
}
372372

373373

@@ -519,7 +519,7 @@ fragment half4 frag_grad(GradShaderInOut in [[stage_in]],
519519
}
520520
}
521521
float4 c = mix(uniforms.color1, uniforms.color2, a);
522-
return half4(c);
522+
return half4(c) * uniforms.extraAlpha;
523523
}
524524

525525
// LinGradFrameUniforms
@@ -546,7 +546,7 @@ fragment half4 frag_lin_grad(GradShaderInOut in [[stage_in]],
546546
}
547547
a = (a - n*lf)/lf;
548548
float4 c = mix(uniforms.color[n], uniforms.color[n + 1], a);
549-
return half4(c);
549+
return half4(c) * uniforms.extraAlpha;
550550
}
551551

552552
fragment half4 frag_rad_grad(GradShaderInOut in [[stage_in]],
@@ -576,7 +576,7 @@ fragment half4 frag_rad_grad(GradShaderInOut in [[stage_in]],
576576
}
577577
a = (a - n*lf)/lf;
578578
float4 c = mix(uniforms.color[n], uniforms.color[n + 1], a);
579-
return half4(c);
579+
return half4(c) * uniforms.extraAlpha;
580580
}
581581

582582

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLPaints.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ - (void)setPipelineState:(id)encoder
324324
{_p0, _p1, _p3},
325325
RGBA_TO_V4(_pixel1),
326326
RGBA_TO_V4(_pixel2),
327-
_cyclic
327+
_cyclic,
328+
[mtlc.composite getExtraAlpha]
328329
};
329330
[encoder setFragmentBytes:&uf length:sizeof(uf) atIndex:0];
330331

@@ -361,7 +362,8 @@ - (void)setXorModePipelineState:(id)encoder
361362
{_p0, _p1, _p3},
362363
RGBA_TO_V4(_pixel1 ^ xorColor),
363364
RGBA_TO_V4(_pixel2 ^ xorColor),
364-
_cyclic
365+
_cyclic,
366+
[mtlc.composite getExtraAlpha]
365367
};
366368

367369
[encoder setFragmentBytes: &uf length:sizeof(uf) atIndex:0];
@@ -466,7 +468,8 @@ - (void)setPipelineState:(id)encoder
466468
{},
467469
{},
468470
_numFracts,
469-
_cyclic
471+
_cyclic,
472+
[mtlc.composite getExtraAlpha]
470473
};
471474

472475
memcpy(uf.fract, _fract, _numFracts*sizeof(jfloat));
@@ -629,7 +632,8 @@ - (void)setPipelineState:(id)encoder
629632
_cyclic,
630633
{_m00, _m01, _m02},
631634
{_m10, _m11, _m12},
632-
{}
635+
{},
636+
[mtlc.composite getExtraAlpha]
633637
};
634638

635639
uf.precalc[0] = _focusX;

0 commit comments

Comments
 (0)