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

Commit b40696cc authored by Jamie Gennis's avatar Jamie Gennis
Browse files

Surface: add JNI plumbing for setActiveRect.

Bug: 6299171
Change-Id: If26e63ebe7def645626af251bed899ff9389f8e5
parent 459e459e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -510,6 +510,8 @@ public class Surface implements Parcelable {
    public native   void setFreezeTint(int tint);
    /** @hide */
    public native   void setFlags(int flags, int mask);
    /** @hide */
    public native   void setActiveRect(Rect activeRect);


   
+27 −0
Original line number Diff line number Diff line
@@ -345,6 +345,32 @@ static inline SkBitmap::Config convertPixelFormat(PixelFormat format)
    }
}

static void Surface_setActiveRect(JNIEnv* env, jobject thiz, jobject activeRect)
{
    const sp<Surface>& surface(getSurface(env, thiz));
    if (!Surface::isValid(surface)) {
        doThrowIAE(env);
        return;
    }

    android_native_rect_t nativeRect;
    if (activeRect) {
        nativeRect.left  = env->GetIntField(activeRect, ro.l);
        nativeRect.top   = env->GetIntField(activeRect, ro.t);
        nativeRect.right = env->GetIntField(activeRect, ro.r);
        nativeRect.bottom= env->GetIntField(activeRect, ro.b);
    } else {
        doThrowIAE(env, "activeRect may not be null");
        return;
    }

    int err = native_window_set_active_rect(surface.get(), &nativeRect);
    if (err != NO_ERROR) {
        doThrowRE(env, String8::format(
                "Surface::setActiveRect returned an error: %d", err).string());
    }
}

static jobject Surface_lockCanvas(JNIEnv* env, jobject clazz, jobject dirtyRect)
{
    const sp<Surface>& surface(getSurface(env, clazz));
@@ -889,6 +915,7 @@ static JNINativeMethod gSurfaceMethods[] = {
    {"readFromParcel",      "(Landroid/os/Parcel;)V", (void*)Surface_readFromParcel },
    {"writeToParcel",       "(Landroid/os/Parcel;I)V", (void*)Surface_writeToParcel },
    {"isConsumerRunningBehind", "()Z", (void*)Surface_isConsumerRunningBehind },
    {"setActiveRect",       "(Landroid/graphics/Rect;)V", (void*)Surface_setActiveRect },
};

void nativeClassInit(JNIEnv* env, jclass clazz)