Loading core/java/android/view/SurfaceControl.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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); Loading core/jni/android_view_SurfaceControl.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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", Loading Loading
core/java/android/view/SurfaceControl.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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); Loading
core/jni/android_view_SurfaceControl.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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", Loading