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

Commit 7f5265eb authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Added jni and SurfaceControl methods for native setColor"

parents 8c238c5a 0dd03f55
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.view;

import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;

import android.annotation.Size;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
import android.graphics.Rect;
@@ -65,6 +66,7 @@ public class SurfaceControl {
    private static native void nativeSetSize(long nativeObject, int w, int h);
    private static native void nativeSetTransparentRegionHint(long nativeObject, Region region);
    private static native void nativeSetAlpha(long nativeObject, float alpha);
    private static native void nativeSetColor(long nativeObject, float[] color);
    private static native void nativeSetMatrix(long nativeObject, float dsdx, float dtdx,
            float dtdy, float dsdy);
    private static native void nativeSetFlags(long nativeObject, int flags, int mask);
@@ -552,6 +554,15 @@ public class SurfaceControl {
        nativeSetAlpha(mNativeObject, alpha);
    }

    /**
     * Sets a color for the Surface.
     * @param color A float array with three values to represent r, g, b in range [0..1]
     */
    public void setColor(@Size(3) float[] color) {
        checkNotReleased();
        nativeSetColor(mNativeObject, color);
    }

    public void setMatrix(float dsdx, float dtdx, float dtdy, float dsdy) {
        checkNotReleased();
        nativeSetMatrix(mNativeObject, dsdx, dtdx, dtdy, dsdy);
+12 −0
Original line number Diff line number Diff line
@@ -373,6 +373,16 @@ static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat
    }
}

static void nativeSetColor(JNIEnv* env, jclass clazz, jlong nativeObject, jfloatArray fColor) {
    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    float* floatColors = env->GetFloatArrayElements(fColor, 0);
    half3 color(floatColors[0], floatColors[1], floatColors[2]);
    status_t err = ctrl->setColor(color);
    if (err < 0 && err != NO_INIT) {
        doThrowIAE(env);
    }
}

static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject,
        jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) {
    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
@@ -812,6 +822,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetTransparentRegionHint },
    {"nativeSetAlpha", "(JF)V",
            (void*)nativeSetAlpha },
    {"nativeSetColor", "(J[F)V",
            (void*)nativeSetColor },
    {"nativeSetMatrix", "(JFFFF)V",
            (void*)nativeSetMatrix },
    {"nativeSetFlags", "(JII)V",