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

Commit 959c91f7 authored by Romain Guy's avatar Romain Guy
Browse files

Bunch of fixes.

Fixes memory leak, fixes multiple context support, fix 3d transforms.

Change-Id: I7462cfbc57857dbd4de4e76b9d4cba58a1bce77b
parent 943fbb4f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -300,7 +300,6 @@ public abstract class HardwareRenderer {
             */
            if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
                throw new RuntimeException("eglMakeCurrent failed");
                
            }

            return mEglContext.getGL();
@@ -374,6 +373,15 @@ public abstract class HardwareRenderer {
                attachInfo.mIgnoreDirtyState = true;
                view.mPrivateFlags |= View.DRAWN;

                // TODO: Don't check the current context when we have one per UI thread
                // TODO: Use a threadlocal flag to know whether the surface has changed
                if (mEgl.eglGetCurrentContext() != mEglContext ||
                        mEgl.eglGetCurrentSurface(EGL10.EGL_DRAW) != mEglSurface) {
                    if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
                        throw new RuntimeException("eglMakeCurrent failed");
                    }
                }

                onPreDraw();

                Canvas canvas = mCanvas;
+10 −2
Original line number Diff line number Diff line
@@ -160,7 +160,9 @@ OpenGLRenderer::~OpenGLRenderer() {
    mTextureCache.clear();
    mLayerCache.clear();
    mGradientCache.clear();
    mPathCache.clear();
    mPatchCache.clear();
    mProgramCache.clear();
}

///////////////////////////////////////////////////////////////////////////////
@@ -410,8 +412,14 @@ const Rect& OpenGLRenderer::getClipBounds() {
}

bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) {
    Rect r(left, top, right, bottom);
    mSnapshot->transform.mapRect(r);
    SkRect sr;
    sr.set(left, top, right, bottom);

    SkMatrix m;
    mSnapshot->transform.copyTo(m);
    m.mapRect(&sr);

    Rect r(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom);
    return !mSnapshot->clipRect.intersects(r);
}

+17 −4
Original line number Diff line number Diff line
@@ -96,9 +96,14 @@ public:
    bool clip(float left, float top, float right, float bottom, SkRegion::Op op) {
        bool clipped = false;

        Rect r(left, top, right, bottom);
        transform.mapRect(r);
        SkRect sr;
        sr.set(left, top, right, bottom);

        SkMatrix m;
        transform.copyTo(m);
        m.mapRect(&sr);

        Rect r(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom);
        switch (op) {
            case SkRegion::kDifference_Op:
                break;
@@ -137,8 +142,16 @@ public:
        if (flags & Snapshot::kFlagDirtyLocalClip) {
            mat4 inverse;
            inverse.loadInverse(transform);
            localClip.set(clipRect);
            inverse.mapRect(localClip);

            SkRect sr;
            sr.set(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);

            SkMatrix m;
            inverse.copyTo(m);
            m.mapRect(&sr);

            localClip.set(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom);

            flags &= ~Snapshot::kFlagDirtyLocalClip;
        }
        return localClip;