Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91a8c7c6 authored by Chris Craik's avatar Chris Craik
Browse files

Switch to cos interpolation of shadow alpha

bug:16852257

Updates default shadow opacities to compensate.

Also, update variable/constant naming related to vertex alpha.

Change-Id: I9055b4ac3c9ac305ca9d515f21b52d6aa6dc9c5c
parent ddc122ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1360,7 +1360,7 @@ please see styles_device_defaults.xml.
        <item name="lightZ">800dp</item>
        <item name="lightRadius">800dp</item>
        <item name="ambientShadowAlpha">0.06</item>
        <item name="spotShadowAlpha">0.22</item>
        <item name="spotShadowAlpha">0.16</item>
    </style>

</resources>
+4 −1
Original line number Diff line number Diff line
@@ -117,10 +117,13 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque,

        // inner ring of points
        float opacity = 1.0 / (1 + rayHeight[rayIndex] * heightFactor);
        // NOTE: Shadow alpha values are transformed when stored in alphavertices,
        // so that they can be consumed directly by gFS_Main_ApplyVertexAlphaShadowInterp
        float transformedOpacity = acos(1.0f - 2.0f * opacity);
        AlphaVertex::set(&shadowVertices[rays + rayIndex],
                intersection.x,
                intersection.y,
                opacity);
                transformedOpacity);
    }

    if (isCasterOpaque) {
+6 −6
Original line number Diff line number Diff line
@@ -1641,9 +1641,9 @@ void OpenGLRenderer::setupDrawNoTexture() {
    mCaches.disableTexCoordsVertexArray();
}

void OpenGLRenderer::setupDrawAA(bool useShadowInterp) {
    mDescription.isAA = true;
    mDescription.isShadowAA = useShadowInterp;
void OpenGLRenderer::setupDrawVertexAlpha(bool useShadowAlphaInterp) {
    mDescription.hasVertexAlpha = true;
    mDescription.useShadowAlphaInterp = useShadowAlphaInterp;
}

void OpenGLRenderer::setupDrawColor(int color, int alpha) {
@@ -2382,7 +2382,7 @@ status_t OpenGLRenderer::drawVertexBuffer(float translateX, float translateY,

    setupDraw();
    setupDrawNoTexture();
    if (isAA) setupDrawAA((displayFlags & kVertexBuffer_ShadowAA));
    if (isAA) setupDrawVertexAlpha((displayFlags & kVertexBuffer_ShadowInterp));
    setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha);
    setupDrawColorFilter(getColorFilter(paint));
    setupDrawShader(getShader(paint));
@@ -3168,12 +3168,12 @@ status_t OpenGLRenderer::drawShadow(float casterAlpha,

    if (ambientShadowVertexBuffer && mAmbientShadowAlpha > 0) {
        paint.setARGB(casterAlpha * mAmbientShadowAlpha, 0, 0, 0);
        drawVertexBuffer(*ambientShadowVertexBuffer, &paint, kVertexBuffer_ShadowAA);
        drawVertexBuffer(*ambientShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
    }

    if (spotShadowVertexBuffer && mSpotShadowAlpha > 0) {
        paint.setARGB(casterAlpha * mSpotShadowAlpha, 0, 0, 0);
        drawVertexBuffer(*spotShadowVertexBuffer, &paint, kVertexBuffer_ShadowAA);
        drawVertexBuffer(*spotShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
    }

    return DrawGlInfo::kStatusDrew;
+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ enum ClipSideFlags {

enum VertexBufferDisplayFlags {
    kVertexBuffer_Offset = 0x1,
    kVertexBuffer_ShadowAA = 0x2,
    kVertexBuffer_ShadowInterp = 0x2,
};

/**
@@ -847,7 +847,7 @@ private:
    void setupDrawWithTextureAndColor(bool isAlpha8 = false);
    void setupDrawWithExternalTexture();
    void setupDrawNoTexture();
    void setupDrawAA(bool useShadowInterp);
    void setupDrawVertexAlpha(bool useShadowAlphaInterp);
    void setupDrawColor(int color, int alpha);
    void setupDrawColor(float r, float g, float b, float a);
    void setupDrawAlpha8Color(int color, int alpha);
+8 −8
Original line number Diff line number Diff line
@@ -71,8 +71,8 @@ namespace uirenderer {
#define PROGRAM_GRADIENT_TYPE_SHIFT 33 // 2 bits for gradient type
#define PROGRAM_MODULATE_SHIFT 35

#define PROGRAM_HAS_AA_SHIFT 36
#define PROGRAM_HAS_SHADOW_AA_SHIFT 37
#define PROGRAM_HAS_VERTEX_ALPHA_SHIFT 36
#define PROGRAM_USE_SHADOW_ALPHA_INTERP_SHIFT 37

#define PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT 38
#define PROGRAM_HAS_TEXTURE_TRANSFORM_SHIFT 39
@@ -135,8 +135,8 @@ struct ProgramDescription {
    bool hasBitmap;
    bool isBitmapNpot;

    bool isAA; // drawing with a per-vertex alpha
    bool isShadowAA; // drawing per vertex alpha with shadow interpolation
    bool hasVertexAlpha;
    bool useShadowAlphaInterp;

    bool hasGradient;
    Gradient gradientType;
@@ -176,8 +176,8 @@ struct ProgramDescription {

        hasColors = false;

        isAA = false;
        isShadowAA = false;
        hasVertexAlpha = false;
        useShadowAlphaInterp = false;

        modulate = false;

@@ -264,8 +264,8 @@ struct ProgramDescription {
        key |= (framebufferMode & PROGRAM_MAX_XFERMODE) << PROGRAM_XFERMODE_FRAMEBUFFER_SHIFT;
        if (swapSrcDst) key |= PROGRAM_KEY_SWAP_SRC_DST;
        if (modulate) key |= programid(0x1) << PROGRAM_MODULATE_SHIFT;
        if (isAA) key |= programid(0x1) << PROGRAM_HAS_AA_SHIFT;
        if (isShadowAA) key |= programid(0x1) << PROGRAM_HAS_SHADOW_AA_SHIFT;
        if (hasVertexAlpha) key |= programid(0x1) << PROGRAM_HAS_VERTEX_ALPHA_SHIFT;
        if (useShadowAlphaInterp) key |= programid(0x1) << PROGRAM_USE_SHADOW_ALPHA_INTERP_SHIFT;
        if (hasExternalTexture) key |= programid(0x1) << PROGRAM_HAS_EXTERNAL_TEXTURE_SHIFT;
        if (hasTextureTransform) key |= programid(0x1) << PROGRAM_HAS_TEXTURE_TRANSFORM_SHIFT;
        if (hasGammaCorrection) key |= programid(0x1) << PROGRAM_HAS_GAMMA_CORRECTION;
Loading