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

Commit 78b8ef3f authored by Jamie Gennis's avatar Jamie Gennis
Browse files

Surface: replace active rect with window crop

This change replaces the setActiveRectCrop method on Surface, which was called
from app processes, with the setWindowCrop method that is to be called from the
window manager.

Bug: 6299171
Change-Id: Ica51efcd8c488a526e7013b83d80df4856694519
parent 304521b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -511,7 +511,7 @@ public class Surface implements Parcelable {
    /** @hide */
    public native   void setFlags(int flags, int mask);
    /** @hide */
    public native   void setActiveRect(Rect activeRect);
    public native   void setWindowCrop(Rect crop);


   
+0 −9
Original line number Diff line number Diff line
@@ -263,7 +263,6 @@ public final class ViewRootImpl implements ViewParent,
    final Rect mPendingVisibleInsets = new Rect();
    final Rect mPendingContentInsets = new Rect();
    final Rect mPendingSystemInsets = new Rect();
    final Rect mActiveRect = new Rect();
    final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
            = new ViewTreeObserver.InternalInsetsInfo();

@@ -1698,14 +1697,6 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        if (activeRectChanged && mSurface.isValid()) {
            mActiveRect.set(attachInfo.mSystemInsets.left, attachInfo.mSystemInsets.top,
                    mWidth - attachInfo.mSystemInsets.right,
                    mHeight - attachInfo.mSystemInsets.bottom);
            //Log.i(TAG, "Active rect " + mWindowAttributes.getTitle() + ": " + mActiveRect);
            mSurface.setActiveRect(mActiveRect);
        }

        final boolean didLayout = layoutRequested && !mStopped;
        boolean triggerGlobalLayoutListener = didLayout
                || attachInfo.mRecomputeGlobalAttributes;
+23 −27
Original line number Diff line number Diff line
@@ -345,32 +345,6 @@ 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));
@@ -773,6 +747,28 @@ static void Surface_setFreezeTint(
    }
}

static void Surface_setWindowCrop(JNIEnv* env, jobject thiz, jobject crop)
{
    const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz));
    if (surface == 0) return;

    Rect nativeCrop;
    if (crop) {
        nativeCrop.left  = env->GetIntField(crop, ro.l);
        nativeCrop.top   = env->GetIntField(crop, ro.t);
        nativeCrop.right = env->GetIntField(crop, ro.r);
        nativeCrop.bottom= env->GetIntField(crop, ro.b);
    } else {
        nativeCrop.left = nativeCrop.top = nativeCrop.right =
                nativeCrop.bottom = 0;
    }

    status_t err = surface->setCrop(nativeCrop);
    if (err<0 && err!=NO_INIT) {
        doThrowIAE(env);
    }
}

// ----------------------------------------------------------------------------

static void Surface_copyFrom(
@@ -915,7 +911,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 },
    {"setWindowCrop",       "(Landroid/graphics/Rect;)V", (void*)Surface_setWindowCrop },
};

void nativeClassInit(JNIEnv* env, jclass clazz)