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

Commit 80193e77 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "add a (hidden) api on Surface to query if the consumer is running behind the producer"

parents ec046784 c14bacf1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -323,6 +323,15 @@ public class Surface implements Parcelable {
        return mSurfaceGenerationId;
    }


    /**
     * Whether the consumer of this Surface is running behind the producer;
     * that is, isConsumerRunningBehind() returns true if the consumer is more
     * than one buffer ahead of the producer.
     * @hide
     */
    public native boolean isConsumerRunningBehind();

    /**
     * A Canvas class that can handle the compatibility mode. This does two
     * things differently.
+14 −0
Original line number Diff line number Diff line
@@ -316,6 +316,19 @@ static jboolean Surface_isValid(JNIEnv* env, jobject clazz)
    return Surface::isValid(surface) ? JNI_TRUE : JNI_FALSE;
}

static jboolean Surface_isConsumerRunningBehind(JNIEnv* env, jobject clazz)
{
    int value = 0;
    const sp<Surface>& surface(getSurface(env, clazz));
    if (!Surface::isValid(surface)) {
        doThrowIAE(env);
        return 0;
    }
    ANativeWindow* anw = static_cast<ANativeWindow *>(surface.get());
    anw->query(anw, NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND, &value);
    return (jboolean)value;
}

static inline SkBitmap::Config convertPixelFormat(PixelFormat format)
{
    /* note: if PIXEL_FORMAT_RGBX_8888 means that all alpha bytes are 0xFF, then
@@ -875,6 +888,7 @@ static JNINativeMethod gSurfaceMethods[] = {
    {"setFreezeTint",       "(I)V",  (void*)Surface_setFreezeTint },
    {"readFromParcel",      "(Landroid/os/Parcel;)V", (void*)Surface_readFromParcel },
    {"writeToParcel",       "(Landroid/os/Parcel;I)V", (void*)Surface_writeToParcel },
    {"isConsumerRunningBehind", "()Z", (void*)Surface_isConsumerRunningBehind },
};

void nativeClassInit(JNIEnv* env, jclass clazz)