summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/SurfaceControl.java33
-rw-r--r--core/java/android/view/Window.java26
-rw-r--r--core/java/android/view/WindowManager.java47
-rw-r--r--core/jni/android_view_SurfaceControl.cpp41
-rw-r--r--core/res/res/values/cm_symbols.xml4
-rw-r--r--core/res/res/values/config.xml4
6 files changed, 155 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 584fe76..e839468 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -58,6 +58,11 @@ public class SurfaceControl {
private static native void nativeSetWindowCrop(long nativeObject, int l, int t, int r, int b);
private static native void nativeSetLayerStack(long nativeObject, int layerStack);
+ private static native void nativeSetBlur(long nativeObject, float blur);
+ private static native void nativeSetBlurMaskSurface(long nativeObject, long maskLayerNativeObject);
+ private static native void nativeSetBlurMaskSampling(long nativeObject, int blurMaskSampling);
+ private static native void nativeSetBlurMaskAlphaThreshold(long nativeObject, float alpha);
+
private static native boolean nativeClearContentFrameStats(long nativeObject);
private static native boolean nativeGetContentFrameStats(long nativeObject, WindowContentFrameStats outStats);
private static native boolean nativeClearAnimationFrameStats();
@@ -170,6 +175,11 @@ public class SurfaceControl {
public static final int FX_SURFACE_NORMAL = 0x00000000;
/**
+ * Surface creation flag: Creates a blur surface.
+ */
+ public static final int FX_SURFACE_BLUR = 0x00010000;
+
+ /**
* Surface creation flag: Creates a Dim surface.
* Everything behind this surface is dimmed by the amount specified
* in {@link #setAlpha}. It is an error to lock a Dim surface, since it
@@ -384,6 +394,29 @@ public class SurfaceControl {
nativeSetSize(mNativeObject, w, h);
}
+ public void setBlur(float blur) {
+ checkNotReleased();
+ nativeSetBlur(mNativeObject, blur);
+ }
+
+ public void setBlurMaskSurface(SurfaceControl maskSurface) {
+ checkNotReleased();
+ if (maskSurface != null) {
+ maskSurface.checkNotReleased();
+ }
+ nativeSetBlurMaskSurface(mNativeObject, maskSurface == null ? 0:maskSurface.mNativeObject);
+ }
+
+ public void setBlurMaskSampling(int blurMaskSampling) {
+ checkNotReleased();
+ nativeSetBlurMaskSampling(mNativeObject, blurMaskSampling);
+ }
+
+ public void setBlurMaskAlphaThreshold(float alpha) {
+ checkNotReleased();
+ nativeSetBlurMaskAlphaThreshold(mNativeObject, alpha);
+ }
+
public void hide() {
checkNotReleased();
nativeSetFlags(mNativeObject, SURFACE_HIDDEN, SURFACE_HIDDEN);
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index 0b26175..2150d33 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -199,6 +199,7 @@ public abstract class Window {
private boolean mHaveWindowFormat = false;
private boolean mHaveDimAmount = false;
+ private boolean mHaveBlurAmount = false;
private int mDefaultWindowFormat = PixelFormat.OPAQUE;
private boolean mHasSoftInputMode = false;
@@ -818,6 +819,13 @@ public abstract class Window {
setPrivateFlags(flags, flags);
}
+ /** @hide */
+ public void setBlurMaskAlphaThreshold(float alpha) {
+ final WindowManager.LayoutParams attrs = getAttributes();
+ attrs.blurMaskAlphaThreshold = alpha;
+ dispatchWindowAttributesChanged(attrs);
+ }
+
/**
* Convenience function to clear the flag bits as specified in flags, as
* per {@link #setFlags}.
@@ -899,6 +907,19 @@ public abstract class Window {
}
/**
+ * Set the amount of blur behind the window when using
+ * {@link WindowManager.LayoutParams#FLAG_BLUR_BEHIND}.
+ * This feature may not be supported by all devices.
+ * {@hide}
+ */
+ public void setBlurAmount(float amount) {
+ final WindowManager.LayoutParams attrs = getAttributes();
+ attrs.blurAmount = amount;
+ mHaveBlurAmount = true;
+ dispatchWindowAttributesChanged(attrs);
+ }
+
+ /**
* Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
* layout params you give here should generally be from values previously
* retrieved with {@link #getAttributes()}; you probably do not want to
@@ -1408,6 +1429,11 @@ public abstract class Window {
return mHaveDimAmount;
}
+ /** @hide */
+ protected boolean haveBlurAmount() {
+ return mHaveBlurAmount;
+ }
+
public abstract void setChildDrawable(int featureId, Drawable drawable);
public abstract void setChildInt(int featureId, int value);
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 9263875..6cb27cc 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1134,6 +1134,19 @@ public interface WindowManager extends ViewManager {
public static final int PRIVATE_FLAG_PREVENT_POWER_KEY = 0x20000000;
/**
+ * Window flag: adding additional blur layer and set this as masking layer
+ * {@hide}
+ */
+ public static final int PRIVATE_FLAG_BLUR_WITH_MASKING = 0x40000000;
+
+ /**
+ * Window flag: adding additional blur layer and set this as masking layer.
+ * This is faster and ugglier than non-scaled version.
+ * {@hide}
+ */
+ public static final int PRIVATE_FLAG_BLUR_WITH_MASKING_SCALED = 0x80000000;
+
+ /**
* Control flags that are private to the platform.
* @hide
*/
@@ -1395,6 +1408,15 @@ public interface WindowManager extends ViewManager {
public float dimAmount = 1.0f;
/**
+ * When {@link #FLAG_BLUR_BEHIND} is set, this is the amount of blur
+ * to apply. Range is from 1.0 for maximum to 0.0 for no
+ * blur.
+ * @hide
+ */
+ public float blurAmount = 1.0f;
+
+
+ /**
* Default value for {@link #screenBrightness} and {@link #buttonBrightness}
* indicating that the brightness value is not overridden for this window
* and normal brightness policy should be used.
@@ -1587,6 +1609,14 @@ public interface WindowManager extends ViewManager {
*/
public long userActivityTimeout = -1;
+ /**
+ * Threshold value that blur masking layer uses to determine whether
+ * to use or discard the blurred color.
+ * Value should be between 0.0 and 1.0
+ * @hide
+ */
+ public float blurMaskAlphaThreshold = 0.0f;
+
public LayoutParams() {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = TYPE_APPLICATION;
@@ -1673,6 +1703,7 @@ public interface WindowManager extends ViewManager {
out.writeInt(windowAnimations);
out.writeFloat(alpha);
out.writeFloat(dimAmount);
+ out.writeFloat(blurAmount);
out.writeFloat(screenBrightness);
out.writeFloat(buttonBrightness);
out.writeInt(rotationAnimation);
@@ -1693,6 +1724,7 @@ public interface WindowManager extends ViewManager {
out.writeInt(surfaceInsets.bottom);
out.writeInt(hasManualSurfaceInsets ? 1 : 0);
out.writeInt(needsMenuKey);
+ out.writeFloat(blurMaskAlphaThreshold);
}
public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -1723,6 +1755,7 @@ public interface WindowManager extends ViewManager {
windowAnimations = in.readInt();
alpha = in.readFloat();
dimAmount = in.readFloat();
+ blurAmount = in.readFloat();
screenBrightness = in.readFloat();
buttonBrightness = in.readFloat();
rotationAnimation = in.readInt();
@@ -1743,6 +1776,7 @@ public interface WindowManager extends ViewManager {
surfaceInsets.bottom = in.readInt();
hasManualSurfaceInsets = in.readInt() != 0;
needsMenuKey = in.readInt();
+ blurMaskAlphaThreshold = in.readFloat();
}
@SuppressWarnings({"PointlessBitwiseExpression"})
@@ -1782,6 +1816,10 @@ public interface WindowManager extends ViewManager {
/** {@hide} */
public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
/** {@hide} */
+ public static final int BLUR_AMOUNT_CHANGED = 1 << 29;
+ /** {@hide} */
+ public static final int BLUR_MASK_ALPHA_THRESHOLD_CHANGED = 1 << 30;
+ /** {@hide} */
public static final int EVERYTHING_CHANGED = 0xffffffff;
// internal buffer to backup/restore parameters under compatibility mode.
@@ -1876,6 +1914,10 @@ public interface WindowManager extends ViewManager {
dimAmount = o.dimAmount;
changes |= DIM_AMOUNT_CHANGED;
}
+ if (blurAmount != o.blurAmount) {
+ blurAmount = o.blurAmount;
+ changes |= BLUR_AMOUNT_CHANGED;
+ }
if (screenBrightness != o.screenBrightness) {
screenBrightness = o.screenBrightness;
changes |= SCREEN_BRIGHTNESS_CHANGED;
@@ -1941,6 +1983,11 @@ public interface WindowManager extends ViewManager {
changes |= NEEDS_MENU_KEY_CHANGED;
}
+ if (blurMaskAlphaThreshold != o.blurMaskAlphaThreshold) {
+ blurMaskAlphaThreshold = o.blurMaskAlphaThreshold;
+ changes |= BLUR_MASK_ALPHA_THRESHOLD_CHANGED;
+ }
+
return changes;
}
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 20352eb..7156c0f 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -316,6 +316,39 @@ static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, j
}
}
+static void nativeSetBlur(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat blur) {
+ SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
+ status_t err = ctrl->setBlur(blur);
+ if (err < 0 && err != NO_INIT) {
+ doThrowIAE(env);
+ }
+}
+
+static void nativeSetBlurMaskSurface(JNIEnv* env, jclass clazz, jlong nativeObject, jlong maskLayerNativeObject) {
+ SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
+ SurfaceControl* const maskLayer = reinterpret_cast<SurfaceControl *>(maskLayerNativeObject);
+ status_t err = ctrl->setBlurMaskSurface(maskLayer);
+ if (err < 0 && err != NO_INIT) {
+ doThrowIAE(env);
+ }
+}
+
+static void nativeSetBlurMaskSampling(JNIEnv* env, jclass clazz, jlong nativeObject, jint blurMaskSampling) {
+ SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
+ status_t err = ctrl->setBlurMaskSampling(blurMaskSampling);
+ if (err < 0 && err != NO_INIT) {
+ doThrowIAE(env);
+ }
+}
+
+static void nativeSetBlurMaskAlphaThreshold(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) {
+ SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
+ status_t err = ctrl->setBlurMaskAlphaThreshold(alpha);
+ if (err < 0 && err != NO_INIT) {
+ doThrowIAE(env);
+ }
+}
+
static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) {
sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id));
return javaObjectForIBinder(env, token);
@@ -614,6 +647,14 @@ static JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetWindowCrop },
{"nativeSetLayerStack", "(JI)V",
(void*)nativeSetLayerStack },
+ {"nativeSetBlur", "(JF)V",
+ (void*)nativeSetBlur },
+ {"nativeSetBlurMaskSurface", "(JJ)V",
+ (void*)nativeSetBlurMaskSurface },
+ {"nativeSetBlurMaskSampling", "(JI)V",
+ (void*)nativeSetBlurMaskSampling },
+ {"nativeSetBlurMaskAlphaThreshold", "(JF)V",
+ (void*)nativeSetBlurMaskAlphaThreshold },
{"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
(void*)nativeGetBuiltInDisplay },
{"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
diff --git a/core/res/res/values/cm_symbols.xml b/core/res/res/values/cm_symbols.xml
index 143adc9..164594e 100644
--- a/core/res/res/values/cm_symbols.xml
+++ b/core/res/res/values/cm_symbols.xml
@@ -120,4 +120,8 @@
<java-symbol type="string" name="privacy_guard_notification_detail" />
<java-symbol type="string" name="privacy_guard_dialog_title" />
<java-symbol type="string" name="privacy_guard_dialog_summary" />
+
+ <!-- Blur effects -->
+ <java-symbol type="bool" name="config_ui_blur_enabled" />
+
</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index b2bf07a..1e7b102 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2516,4 +2516,8 @@
<!-- Allow the gesture to double tap the power button twice to start the camera while the device
is non-interactive. -->
<bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool>
+
+ <!-- Support in Surfaceflinger for blur layers.
+ NOTE: This requires additional hardware-specific code. -->
+ <bool name="config_ui_blur_enabled">false</bool>
</resources>