Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8242653: Lanai: SRC_OVER with extra alpha does not work for VI
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Ushakov committed Apr 16, 2020
1 parent 616100a commit ee7fee1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ jboolean clipDestCoords(
#ifdef TRACE_ISOBLIT
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_TRUE," [via sampling]");
#endif //TRACE_ISOBLIT
drawTex2Tex(mtlc, srcTex, dstTex, srcOps->isOpaque, dstOps->isOpaque, hint, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
drawTex2Tex(mtlc, srcTex, dstTex,
[mtlc isBlendingDisabled:srcOps->isOpaque],
dstOps->isOpaque, hint, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,10 @@ - (NSString *)getDescription {
}

- (jboolean)isBlendingDisabled:(jboolean)isSrcOpaque {
if (_compositeRule == java_awt_AlphaComposite_SRC) {
const jfloat epsilon = 0.001f;
return fabs(_extraAlpha - 1.0f) < epsilon;
}
if (_compositeRule != java_awt_AlphaComposite_SRC_OVER) {
// J2dRlsTraceLn1(J2D_TRACE_VERBOSE, "\tuse blending for rule %d", alphaCompositeRule);
return JNI_FALSE;
if (_compositeRule == java_awt_AlphaComposite_SRC ||
_compositeRule == java_awt_AlphaComposite_SRC_OVER)
{
return FLT_LT(_extraAlpha, 1.0f);
}
return isSrcOpaque;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static void setTxtUniforms(
id<MTLRenderCommandEncoder> encoder, int color, int mode, int interpolation, bool repeat, jfloat extraAlpha,
const SurfaceRasterFlags * srcFlags, const SurfaceRasterFlags * dstFlags
) {
struct TxtFrameUniforms uf = {RGBA_TO_V4(color), mode, srcFlags->isOpaque, dstFlags->isOpaque, interpolation};
struct TxtFrameUniforms uf = {RGBA_TO_V4(color), mode, srcFlags->isOpaque, dstFlags->isOpaque, extraAlpha};
[encoder setFragmentBytes:&uf length:sizeof(uf) atIndex:FrameUniformBuffer];

id<MTLSamplerState> sampler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ static void setBlendingFactors(
const SurfaceRasterFlags * srcFlags,
const SurfaceRasterFlags * dstFlags
) {
if (compositeRule == RULE_Src) {
J2dTraceLn(J2D_TRACE_VERBOSE, "set RULE_Src");
if (compositeRule == RULE_Src &&
(composite == nil || FLT_GE([composite getExtraAlpha], 1.0f))) {
J2dTraceLn(J2D_TRACE_VERBOSE, "set RULE_Src but blending is disabled because src is opaque");
return;
}

Expand All @@ -293,7 +294,7 @@ static void setBlendingFactors(
(composite == nil ||
FLT_GE([composite getExtraAlpha], 1.0f)))
{
J2dTraceLn(J2D_TRACE_VERBOSE, "rule=RULE_Src, but blending is disabled because src is opaque");
J2dTraceLn(J2D_TRACE_VERBOSE, "rule=RULE_SrcOver, but blending is disabled because src is opaque");
cad.blendingEnabled = NO;
return;
}
Expand Down

0 comments on commit ee7fee1

Please sign in to comment.