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

Commit

Permalink
8255149: Lanai: DrawImage/IncorrectAlphaConversionBicubic.java failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Ushakov committed Oct 21, 2020
1 parent e47e233 commit fbc066e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/common.h
Expand Up @@ -102,6 +102,7 @@ struct TxtFrameUniforms {
vector_float4 color;
int mode; // NOTE: consider to use bit fields
int isSrcOpaque;
int isSrcPremult;
int isDstOpaque;
float extraAlpha;
};
Expand Down
4 changes: 4 additions & 0 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/shaders.metal
Expand Up @@ -177,6 +177,10 @@ fragment half4 frag_txt(
return half4(c.r, c.g, c.b , c.a);
}

if (uniforms.isSrcPremult) {
pixelColor.rgb /= srcA;
}

return half4(pixelColor.r,
pixelColor.g,
pixelColor.b, srcA)*uniforms.extraAlpha;
Expand Down
Expand Up @@ -858,7 +858,9 @@ 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, extraAlpha};
struct TxtFrameUniforms uf = {
RGBA_TO_V4(color), mode, srcFlags->isOpaque, srcFlags->isPremultiplied,
dstFlags->isOpaque, extraAlpha};
[encoder setFragmentBytes:&uf length:sizeof(uf) atIndex:FrameUniformBuffer];

setSampler(encoder, interpolation, repeat);
Expand Down

0 comments on commit fbc066e

Please sign in to comment.