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

Commit 849ea934 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Support floating point values for layer crop" into main

parents ca62a9db c07e3ef3
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@ public final class SurfaceControl implements Parcelable {
            long nativeObject, int priority);
    private static native void nativeSetWindowCrop(long transactionObj, long nativeObject,
            int l, int t, int r, int b);
    private static native void nativeSetCrop(long transactionObj, long nativeObject,
            float l, float t, float r, float b);
    private static native void nativeSetCornerRadius(long transactionObj, long nativeObject,
            float cornerRadius);
    private static native void nativeSetBackgroundBlurRadius(long transactionObj, long nativeObject,
@@ -3451,6 +3453,29 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Bounds the surface and its children to the bounds specified. Size of the surface will be
         * ignored and only the crop and buffer size will be used to determine the bounds of the
         * surface. If no crop is specified and the surface has no buffer, the surface bounds is
         * only constrained by the size of its parent bounds.
         *
         * @param sc   SurfaceControl to set crop of.
         * @param crop Bounds of the crop to apply.
         * @return this This transaction for chaining
         * @hide
         */
        public @NonNull Transaction setCrop(@NonNull SurfaceControl sc, float top, float left,
                float bottom, float right) {
            checkPreconditions(sc);
            if (SurfaceControlRegistry.sCallStackDebuggingEnabled) {
                SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging(
                        "setCrop", this, sc, "crop={" + top + ", " + left + ", " +
                        bottom + ", " + right + "}");
            }
            nativeSetCrop(mNativeObject, sc.mNativeObject, top, left, bottom, right);
            return this;
        }

        /**
         * Sets the corner radius of a {@link SurfaceControl}.
         * @param sc SurfaceControl
+12 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include <ui/DisplayMode.h>
#include <ui/DisplayedFrameStats.h>
#include <ui/DynamicDisplayInfo.h>
#include <ui/FloatRect.h>
#include <ui/FrameStats.h>
#include <ui/GraphicTypes.h>
#include <ui/HdrCapabilities.h>
@@ -992,6 +993,15 @@ static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
    transaction->setCrop(ctrl, crop);
}

static void nativeSetCrop(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject,
                          jfloat l, jfloat t, jfloat r, jfloat b) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);

    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
    FloatRect crop(l, t, r, b);
    transaction->setCrop(ctrl, crop);
}

static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj,
         jlong nativeObject, jfloat cornerRadius) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2347,6 +2357,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetFrameRateSelectionPriority },
    {"nativeSetWindowCrop", "(JJIIII)V",
            (void*)nativeSetWindowCrop },
    {"nativeSetCrop", "(JJFFFF)V",
            (void*)nativeSetCrop },
    {"nativeSetCornerRadius", "(JJF)V",
            (void*)nativeSetCornerRadius },
    {"nativeSetBackgroundBlurRadius", "(JJI)V",