Constant sparkle scale

Drawables from different themes are yielding different densities.
Framework themes are returning 160 (DENSITY_MEDIUM), while AppCompat
is reporting 420 (DENSITY_420.)

This is causing the sparkles to have completely different sizes on
the same device, which is wrong.

Fixes: 189236372
Test: manual
Change-Id: Ia79e360123cf740aaba85d5348f07604c2b39026
This commit is contained in:
Lucas Dupin
2021-05-26 09:20:27 -07:00
parent 1cbeefce09
commit 9f6fb354e8
2 changed files with 3 additions and 4 deletions

View File

@@ -975,7 +975,7 @@ public class RippleDrawable extends LayerDrawable {
shader.setColor(color, effectColor);
shader.setOrigin(cx, cy);
shader.setTouch(x, y);
shader.setResolution(w, h, mState.mDensity);
shader.setResolution(w, h);
shader.setNoisePhase(noisePhase);
shader.setRadius(radius);
shader.setProgress(.0f);

View File

@@ -20,7 +20,6 @@ import android.annotation.ColorInt;
import android.graphics.Color;
import android.graphics.RuntimeShader;
import android.graphics.Shader;
import android.util.DisplayMetrics;
final class RippleShader extends RuntimeShader {
private static final String SHADER_UNIFORMS = "uniform vec2 in_origin;\n"
@@ -204,8 +203,8 @@ final class RippleShader extends RuntimeShader {
sparkleColor.green(), sparkleColor.blue(), sparkleColor.alpha()});
}
public void setResolution(float w, float h, int density) {
final float densityScale = density * DisplayMetrics.DENSITY_DEFAULT_SCALE * 0.8f;
public void setResolution(float w, float h) {
final float densityScale = 2.1f;
setUniform("in_resolutionScale", new float[] {1f / w, 1f / h});
setUniform("in_noiseScale", new float[] {densityScale / w, densityScale / h});
}