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

Commit 14a4e352 authored by ztenghui's avatar ztenghui Committed by Tenghui Zhu
Browse files

Bring back the shadow strength tweak

bug:16712006

Change-Id: Ifc0ecca139d58140b45d7d227536a53069e1d480
parent 4a8dddbf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -703,6 +703,8 @@ void Caches::initTempProperties() {
    propertyLightPosY = -1.0f;
    propertyLightPosZ = -1.0f;
    propertyAmbientRatio = -1.0f;
    propertyAmbientShadowStrength = -1;
    propertySpotShadowStrength = -1;
}

void Caches::setTempProperty(const char* name, const char* value) {
@@ -723,6 +725,14 @@ void Caches::setTempProperty(const char* name, const char* value) {
        propertyLightPosZ = fmin(fmax(atof(value), 0.0), 3000.0);
        ALOGD("lightPos Z = %.2f", propertyLightPosZ);
        return;
    } else if (!strcmp(name, "ambientShadowStrength")) {
        propertyAmbientShadowStrength = atoi(value);
        ALOGD("ambient shadow strength = 0x%x out of 0xff", propertyAmbientShadowStrength);
        return;
    } else if (!strcmp(name, "spotShadowStrength")) {
        propertySpotShadowStrength = atoi(value);
        ALOGD("spot shadow strength = 0x%x out of 0xff", propertySpotShadowStrength);
        return;
    }
    ALOGD("    failed");
}
+3 −0
Original line number Diff line number Diff line
@@ -366,6 +366,9 @@ public:
    float propertyLightPosY;
    float propertyLightPosZ;
    float propertyAmbientRatio;
    int propertyAmbientShadowStrength;
    int propertySpotShadowStrength;

private:
    enum OverdrawColorSet {
        kColorSet_Default = 0,
+13 −4
Original line number Diff line number Diff line
@@ -3166,13 +3166,22 @@ status_t OpenGLRenderer::drawShadow(float casterAlpha,
    SkPaint paint;
    paint.setAntiAlias(true); // want to use AlphaVertex

    if (ambientShadowVertexBuffer && mAmbientShadowAlpha > 0) {
        paint.setARGB(casterAlpha * mAmbientShadowAlpha, 0, 0, 0);
    // The caller has made sure casterAlpha > 0.
    float ambientShadowAlpha = mAmbientShadowAlpha;
    if (CC_UNLIKELY(mCaches.propertyAmbientShadowStrength >= 0)) {
        ambientShadowAlpha = mCaches.propertyAmbientShadowStrength;
    }
    if (ambientShadowVertexBuffer && ambientShadowAlpha > 0) {
        paint.setARGB(casterAlpha * ambientShadowAlpha, 0, 0, 0);
        drawVertexBuffer(*ambientShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
    }

    if (spotShadowVertexBuffer && mSpotShadowAlpha > 0) {
        paint.setARGB(casterAlpha * mSpotShadowAlpha, 0, 0, 0);
    float spotShadowAlpha = mSpotShadowAlpha;
    if (CC_UNLIKELY(mCaches.propertySpotShadowStrength >= 0)) {
        spotShadowAlpha = mCaches.propertySpotShadowStrength;
    }
    if (spotShadowVertexBuffer && spotShadowAlpha > 0) {
        paint.setARGB(casterAlpha * spotShadowAlpha, 0, 0, 0);
        drawVertexBuffer(*spotShadowVertexBuffer, &paint, kVertexBuffer_ShadowInterp);
    }