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

Commit 4a7d7801 authored by Sanjeev Jakkilinki's avatar Sanjeev Jakkilinki Committed by Linux Build Service Account
Browse files

Display: Dirty region propagation

Pass Dirty region values from HW renderer to Surface Texture.

Conflicts:
        core/java/android/view/ViewRootImpl.java

Change-Id: Ibd121ed398a1319d3daf26f9fd39a03323bba666
parent 1b641622
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class Surface implements Parcelable {
    private static native void nativeWriteToParcel(long nativeObject, Parcel dest);

    private static native void nativeAllocateBuffers(long nativeObject);
    private static native void nativeSetDirtyRegion(long nativeObject, Rect dirty);

    public static final Parcelable.Creator<Surface> CREATOR =
            new Parcelable.Creator<Surface>() {
@@ -160,6 +161,16 @@ public class Surface implements Parcelable {
        }
    }

    /**
     * Set dirty region passed from HW renderer.
     * @hide
     */
    public void setDirtyRegion(Rect dirty) {
        if (mNativeObject != 0) {
            nativeSetDirtyRegion(mNativeObject,dirty);
        }
    }

    /**
     * Release the local reference to the server-side surface.
     * Always call release() when you're done with a Surface.
+7 −0
Original line number Diff line number Diff line
@@ -2486,6 +2486,13 @@ public final class ViewRootImpl implements ViewParent,
                }
                mResizeAlpha = resizeAlpha;

                // sometimes we get the dirty rect as null
                // and also its better to check the surface
                // validity to avoid any crash.
                if(mSurface.isValid() && dirty != null) {
                    mSurface.setDirtyRegion(dirty);
                }

                dirty.setEmpty();

                mBlockResizeBuffer = false;
+31 −0
Original line number Diff line number Diff line
@@ -187,6 +187,35 @@ static inline SkColorType convertPixelFormat(PixelFormat format) {
    }
}

static void nativeSetDirtyRegion(JNIEnv* env, jclass clazz,
        jlong nativeObject, jobject dirtyRect) {

    sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject));

    if (!isSurfaceValid(surface)) {
        doThrowIAE(env);
        return;
    }

    // get dirty region
    Region dirtyRegion;
    Rect dirty;

    dirty.left = env->GetIntField(dirtyRect, gRectClassInfo.left);
    dirty.top = env->GetIntField(dirtyRect, gRectClassInfo.top);
    dirty.right = env->GetIntField(dirtyRect, gRectClassInfo.right);
    dirty.bottom = env->GetIntField(dirtyRect, gRectClassInfo.bottom);

    if (!dirty.isEmpty()) {
       dirtyRegion.set(dirty);
    }

    status_t err = surface->setDirtyRegion(&dirtyRegion);
    if (err < 0) {
        doThrowIAE(env);
    }
}

static jlong nativeLockCanvas(JNIEnv* env, jclass clazz,
        jlong nativeObject, jobject canvasObj, jobject dirtyRectObj) {
    sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject));
@@ -375,6 +404,8 @@ static JNINativeMethod gSurfaceMethods[] = {
            (void*)nativeReadFromParcel },
    {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
            (void*)nativeWriteToParcel },
    {"nativeSetDirtyRegion", "(JLandroid/graphics/Rect;)V",
           (void*)nativeSetDirtyRegion },
};

int register_android_view_Surface(JNIEnv* env)