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

Commit e361ad7a authored by Chris Craik's avatar Chris Craik
Browse files

Remove experimental perspective projection

Change-Id: Iad688c8395ccd4673cc129973802b5f01dfb45ba
parent b2626494
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -702,9 +702,6 @@ TextureVertex* Caches::getRegionMesh() {
///////////////////////////////////////////////////////////////////////////////

void Caches::initTempProperties() {
    propertyDirtyViewport = false;
    propertyEnable3d = false;
    propertyCameraDistance = 1.0f;
    propertyAmbientShadowStrength = 25;
    propertySpotShadowStrength = 25;

@@ -715,17 +712,7 @@ void Caches::initTempProperties() {

void Caches::setTempProperty(const char* name, const char* value) {
    ALOGD("setting property %s to %s", name, value);
    if (!strcmp(name, "enable3d")) {
        propertyEnable3d = !strcmp(value, "true");
        propertyDirtyViewport = true;
        ALOGD("enable3d = %d", propertyEnable3d);
        return;
    } else if (!strcmp(name, "cameraDistance")) {
        propertyCameraDistance = fmin(fmax(atof(value), 0.001), 10);
        propertyDirtyViewport = true;
        ALOGD("camera dist multiplier = %.2f", propertyCameraDistance);
        return;
    } else if (!strcmp(name, "ambientShadowStrength")) {
    if (!strcmp(name, "ambientShadowStrength")) {
        propertyAmbientShadowStrength = atoi(value);
        ALOGD("ambient shadow strength = 0x%x out of 0xff", propertyAmbientShadowStrength);
        return;
@@ -735,17 +722,14 @@ void Caches::setTempProperty(const char* name, const char* value) {
        return;
    } else if (!strcmp(name, "lightPosXScale")) {
        propertyLightPosXScale = fmin(fmax(atof(value), 0.0), 1.0);
        propertyDirtyViewport = true;
        ALOGD("lightPos X Scale = %.2f", propertyLightPosXScale);
        return;
    }  else if (!strcmp(name, "lightPosYScale")) {
        propertyLightPosYScale = fmin(fmax(atof(value), 0.0), 1.0);
        propertyDirtyViewport = true;
        ALOGD("lightPos Y Scale = %.2f", propertyLightPosXScale);
        return;
    }  else if (!strcmp(name, "lightPosZScale")) {
        propertyLightPosZScale = fmin(fmax(atof(value), 0.0), 1.0);
        propertyDirtyViewport = true;
        ALOGD("lightPos Z Scale = %.2f", propertyLightPosXScale);
        return;
    }
+0 −3
Original line number Diff line number Diff line
@@ -356,9 +356,6 @@ public:
    // TEMPORARY properties
    void initTempProperties();
    void setTempProperty(const char* name, const char* value);
    bool propertyEnable3d;
    bool propertyDirtyViewport; // flag set when dirtying the viewport
    float propertyCameraDistance;

    // These scaling factors range from 0 to 1, to scale the light position
    // within the bound of (screenwidth, screenheight, max(screenwidth, screenheight));
+21 −35
Original line number Diff line number Diff line
@@ -160,8 +160,8 @@ void DisplayList::updateMatrix() {
                    mPivotY = mPrevHeight / 2.0f;
                }
            }
            const bool perspectiveEnabled = Caches::getInstance().propertyEnable3d;
            if (!perspectiveEnabled && (mMatrixFlags & ROTATION_3D) == 0) {

            if ((mMatrixFlags & ROTATION_3D) == 0) {
                mTransformMatrix->loadTranslate(
                        mPivotX + mTranslationX,
                        mPivotY + mTranslationY,
@@ -170,18 +170,6 @@ void DisplayList::updateMatrix() {
                mTransformMatrix->scale(mScaleX, mScaleY, 1);
                mTransformMatrix->translate(-mPivotX, -mPivotY);
            } else {
                if (perspectiveEnabled) {
                    mTransformMatrix->loadTranslate(
                            mPivotX + mTranslationX,
                            mPivotY + mTranslationY,
                            mTranslationZ);
                    mTransformMatrix->rotate(mRotationX, 1, 0, 0);
                    mTransformMatrix->rotate(mRotationY, 0, 1, 0);
                    mTransformMatrix->rotate(mRotation, 0, 0, 1);
                    mTransformMatrix->scale(mScaleX, mScaleY, 1);
                    mTransformMatrix->translate(-mPivotX, -mPivotY);
                } else {
                    /* TODO: support this old transform approach, based on API level */
                if (!mTransformCamera) {
                    mTransformCamera = new Sk3DView();
                    mTransformMatrix3D = new SkMatrix();
@@ -203,7 +191,6 @@ void DisplayList::updateMatrix() {
                mTransformMatrix->load(transformMatrix);
            }
        }
        }
        mMatrixDirty = false;
    }
}
@@ -278,8 +265,7 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, T& handler,
    }
    if (mMatrixFlags != 0) {
        if (mMatrixFlags == TRANSLATION) {
            renderer.translate(mTranslationX, mTranslationY,
                    Caches::getInstance().propertyEnable3d ? mTranslationZ : 0.0f); // TODO: necessary?
            renderer.translate(mTranslationX, mTranslationY);
        } else {
            renderer.concatMatrix(*mTransformMatrix);
        }
+0 −78
Original line number Diff line number Diff line
@@ -372,84 +372,6 @@ void Matrix4::loadMultiply(const Matrix4& u, const Matrix4& v) {
    mType = kTypeUnknown;
}

// translated from android.opengl.Matrix#frustumM()
void Matrix4::loadFrustum(float left, float top, float right, float bottom, float near, float far) {
    float r_width  = 1.0f / (right - left);
    float r_height = 1.0f / (top - bottom);
    float r_depth  = 1.0f / (near - far);
    float x = 2.0f * (near * r_width);
    float y = 2.0f * (near * r_height);
    float A = (right + left) * r_width;
    float B = (top + bottom) * r_height;
    float C = (far + near) * r_depth;
    float D = 2.0f * (far * near * r_depth);

    memset(&data, 0, sizeof(data));
    mType = kTypeUnknown;

    data[kScaleX] = x;
    data[kScaleY] = y;
    data[8] = A;
    data[9] = B;
    data[kScaleZ] = C;
    data[kTranslateZ] = D;
    data[11] = -1.0f;
}

// translated from android.opengl.Matrix#setLookAtM()
void Matrix4::loadLookAt(float eyeX, float eyeY, float eyeZ,
        float centerX, float centerY, float centerZ,
        float upX, float upY, float upZ) {
    float fx = centerX - eyeX;
    float fy = centerY - eyeY;
    float fz = centerZ - eyeZ;

    // Normalize f
    float rlf = 1.0f / sqrt(fx*fx + fy*fy + fz*fz);
    fx *= rlf;
    fy *= rlf;
    fz *= rlf;

    // compute s = f x up (x means "cross product")
    float sx = fy * upZ - fz * upY;
    float sy = fz * upX - fx * upZ;
    float sz = fx * upY - fy * upX;

    // and normalize s
    float rls = 1.0f / sqrt(sx*sx + sy*sy + sz*sz);
    sx *= rls;
    sy *= rls;
    sz *= rls;

    // compute u = s x f
    float ux = sy * fz - sz * fy;
    float uy = sz * fx - sx * fz;
    float uz = sx * fy - sy * fx;

    mType = kTypeUnknown;
    data[0] = sx;
    data[1] = ux;
    data[2] = -fx;
    data[3] = 0.0f;

    data[4] = sy;
    data[5] = uy;
    data[6] = -fy;
    data[7] = 0.0f;

    data[8] = sz;
    data[9] = uz;
    data[10] = -fz;
    data[11] = 0.0f;

    data[12] = 0.0f;
    data[13] = 0.0f;
    data[14] = 0.0f;
    data[15] = 1.0f;

    translate(-eyeX, -eyeY, -eyeZ);
}

void Matrix4::loadOrtho(float left, float right, float bottom, float top, float near, float far) {
    loadIdentity();

+0 −4
Original line number Diff line number Diff line
@@ -129,10 +129,6 @@ public:
    void loadRotate(float angle);
    void loadRotate(float angle, float x, float y, float z);
    void loadMultiply(const Matrix4& u, const Matrix4& v);
    void loadFrustum(float left, float top, float right, float bottom, float near, float far);
    void loadLookAt(float eyeX, float eyeY, float eyeZ,
            float centerX, float centerY, float centerZ,
            float upX, float upY, float upZ);

    void loadOrtho(float left, float right, float bottom, float top, float near, float far);

Loading