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

Commit 146a1f0c authored by ztenghui's avatar ztenghui Committed by Android (Google) Code Review
Browse files

Merge "Separate spot and ambient shadow strength setting"

parents 060f509f ef94c6f8
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -685,7 +685,8 @@ void Caches::initTempProperties() {
    propertyDirtyViewport = false;
    propertyDirtyViewport = false;
    propertyEnable3d = false;
    propertyEnable3d = false;
    propertyCameraDistance = 1.0f;
    propertyCameraDistance = 1.0f;
    propertyShadowStrength = 0x3f;
    propertyAmbientShadowStrength = 0x3f;
    propertySpotShadowStrength = 0x3f;


    propertyLightPosXScale = 0.5f;
    propertyLightPosXScale = 0.5f;
    propertyLightPosYScale = 0.0f;
    propertyLightPosYScale = 0.0f;
@@ -704,9 +705,13 @@ void Caches::setTempProperty(const char* name, const char* value) {
        propertyDirtyViewport = true;
        propertyDirtyViewport = true;
        ALOGD("camera dist multiplier = %.2f", propertyCameraDistance);
        ALOGD("camera dist multiplier = %.2f", propertyCameraDistance);
        return;
        return;
    } else if (!strcmp(name, "shadowStrength")) {
    } else if (!strcmp(name, "ambientShadowStrength")) {
        propertyShadowStrength = atoi(value);
        propertyAmbientShadowStrength = atoi(value);
        ALOGD("shadow strength = 0x%x out of 0xff", propertyShadowStrength);
        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;
        return;
    } else if (!strcmp(name, "lightPosXScale")) {
    } else if (!strcmp(name, "lightPosXScale")) {
        propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0);
        propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0);
+2 −1
Original line number Original line Diff line number Diff line
@@ -367,7 +367,8 @@ public:
    float propertyLightPosXScale;
    float propertyLightPosXScale;
    float propertyLightPosYScale;
    float propertyLightPosYScale;
    float propertyLightPosZScale;
    float propertyLightPosZScale;
    int propertyShadowStrength;
    int propertyAmbientShadowStrength;
    int propertySpotShadowStrength;


private:
private:
    enum OverdrawColorSet {
    enum OverdrawColorSet {
+19 −14
Original line number Original line Diff line number Diff line
@@ -3214,7 +3214,6 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
    mCaches.enableScissor();
    mCaches.enableScissor();


    SkPaint paint;
    SkPaint paint;
    paint.setARGB(mCaches.propertyShadowStrength, 0, 0, 0);
    paint.setAntiAlias(true); // want to use AlphaVertex
    paint.setAntiAlias(true); // want to use AlphaVertex


    // tessellate caster outline into a 2d polygon
    // tessellate caster outline into a 2d polygon
@@ -3238,11 +3237,16 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
    }
    }


    // draw caster's shadows
    // draw caster's shadows
    if (mCaches.propertyAmbientShadowStrength > 0) {
        paint.setARGB(mCaches.propertyAmbientShadowStrength, 0, 0, 0);
        VertexBuffer ambientShadowVertexBuffer;
        VertexBuffer ambientShadowVertexBuffer;
        ShadowTessellator::tessellateAmbientShadow(casterPolygon, casterVertexCount,
        ShadowTessellator::tessellateAmbientShadow(casterPolygon, casterVertexCount,
                ambientShadowVertexBuffer);
                ambientShadowVertexBuffer);
        drawVertexBuffer(ambientShadowVertexBuffer, &paint);
        drawVertexBuffer(ambientShadowVertexBuffer, &paint);
    }


    if (mCaches.propertySpotShadowStrength > 0) {
        paint.setARGB(mCaches.propertySpotShadowStrength, 0, 0, 0);
        VertexBuffer spotShadowVertexBuffer;
        VertexBuffer spotShadowVertexBuffer;
        Vector3 lightPosScale(mCaches.propertyLightPosXScale,
        Vector3 lightPosScale(mCaches.propertyLightPosXScale,
                mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale);
                mCaches.propertyLightPosYScale, mCaches.propertyLightPosZScale);
@@ -3251,6 +3255,7 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp
                spotShadowVertexBuffer);
                spotShadowVertexBuffer);


        drawVertexBuffer(spotShadowVertexBuffer, &paint);
        drawVertexBuffer(spotShadowVertexBuffer, &paint);
    }


    return DrawGlInfo::kStatusDrew;
    return DrawGlInfo::kStatusDrew;
}
}