summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.xml57
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java5
-rw-r--r--core/java/android/view/Surface.java5
-rw-r--r--core/java/android/view/WindowManagerPolicy.java6
-rw-r--r--core/res/res/anim/wallpaper_activity_close_enter.xml30
-rw-r--r--core/res/res/anim/wallpaper_activity_close_exit.xml29
-rw-r--r--core/res/res/anim/wallpaper_activity_open_enter.xml29
-rw-r--r--core/res/res/anim/wallpaper_activity_open_exit.xml30
-rw-r--r--core/res/res/values/attrs.xml50
-rw-r--r--core/res/res/values/public.xml4
-rw-r--r--core/res/res/values/styles.xml10
-rw-r--r--include/ui/ISurfaceFlingerClient.h3
-rw-r--r--libs/rs/java/Fall/res/raw/fall.c164
-rw-r--r--libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java29
-rw-r--r--libs/rs/java/Galaxy/res/raw/galaxy.c61
-rw-r--r--libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java40
-rw-r--r--libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java11
-rw-r--r--libs/surfaceflinger/LayerBase.cpp8
-rw-r--r--libs/surfaceflinger/LayerBase.h5
-rw-r--r--libs/surfaceflinger/LayerBitmap.cpp8
-rw-r--r--libs/surfaceflinger/SurfaceFlinger.cpp18
-rw-r--r--libs/surfaceflinger/SurfaceFlinger.h4
-rw-r--r--libs/ui/ISurfaceFlingerClient.cpp10
-rw-r--r--libs/ui/Surface.cpp93
-rw-r--r--services/java/com/android/server/WindowManagerService.java196
25 files changed, 670 insertions, 235 deletions
diff --git a/api/current.xml b/api/current.xml
index ec76edb..e9c3b30 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -8567,6 +8567,50 @@
visibility="public"
>
</field>
+<field name="wallpaperActivityCloseEnterAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843412"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperActivityCloseExitAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843413"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperActivityOpenEnterAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843410"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperActivityOpenExitAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843411"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="webViewStyle"
type="int"
transient="false"
@@ -12087,6 +12131,17 @@
visibility="public"
>
</field>
+<field name="Animation_InputMethod"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973910"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="Animation_Toast"
type="int"
transient="false"
@@ -144974,6 +145029,8 @@
>
<parameter name="dirty" type="android.graphics.Rect">
</parameter>
+<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
+</exception>
<exception name="Surface.OutOfResourcesException" type="android.view.Surface.OutOfResourcesException">
</exception>
</method>
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 6ee92ce..1f640ea 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -1992,8 +1992,9 @@ public class InputMethodService extends AbstractInputMethodService {
req.flags = InputConnection.GET_TEXT_WITH_STYLES;
req.hintMaxLines = 10;
req.hintMaxChars = 10000;
- mExtractedText = getCurrentInputConnection().getExtractedText(req,
- InputConnection.GET_EXTRACTED_TEXT_MONITOR);
+ InputConnection ic = getCurrentInputConnection();
+ mExtractedText = ic == null? null
+ : ic.getExtractedText(req, InputConnection.GET_EXTRACTED_TEXT_MONITOR);
final EditorInfo ei = getCurrentInputEditorInfo();
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 9ec1013..5cecac3 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -246,7 +246,7 @@ public class Surface implements Parcelable {
};
/**
- * Sets the display metrics used to provide canva's width/height in comaptibility mode.
+ * Sets the display metrics used to provide canva's width/height in compatibility mode.
*/
void setCompatibleDisplayMetrics(DisplayMetrics metrics, Translator translator) {
mCompatibleDisplayMetrics = metrics;
@@ -275,7 +275,8 @@ public class Surface implements Parcelable {
public native void clear();
/** draw into a surface */
- public Canvas lockCanvas(Rect dirty) throws OutOfResourcesException {
+ public Canvas lockCanvas(Rect dirty) throws OutOfResourcesException, IllegalArgumentException
+ {
/* the dirty rectangle may be expanded to the surface's size, if
* for instance it has been resized or if the bits were lost, since
* the last call.
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index f4e9900..ea08f33 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -344,6 +344,12 @@ public interface WindowManagerPolicy {
public final int TRANSIT_TASK_TO_FRONT = 10;
/** A window in an existing task is being put below all other tasks. */
public final int TRANSIT_TASK_TO_BACK = 11;
+ /** A window in a new activity is being opened on top of an existing one,
+ * and both are on top of the wallpaper. */
+ public final int TRANSIT_WALLPAPER_ACTIVITY_OPEN = 12;
+ /** The window in the top-most activity is being closed to reveal the
+ * previous activity, and both are on top of he wallpaper. */
+ public final int TRANSIT_WALLPAPER_ACTIVITY_CLOSE = 13;
/** Screen turned off because of power button */
public final int OFF_BECAUSE_OF_USER = 1;
diff --git a/core/res/res/anim/wallpaper_activity_close_enter.xml b/core/res/res/anim/wallpaper_activity_close_enter.xml
new file mode 100644
index 0000000..fc6e332
--- /dev/null
+++ b/core/res/res/anim/wallpaper_activity_close_enter.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/options_panel_exit.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@anim/decelerate_interpolator"
+ android:zAdjustment="top">
+ <scale android:fromXScale="2.0" android:toXScale="1.0"
+ android:fromYScale="2.0" android:toYScale="1.0"
+ android:pivotX="50%" android:pivotY="50%"
+ android:duration="@android:integer/config_mediumAnimTime" />
+ <translate android:fromXDelta="-150%" android:toXDelta="0"
+ android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
diff --git a/core/res/res/anim/wallpaper_activity_close_exit.xml b/core/res/res/anim/wallpaper_activity_close_exit.xml
new file mode 100644
index 0000000..edd00fd
--- /dev/null
+++ b/core/res/res/anim/wallpaper_activity_close_exit.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/options_panel_exit.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@anim/accelerate_interpolator">
+ <scale android:fromXScale="1.0" android:toXScale=".5"
+ android:fromYScale="1.0" android:toYScale=".5"
+ android:pivotX="50%" android:pivotY="50%"
+ android:duration="@android:integer/config_mediumAnimTime" />
+ <translate android:fromXDelta="0%" android:toXDelta="100%"
+ android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
diff --git a/core/res/res/anim/wallpaper_activity_open_enter.xml b/core/res/res/anim/wallpaper_activity_open_enter.xml
new file mode 100644
index 0000000..5b44d97
--- /dev/null
+++ b/core/res/res/anim/wallpaper_activity_open_enter.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/options_panel_exit.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@anim/decelerate_interpolator">
+ <scale android:fromXScale=".5" android:toXScale="1.0"
+ android:fromYScale=".5" android:toYScale="1.0"
+ android:pivotX="50%" android:pivotY="50%"
+ android:duration="@android:integer/config_mediumAnimTime" />
+ <translate android:fromXDelta="100%" android:toXDelta="0"
+ android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
diff --git a/core/res/res/anim/wallpaper_activity_open_exit.xml b/core/res/res/anim/wallpaper_activity_open_exit.xml
new file mode 100644
index 0000000..fa39bee
--- /dev/null
+++ b/core/res/res/anim/wallpaper_activity_open_exit.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/options_panel_exit.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@anim/accelerate_interpolator"
+ android:zAdjustment="top">
+ <scale android:fromXScale="1.0" android:toXScale="2.0"
+ android:fromYScale="1.0" android:toYScale="2.0"
+ android:pivotX="50%" android:pivotY="50%"
+ android:duration="@android:integer/config_mediumAnimTime" />
+ <translate android:fromXDelta="0" android:toXDelta="-150%"
+ android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index eee87e6..e03211d 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -937,18 +937,68 @@
<attr name="windowShowAnimation" format="reference" />
<!-- The animation used when a window is going from VISIBLE to INVISIBLE. -->
<attr name="windowHideAnimation" format="reference" />
+
+ <!-- When opening a new activity, this is the animation that is
+ run on the next activity (which is entering the screen). -->
<attr name="activityOpenEnterAnimation" format="reference" />
+ <!-- When opening a new activity, this is the animation that is
+ run on the previous activity (which is exiting the screen). -->
<attr name="activityOpenExitAnimation" format="reference" />
+ <!-- When closing the current activity, this is the animation that is
+ run on the next activity (which is entering the screen). -->
<attr name="activityCloseEnterAnimation" format="reference" />
+ <!-- When closing the current activity, this is the animation that is
+ run on the current activity (which is exiting the screen). -->
<attr name="activityCloseExitAnimation" format="reference" />
+ <!-- When opening an activity in a new task, this is the animation that is
+ run on the activity of the new task (which is entering the screen). -->
<attr name="taskOpenEnterAnimation" format="reference" />
+ <!-- When opening an activity in a new task, this is the animation that is
+ run on the activity of the old task (which is exiting the screen). -->
<attr name="taskOpenExitAnimation" format="reference" />
+ <!-- When closing the last activity of a task, this is the animation that is
+ run on the activity of the next task (which is entering the screen). -->
<attr name="taskCloseEnterAnimation" format="reference" />
+ <!-- When opening an activity in a new task, this is the animation that is
+ run on the activity of the old task (which is exiting the screen). -->
<attr name="taskCloseExitAnimation" format="reference" />
+ <!-- When bringing an existing task to the foreground, this is the
+ animation that is run on the top activity of the task being brought
+ to the foreground (which is entering the screen). -->
<attr name="taskToFrontEnterAnimation" format="reference" />
+ <!-- When bringing an existing task to the foreground, this is the
+ animation that is run on the current foreground activity
+ (which is exiting the screen). -->
<attr name="taskToFrontExitAnimation" format="reference" />
+ <!-- When sending the current task to the background, this is the
+ animation that is run on the top activity of the task behind
+ it (which is entering the screen). -->
<attr name="taskToBackEnterAnimation" format="reference" />
+ <!-- When sending the current task to the background, this is the
+ animation that is run on the top activity of the current task
+ (which is exiting the screen). -->
<attr name="taskToBackExitAnimation" format="reference" />
+
+ <!-- When opening a new activity that is on top of the wallpaper
+ when the current activity is also on top of the wallpaper,
+ this is the animation that is run on the new activity
+ (which is entering the screen). -->
+ <attr name="wallpaperActivityOpenEnterAnimation" format="reference" />
+ <!-- When opening a new activity that is on top of the wallpaper
+ when the current activity is also on top of the wallpaper,
+ this is the animation that is run on the current activity
+ (which is exiting the screen). -->
+ <attr name="wallpaperActivityOpenExitAnimation" format="reference" />
+ <!-- When closing a foreround activity that is on top of the wallpaper
+ when the previous activity is also on top of the wallpaper,
+ this is the animation that is run on the previous activity
+ (which is entering the screen). -->
+ <attr name="wallpaperActivityCloseEnterAnimation" format="reference" />
+ <!-- When closing a foreround activity that is on top of the wallpaper
+ when the previous activity is also on top of the wallpaper,
+ this is the animation that is run on the current activity
+ (which is exiting the screen). -->
+ <attr name="wallpaperActivityCloseExitAnimation" format="reference" />
</declare-styleable>
<!-- ============================= -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 60b492a..bbeb78d 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1150,6 +1150,10 @@
<public type="attr" name="contentAuthority" />
<public type="attr" name="userVisible" />
<public type="attr" name="windowShowWallpaper" />
+ <public type="attr" name="wallpaperActivityOpenEnterAnimation" />
+ <public type="attr" name="wallpaperActivityOpenExitAnimation" />
+ <public type="attr" name="wallpaperActivityCloseEnterAnimation" />
+ <public type="attr" name="wallpaperActivityCloseExitAnimation" />
<public type="style" name="Theme.Wallpaper" />
<public type="style" name="Theme.Wallpaper.NoTitleBar" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 4aa4210..10d2093 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -66,6 +66,10 @@
<item name="taskToFrontExitAnimation">@anim/task_open_exit</item>
<item name="taskToBackEnterAnimation">@anim/task_close_enter</item>
<item name="taskToBackExitAnimation">@anim/task_close_exit</item>
+ <item name="wallpaperActivityOpenEnterAnimation">@anim/wallpaper_activity_open_enter</item>
+ <item name="wallpaperActivityOpenExitAnimation">@anim/wallpaper_activity_open_exit</item>
+ <item name="wallpaperActivityCloseEnterAnimation">@anim/wallpaper_activity_close_enter</item>
+ <item name="wallpaperActivityCloseExitAnimation">@anim/wallpaper_activity_close_exit</item>
</style>
<!-- Standard animations for a non-full-screen window or activity. -->
@@ -130,8 +134,7 @@
<item name="windowExitAnimation">@anim/slide_out_down</item>
</style>
- <!-- Window animations that are applied to input method overlay windows.
- {@hide Pending API council approval} -->
+ <!-- Window animations that are applied to input method overlay windows. -->
<style name="Animation.InputMethod">
<item name="windowEnterAnimation">@anim/input_method_enter</item>
<item name="windowExitAnimation">@anim/input_method_exit</item>
@@ -151,8 +154,7 @@
<item name="windowExitAnimation">@anim/search_bar_exit</item>
</style>
- <!-- Window animations that are applied to the zoom buttons overlay window.
- {@hide Pending API council approval} -->
+ <!-- Window animations that are applied to the zoom buttons overlay window. -->
<style name="Animation.ZoomButtons">
<item name="windowEnterAnimation">@anim/fade_in</item>
<item name="windowExitAnimation">@anim/fade_out</item>
diff --git a/include/ui/ISurfaceFlingerClient.h b/include/ui/ISurfaceFlingerClient.h
index 932a70a..5d231e6 100644
--- a/include/ui/ISurfaceFlingerClient.h
+++ b/include/ui/ISurfaceFlingerClient.h
@@ -52,6 +52,9 @@ public:
struct surface_data_t {
int32_t token;
int32_t identity;
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
status_t readFromParcel(const Parcel& parcel);
status_t writeToParcel(Parcel* parcel) const;
};
diff --git a/libs/rs/java/Fall/res/raw/fall.c b/libs/rs/java/Fall/res/raw/fall.c
index a67764e..f348a62 100644
--- a/libs/rs/java/Fall/res/raw/fall.c
+++ b/libs/rs/java/Fall/res/raw/fall.c
@@ -68,17 +68,18 @@ void dropWithStrength(int x, int y, int r, int s) {
int* current = loadArrayI32(RSID_RIPPLE_MAP, index * rippleMapSize + origin);
int sqr = r * r;
+ float invs = 1.0f / s;
int h = 0;
- for ( ; h < r; h++) {
+ for ( ; h < r; h += 1) {
int sqv = h * h;
int yn = origin + (y - h) * (width + 2);
int yp = origin + (y + h) * (width + 2);
int w = 0;
- for ( ; w < r; w++) {
+ for ( ; w < r; w += 1) {
int squ = w * w;
if (squ + sqv < sqr) {
- int v = -sqrtf((sqr - (squ + sqv)) << 16) / s;
+ int v = -sqrtf((sqr - (squ + sqv)) << 16) * invs;
current[yn + x + w] = v;
current[yp + x + w] = v;
current[yn + x - w] = v;
@@ -110,16 +111,16 @@ void updateRipples() {
while (h) {
int w = width;
while (w) {
- int droplet = ((current[-b] + current[b] + current[-a] + current[a]) >> 1) - next[0];
+ int droplet = ((current[-b] + current[b] + current[-a] + current[a]) >> 1) - *next;
droplet -= (droplet >> DAMP);
- next[0] = droplet;
- current++;
- next++;
- w--;
+ *next = droplet;
+ current += 1;
+ next += 1;
+ w -= 1;
}
current += 2;
next += 2;
- h--;
+ h -= 1;
}
}
@@ -149,10 +150,14 @@ void generateRipples() {
int *map = loadArrayI32(RSID_REFRACTION_MAP, 0);
float *vertices = loadTriangleMeshVerticesF(NAMED_WaterMesh);
+ float fw = (float) width;
+ float fh = (float) height;
+ float fy = (1.0f / 512.0f) * (1.0f / RIPPLE_HEIGHT);
+
int h = height - 1;
while (h >= 0) {
int w = width - 1;
- int wave = current[0];
+ int wave = *current;
int offset = h * width;
while (w >= 0) {
int nextWave = current[1];
@@ -169,40 +174,47 @@ void generateRipples() {
v &= ~(v >> 31);
if (v >= height) v = height - 1;
- vertices[(offset + w) * 8 + 3] = u / (float) width;
- vertices[(offset + w) * 8 + 4] = v / (float) height;
+ int index = (offset + w) << 3;
+ vertices[index + 3] = u / fw;
+ vertices[index + 4] = v / fh;
// Update Z coordinate of the vertex
- vertices[(offset + w) * 8 + 7] = (dy / 512.0f) / RIPPLE_HEIGHT;
+ vertices[index + 7] = dy * fy;
- w--;
- current++;
+ w -= 1;
+ current += 1;
wave = nextWave;
}
- h--;
+ h -= 1;
current += 2;
}
// Compute the normals for lighting
int y = 0;
- for ( ; y < height; y++) {
+ int w8 = width << 3;
+ for ( ; y < height; y += 1) {
int x = 0;
int yOffset = y * width;
- for ( ; x < width; x++) {
+ for ( ; x < width; x += 1) {
+ int o = (yOffset + x) << 3;
+ int o1 = o + 8;
+ int ow = o + w8;
+ int ow1 = ow + 8;
+
// V1
- float v1x = vertices[(yOffset + x) * 8 + 5];
- float v1y = vertices[(yOffset + x) * 8 + 6];
- float v1z = vertices[(yOffset + x) * 8 + 7];
+ float v1x = vertices[o + 5];
+ float v1y = vertices[o + 6];
+ float v1z = vertices[o + 7];
// V2
- float v2x = vertices[(yOffset + x + 1) * 8 + 5];
- float v2y = vertices[(yOffset + x + 1) * 8 + 6];
- float v2z = vertices[(yOffset + x + 1) * 8 + 7];
+ float v2x = vertices[o1 + 5];
+ float v2y = vertices[o1 + 6];
+ float v2z = vertices[o1 + 7];
// V3
- float v3x = vertices[(yOffset + width + x) * 8 + 5];
- float v3y = vertices[(yOffset + width + x) * 8 + 6];
- float v3z = vertices[(yOffset + width + x) * 8 + 7];
+ float v3x = vertices[ow + 5];
+ float v3y = vertices[ow + 6];
+ float v3z = vertices[ow + 7];
// N1
float n1x = v2x - v1x;
@@ -220,15 +232,15 @@ void generateRipples() {
float n3z = n1x * n2y - n1y * n2x;
// Normalize
- float len = magf3(n3x, n3y, n3z);
- n3x /= len;
- n3y /= len;
- n3z /= len;
+ float len = 1.0f / magf3(n3x, n3y, n3z);
+ n3x *= len;
+ n3y *= len;
+ n3z *= len;
// V2
- v2x = vertices[(yOffset + width + x + 1) * 8 + 5];
- v2y = vertices[(yOffset + width + x + 1) * 8 + 6];
- v2z = vertices[(yOffset + width + x + 1) * 8 + 7];
+ v2x = vertices[ow1 + 5];
+ v2y = vertices[ow1 + 6];
+ v2z = vertices[ow1 + 7];
// N1
n1x = v2x - v1x;
@@ -240,23 +252,23 @@ void generateRipples() {
n2y = v3y - v1y;
n2z = v3z - v1z;
- // Avegare of previous normal and N1 x N2
- n3x = n3x / 2.0f + (n1y * n2z - n1z * n2y) / 2.0f;
- n3y = n3y / 2.0f + (n1z * n2x - n1x * n2z) / 2.0f;
- n3z = n3z / 2.0f + (n1x * n2y - n1y * n2x) / 2.0f;
+ // Average of previous normal and N1 x N2
+ n3x = n3x * 0.5f + (n1y * n2z - n1z * n2y) * 0.5f;
+ n3y = n3y * 0.5f + (n1z * n2x - n1x * n2z) * 0.5f;
+ n3z = n3z * 0.5f + (n1x * n2y - n1y * n2x) * 0.5f;
// Normalize
- len = magf3(n3x, n3y, n3z);
- n3x /= len;
- n3y /= len;
- n3z /= len;
-
- vertices[(yOffset + x) * 8 + 0] = n3x;
- vertices[(yOffset + x) * 8 + 1] = n3y;
- vertices[(yOffset + x) * 8 + 2] = -n3z;
+ len = 1.0f / magf3(n3x, n3y, n3z);
+ n3x *= len;
+ n3y *= len;
+ n3z *= len;
+
+ vertices[o + 0] = n3x;
+ vertices[o + 1] = n3y;
+ vertices[o + 2] = -n3z;
// reset Z
- //vertices[(yOffset + x) * 8 + 7] = 0.0f;
+ //vertices[(yOffset + x) << 3 + 7] = 0.0f;
}
}
}
@@ -264,10 +276,10 @@ void generateRipples() {
float averageZ(float x1, float x2, float y1, float y2, float* vertices,
int meshWidth, int meshHeight, float glWidth, float glHeight) {
- x1 = ((x1 + glWidth / 2.0f) / glWidth) * meshWidth;
- x2 = ((x2 + glWidth / 2.0f) / glWidth) * meshWidth;
- y1 = ((y1 + glHeight / 2.0f) / glHeight) * meshHeight;
- y2 = ((y2 + glHeight / 2.0f) / glHeight) * meshHeight;
+ x1 = ((x1 + glWidth * 0.5f) / glWidth) * meshWidth;
+ x2 = ((x2 + glWidth * 0.5f) / glWidth) * meshWidth;
+ y1 = ((y1 + glHeight * 0.5f) / glHeight) * meshHeight;
+ y2 = ((y2 + glHeight * 0.5f) / glHeight) * meshHeight;
int quadX1 = clamp(x1, 0, meshWidth);
int quadX2 = clamp(x2, 0, meshWidth);
@@ -278,12 +290,12 @@ float averageZ(float x1, float x2, float y1, float y2, float* vertices,
int vertexCount = 0;
int y = quadY1;
- for ( ; y < quadY2; y++) {
+ for ( ; y < quadY2; y += 1) {
int x = quadX1;
int yOffset = y * meshWidth;
- for ( ; x < quadX2; x++) {
- z += vertices[(yOffset + x) * 8 + 7];
- vertexCount++;
+ for ( ; x < quadX2; x += 1) {
+ z += vertices[(yOffset + x) << 3 + 7];
+ vertexCount += 1;
}
}
@@ -319,10 +331,10 @@ void drawLeaf(int index, float* vertices, int meshWidth, int meshHeight,
if (a > 0.0f) {
tz = -a;
} else {
- z1 = averageZ(x1, x, y1, y, vertices, meshWidth, meshHeight, glWidth, glHeight);
- z2 = averageZ(x, x2, y1, y, vertices, meshWidth, meshHeight, glWidth, glHeight);
- z3 = averageZ(x, x2, y, y2, vertices, meshWidth, meshHeight, glWidth, glHeight);
- z4 = averageZ(x1, x, y, y2, vertices, meshWidth, meshHeight, glWidth, glHeight);
+// z1 = averageZ(x1, x, y1, y, vertices, meshWidth, meshHeight, glWidth, glHeight);
+// z2 = averageZ(x, x2, y1, y, vertices, meshWidth, meshHeight, glWidth, glHeight);
+// z3 = averageZ(x, x2, y, y2, vertices, meshWidth, meshHeight, glWidth, glHeight);
+// z4 = averageZ(x1, x, y, y2, vertices, meshWidth, meshHeight, glWidth, glHeight);
}
x1 -= x;
@@ -346,8 +358,8 @@ void drawLeaf(int index, float* vertices, int meshWidth, int meshHeight,
if (a <= 0.0f) {
float rippled = leafStruct[LEAF_STRUCT_RIPPLED];
if (rippled < 0.0f) {
- drop(((x + glWidth / 2.0f) / glWidth) * meshWidth,
- meshHeight - ((y + glHeight / 2.0f) / glHeight) * meshHeight,
+ drop(((x + glWidth * 0.5f) / glWidth) * meshWidth,
+ meshHeight - ((y + glHeight * 0.5f) / glHeight) * meshHeight,
DROP_RADIUS);
spin /= 4.0f;
leafStruct[LEAF_STRUCT_SPIN] = spin;
@@ -454,6 +466,35 @@ void drawLighting() {
drawTriangleMesh(NAMED_WaterMesh);
}
+void drawNormals() {
+ int width = State_meshWidth;
+ int height = State_meshHeight;
+
+ float *vertices = loadTriangleMeshVerticesF(NAMED_WaterMesh);
+
+ bindProgramVertex(NAMED_PVSky);
+ bindProgramFragment(NAMED_PFLighting);
+
+ color(1.0f, 0.0f, 0.0f, 1.0f);
+
+ float scale = 1.0f / 10.0f;
+ int y = 0;
+ for ( ; y < height; y += 1) {
+ int yOffset = y * width;
+ int x = 0;
+ for ( ; x < width; x += 1) {
+ int offset = (yOffset + x) << 3;
+ float vx = vertices[offset + 5];
+ float vy = vertices[offset + 6];
+ float vz = vertices[offset + 7];
+ float nx = vertices[offset + 0];
+ float ny = vertices[offset + 1];
+ float nz = vertices[offset + 2];
+ drawLine(vx, vy, vz, vx + nx * scale, vy + ny * scale, vz + nz * scale);
+ }
+ }
+}
+
int main(int index) {
int dropX = Drop_dropX;
if (dropX != -1) {
@@ -471,6 +512,7 @@ int main(int index) {
drawSky();
drawLighting();
drawLeaves();
+ //drawNormals();
return 1;
}
diff --git a/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java b/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
index 02d4737..3b13bed 100644
--- a/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
+++ b/libs/rs/java/Fall/src/com/android/fall/rs/FallRS.java
@@ -177,22 +177,37 @@ class FallRS {
hResolution += 2;
for (int y = 0; y <= hResolution; y++) {
+ final boolean shift = (y & 0x1) == 0;
final float yOffset = y * quadHeight - glHeight / 2.0f - quadHeight;
final float t = 1.0f - y / (float) hResolution;
for (int x = 0; x <= wResolution; x++) {
- rs.triangleMeshAddVertex_XYZ_ST_NORM(
- -1.0f + x * quadWidth - quadWidth, yOffset, 0.0f,
- x / (float) wResolution, t,
- 0.0f, 0.0f, -1.0f);
+ if (shift) {
+ rs.triangleMeshAddVertex_XYZ_ST_NORM(
+ -1.0f + x * quadWidth - quadWidth, yOffset, 0.0f,
+ x / (float) wResolution, t,
+ 0.0f, 0.0f, -1.0f);
+ } else {
+ rs.triangleMeshAddVertex_XYZ_ST_NORM(
+ -1.0f + x * quadWidth - quadWidth * 0.5f, yOffset, 0.0f,
+ x / (float) wResolution, t,
+ 0.0f, 0.0f, -1.0f);
+ }
}
}
for (int y = 0; y < hResolution; y++) {
+ final boolean shift = (y & 0x1) == 0;
+ final int yOffset = y * (wResolution + 1);
for (int x = 0; x < wResolution; x++) {
- final int index = y * (wResolution + 1) + x;
+ final int index = yOffset + x;
final int iWR1 = index + wResolution + 1;
- rs.triangleMeshAddTriangle(index, index + 1, iWR1);
- rs.triangleMeshAddTriangle(index + 1, iWR1, iWR1 + 1);
+ if (shift) {
+ rs.triangleMeshAddTriangle(index, index + 1, iWR1);
+ rs.triangleMeshAddTriangle(index + 1, iWR1 + 1, iWR1);
+ } else {
+ rs.triangleMeshAddTriangle(index, iWR1 + 1, iWR1);
+ rs.triangleMeshAddTriangle(index, index + 1, iWR1 + 1);
+ }
}
}
diff --git a/libs/rs/java/Galaxy/res/raw/galaxy.c b/libs/rs/java/Galaxy/res/raw/galaxy.c
index 59c31a1..9ff449f 100644
--- a/libs/rs/java/Galaxy/res/raw/galaxy.c
+++ b/libs/rs/java/Galaxy/res/raw/galaxy.c
@@ -19,11 +19,13 @@
#define RSID_PARTICLES 1
-#define PARTICLE_STRUCT_FIELDS_COUNT 4
+#define PARTICLE_STRUCT_FIELDS_COUNT 6
#define PARTICLE_STRUCT_ANGLE 0
#define PARTICLE_STRUCT_DISTANCE 1
#define PARTICLE_STRUCT_SPEED 2
#define PARTICLE_STRUCT_RADIUS 3
+#define PARTICLE_STRUCT_S 4
+#define PARTICLE_STRUCT_T 5
#define RSID_PARTICLES_BUFFER 2
#define PARTICLE_BUFFER_COMPONENTS_COUNT 5
@@ -31,19 +33,14 @@
#define PARTICLES_TEXTURES_COUNT 2
#define ELLIPSE_RATIO 0.892f
-#define ELLIPSE_TWIST 0.02333333333f
void drawSpace(int width, int height) {
bindTexture(NAMED_PFBackground, 0, NAMED_TSpace);
drawQuadTexCoords(
- 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f,
- width, 0.0f, 0.0f,
- 2.0f, 1.0f,
- width, height, 0.0f,
- 2.0f, 0.0f,
- 0.0f, height, 0.0f,
- 0.0f, 0.0f);
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+ width, 0.0f, 0.0f, 2.0f, 1.0f,
+ width, height, 0.0f, 2.0f, 0.0f,
+ 0.0f, height, 0.0f, 0.0f, 0.0f);
}
void drawLights(int width, int height) {
@@ -61,39 +58,34 @@ void drawLights(int width, int height) {
x + 512.0f * 1.1f, y + 512.0f, 0.0f);
}
-void drawParticle(float *particle, int index, float *particleBuffer, int bufferIndex,
- float w, float h) {
-
- float distance = particle[index + PARTICLE_STRUCT_DISTANCE];
- float angle = particle[index + PARTICLE_STRUCT_ANGLE];
- float speed = particle[index + PARTICLE_STRUCT_SPEED];
- float r = particle[index + PARTICLE_STRUCT_RADIUS];
+void drawParticle(float *particle, float *particleBuffer, float w, float h) {
+ float distance = particle[PARTICLE_STRUCT_DISTANCE];
+ float angle = particle[PARTICLE_STRUCT_ANGLE];
+ float speed = particle[PARTICLE_STRUCT_SPEED];
+ float r = particle[PARTICLE_STRUCT_RADIUS];
float a = angle + speed;
float x = distance * sinf_fast(a);
float y = distance * cosf_fast(a) * ELLIPSE_RATIO;
- float z = distance * ELLIPSE_TWIST;
- float s = cosf_fast(z);
- float t = sinf_fast(z);
+ float s = particle[PARTICLE_STRUCT_S];
+ float t = particle[PARTICLE_STRUCT_T];
float sX = t * x + s * y + w;
float sY = s * x - t * y + h;
// lower left vertex of the particle's triangle
- particleBuffer[bufferIndex + 1] = sX - r; // X
- particleBuffer[bufferIndex + 2] = sY + r; // Y
+ particleBuffer[1] = sX - r; // X
+ particleBuffer[2] = sY + r; // Y
// lower right vertex of the particle's triangle
- bufferIndex += PARTICLE_BUFFER_COMPONENTS_COUNT;
- particleBuffer[bufferIndex + 1] = sX + r; // X
- particleBuffer[bufferIndex + 2] = sY + r; // Y
+ particleBuffer[6] = sX + r; // X
+ particleBuffer[7] = sY + r; // Y
// upper middle vertex of the particle's triangle
- bufferIndex += PARTICLE_BUFFER_COMPONENTS_COUNT;
- particleBuffer[bufferIndex + 1] = sX; // X
- particleBuffer[bufferIndex + 2] = sY - r; // Y
+ particleBuffer[11] = sX; // X
+ particleBuffer[12] = sY - r; // Y
- particle[index + PARTICLE_STRUCT_ANGLE] = a;
+ particle[PARTICLE_STRUCT_ANGLE] = a;
}
void drawParticles(int width, int height) {
@@ -103,7 +95,6 @@ void drawParticles(int width, int height) {
int radius = State_galaxyRadius;
int particlesCount = State_particlesCount;
- int count = particlesCount * PARTICLE_STRUCT_FIELDS_COUNT;
float *particle = loadArrayF(RSID_PARTICLES, 0);
float *particleBuffer = loadArrayF(RSID_PARTICLES_BUFFER, 0);
@@ -112,11 +103,11 @@ void drawParticles(int width, int height) {
float h = height * 0.5f;
int i = 0;
- int bufferIndex = 0;
- for ( ; i < count; i += PARTICLE_STRUCT_FIELDS_COUNT) {
- drawParticle(particle, i, particleBuffer, bufferIndex, w, h);
- // each particle is a triangle (3 vertices) of 6 properties (ABGR, X, Y, Z, S, T)
- bufferIndex += 3 * PARTICLE_BUFFER_COMPONENTS_COUNT;
+ for ( ; i < particlesCount; i++) {
+ drawParticle(particle, particleBuffer, w, h);
+ particle += PARTICLE_STRUCT_FIELDS_COUNT;
+ // each particle is a triangle (3 vertices) of 5 properties (ABGR, X, Y, S, T)
+ particleBuffer += 3 * PARTICLE_BUFFER_COMPONENTS_COUNT;
}
uploadToBufferObject(NAMED_ParticlesBuffer);
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
index 717100d..c6f5816 100644
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
+++ b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
@@ -42,9 +42,11 @@ import static android.util.MathUtils.*;
import java.util.TimeZone;
+@SuppressWarnings({"FieldCanBeLocal"})
class GalaxyRS {
private static final int GALAXY_RADIUS = 300;
private static final int PARTICLES_COUNT = 12000;
+ private static final float ELLIPSE_TWIST = 0.023333333f;
private static final int RSID_STATE = 0;
@@ -54,11 +56,13 @@ class GalaxyRS {
private static final int RSID_TEXTURE_FLARES = 2;
private static final int RSID_PARTICLES = 1;
- private static final int PARTICLE_STRUCT_FIELDS_COUNT = 4;
+ private static final int PARTICLE_STRUCT_FIELDS_COUNT = 6;
private static final int PARTICLE_STRUCT_ANGLE = 0;
private static final int PARTICLE_STRUCT_DISTANCE = 1;
private static final int PARTICLE_STRUCT_SPEED = 2;
private static final int PARTICLE_STRUCT_RADIUS = 3;
+ private static final int PARTICLE_STRUCT_S = 4;
+ private static final int PARTICLE_STRUCT_T = 5;
private static final int RSID_PARTICLES_BUFFER = 2;
@@ -103,35 +107,6 @@ class GalaxyRS {
initRS();
}
- public void destroy() {
- mScript.destroy();
- mSampler.destroy();
- mLightSampler.destroy();
- mPfBackground.destroy();
- mPfsBackground.destroy();
- mPvBackground.destroy();
- mPvOrthoAlloc.mAlloc.destroy();
- for (Allocation a : mTextures) {
- a.destroy();
- }
- mState.destroy();
- mPfLighting.destroy();
- mParticles.destroy();
- mPfsLights.destroy();
- mParticlesMesh.destroy();
- mParticlesBuffer.destroy();
- mStateType.destroy();
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- destroy();
- } finally {
- super.finalize();
- }
- }
-
private void initRS() {
createProgramVertex();
createProgramFragmentStore();
@@ -218,13 +193,16 @@ class GalaxyRS {
float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f + random(-4.0f, 4.0f);
float z = randomGauss() * 0.5f * 0.8f * ((GALAXY_RADIUS - d) / (float) GALAXY_RADIUS);
z += 1.0f;
+ float p = d * ELLIPSE_TWIST;
particles[index + PARTICLE_STRUCT_ANGLE] = random(0.0f, (float) (Math.PI * 2.0));
particles[index + PARTICLE_STRUCT_DISTANCE] = d;
particles[index + PARTICLE_STRUCT_SPEED] = random(0.0015f, 0.0025f) *
(0.5f + (0.5f * (float) GALAXY_RADIUS / d)) * 0.7f;
particles[index + PARTICLE_STRUCT_RADIUS] = z * random(1.2f, 2.1f);
-
+ particles[index + PARTICLE_STRUCT_S] = (float) Math.cos(p);
+ particles[index + PARTICLE_STRUCT_T] = (float) Math.sin(p);
+
int red, green, blue;
if (d < GALAXY_RADIUS / 3.0f) {
red = (int) (220 + (d / (float) GALAXY_RADIUS) * 35);
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java
index 341293b..4f6d3f0 100644
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java
+++ b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java
@@ -22,8 +22,6 @@ import android.renderscript.RenderScript;
import android.renderscript.RSSurfaceView;
class GalaxyView extends RSSurfaceView {
- private GalaxyRS mRender;
-
public GalaxyView(Context context) {
super(context);
setFocusable(true);
@@ -34,12 +32,7 @@ class GalaxyView extends RSSurfaceView {
super.surfaceChanged(holder, format, w, h);
RenderScript RS = createRenderScript();
- mRender = new GalaxyRS(w, h);
- mRender.init(RS, getResources());
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- if (mRender != null) mRender.destroy();
+ GalaxyRS render = new GalaxyRS(w, h);
+ render.init(RS, getResources());
}
}
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 419574c..fd54e35 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -730,14 +730,6 @@ sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const {
return owner;
}
-
-void LayerBaseClient::Surface::getSurfaceData(
- ISurfaceFlingerClient::surface_data_t* params) const
-{
- params->token = mToken;
- params->identity = mIdentity;
-}
-
status_t LayerBaseClient::Surface::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 65bf55b..7791941 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -321,10 +321,9 @@ public:
class Surface : public BnSurface
{
public:
+ int32_t getToken() const { return mToken; }
+ int32_t getIdentity() const { return mIdentity; }
- virtual void getSurfaceData(
- ISurfaceFlingerClient::surface_data_t* params) const;
-
protected:
Surface(const sp<SurfaceFlinger>& flinger,
SurfaceID id, int identity,
diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp
index 5e74451..dd61e1a 100644
--- a/libs/surfaceflinger/LayerBitmap.cpp
+++ b/libs/surfaceflinger/LayerBitmap.cpp
@@ -97,11 +97,9 @@ status_t Buffer::initSize(uint32_t w, uint32_t h, uint32_t reqUsage)
err = allocator.alloc(w, h, format, usage, &handle, &stride);
if (err == NO_ERROR) {
- if (err == NO_ERROR) {
- width = w;
- height = h;
- mVStride = 0;
- }
+ width = w;
+ height = h;
+ mVStride = 0;
}
return err;
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 102899c..3824024 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -1239,9 +1239,11 @@ sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid,
switch (flags & eFXSurfaceMask) {
case eFXSurfaceNormal:
if (UNLIKELY(flags & ePushBuffers)) {
- layer = createPushBuffersSurfaceLocked(client, d, id, w, h, flags);
+ layer = createPushBuffersSurfaceLocked(client, d, id,
+ w, h, flags);
} else {
- layer = createNormalSurfaceLocked(client, d, id, w, h, format, flags);
+ layer = createNormalSurfaceLocked(client, d, id,
+ w, h, flags, format);
}
break;
case eFXSurfaceBlur:
@@ -1255,8 +1257,13 @@ sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid,
if (layer != 0) {
setTransactionFlags(eTransactionNeeded);
surfaceHandle = layer->getSurface();
- if (surfaceHandle != 0)
- surfaceHandle->getSurfaceData(params);
+ if (surfaceHandle != 0) {
+ params->token = surfaceHandle->getToken();
+ params->identity = surfaceHandle->getIdentity();
+ params->width = w;
+ params->height = h;
+ params->format = format;
+ }
}
return surfaceHandle;
@@ -1264,7 +1271,8 @@ sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid,
sp<LayerBaseClient> SurfaceFlinger::createNormalSurfaceLocked(
const sp<Client>& client, DisplayID display,
- int32_t id, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags)
+ int32_t id, uint32_t w, uint32_t h, uint32_t flags,
+ PixelFormat& format)
{
// initialize the surfaces
switch (format) { // TODO: take h/w into account
diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h
index 2569a0f..56ea97a 100644
--- a/libs/surfaceflinger/SurfaceFlinger.h
+++ b/libs/surfaceflinger/SurfaceFlinger.h
@@ -195,8 +195,8 @@ private:
sp<LayerBaseClient> createNormalSurfaceLocked(
const sp<Client>& client, DisplayID display,
- int32_t id, uint32_t w, uint32_t h,
- PixelFormat format, uint32_t flags);
+ int32_t id, uint32_t w, uint32_t h, uint32_t flags,
+ PixelFormat& format);
sp<LayerBaseClient> createBlurSurfaceLocked(
const sp<Client>& client, DisplayID display,
diff --git a/libs/ui/ISurfaceFlingerClient.cpp b/libs/ui/ISurfaceFlingerClient.cpp
index 51e8422..4a6a1d7 100644
--- a/libs/ui/ISurfaceFlingerClient.cpp
+++ b/libs/ui/ISurfaceFlingerClient.cpp
@@ -189,8 +189,11 @@ status_t BnSurfaceFlingerClient::onTransact(
status_t ISurfaceFlingerClient::surface_data_t::readFromParcel(const Parcel& parcel)
{
- token = parcel.readInt32();
- identity = parcel.readInt32();
+ token = parcel.readInt32();
+ identity = parcel.readInt32();
+ width = parcel.readInt32();
+ height = parcel.readInt32();
+ format = parcel.readInt32();
return NO_ERROR;
}
@@ -198,6 +201,9 @@ status_t ISurfaceFlingerClient::surface_data_t::writeToParcel(Parcel* parcel) co
{
parcel->writeInt32(token);
parcel->writeInt32(identity);
+ parcel->writeInt32(width);
+ parcel->writeInt32(height);
+ parcel->writeInt32(format);
return NO_ERROR;
}
diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp
index f6792c4..36a10cf 100644
--- a/libs/ui/Surface.cpp
+++ b/libs/ui/Surface.cpp
@@ -64,11 +64,16 @@ SurfaceBuffer::SurfaceBuffer(const Parcel& data)
{
// we own the handle in this case
width = data.readInt32();
- height = data.readInt32();
- stride = data.readInt32();
- format = data.readInt32();
- usage = data.readInt32();
- handle = data.readNativeHandle();
+ if (width < 0) {
+ width = height = stride = format = usage = 0;
+ handle = 0;
+ } else {
+ height = data.readInt32();
+ stride = data.readInt32();
+ format = data.readInt32();
+ usage = data.readInt32();
+ handle = data.readNativeHandle();
+ }
}
SurfaceBuffer::~SurfaceBuffer()
@@ -108,16 +113,25 @@ status_t SurfaceBuffer::unlock()
status_t SurfaceBuffer::writeToParcel(Parcel* reply,
android_native_buffer_t const* buffer)
{
- if (buffer == NULL) {
+ if (buffer == NULL)
+ return BAD_VALUE;
+
+ if (buffer->width < 0 || buffer->height < 0)
return BAD_VALUE;
+
+ status_t err = NO_ERROR;
+ if (buffer->handle == NULL) {
+ // this buffer doesn't have a handle
+ reply->writeInt32(NO_MEMORY);
+ } else {
+ reply->writeInt32(buffer->width);
+ reply->writeInt32(buffer->height);
+ reply->writeInt32(buffer->stride);
+ reply->writeInt32(buffer->format);
+ reply->writeInt32(buffer->usage);
+ err = reply->writeNativeHandle(buffer->handle);
}
- reply->writeInt32(buffer->width);
- reply->writeInt32(buffer->height);
- reply->writeInt32(buffer->stride);
- reply->writeInt32(buffer->format);
- reply->writeInt32(buffer->usage);
- reply->writeNativeHandle(buffer->handle);
- return NO_ERROR;
+ return err;
}
// ----------------------------------------------------------------------
@@ -183,7 +197,8 @@ SurfaceControl::SurfaceControl(
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags)
: mClient(client), mSurface(surface),
mToken(data.token), mIdentity(data.identity),
- mWidth(w), mHeight(h), mFormat(format), mFlags(flags)
+ mWidth(data.width), mHeight(data.height), mFormat(data.format),
+ mFlags(flags)
{
}
@@ -434,7 +449,7 @@ Surface::~Surface()
// this is a client-side operation, the surface is destroyed, unmap
// its buffers in this process.
for (int i=0 ; i<2 ; i++) {
- if (mBuffers[i] != 0) {
+ if (mBuffers[i] != 0 && mBuffers[i]->handle != 0) {
getBufferMapper().unregisterBuffer(mBuffers[i]->handle);
}
}
@@ -590,17 +605,24 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
if ((back->flags & surface_info_t::eNeedNewBuffer) || mUsageChanged) {
mUsageChanged = false;
err = getBufferLocked(backIdx, mUsage);
+ if (err == NO_ERROR) {
+ // reset the width/height with the what we get from the buffer
+ const sp<SurfaceBuffer>& backBuffer(mBuffers[backIdx]);
+ mWidth = uint32_t(backBuffer->width);
+ mHeight = uint32_t(backBuffer->height);
+ }
}
if (err == NO_ERROR) {
const sp<SurfaceBuffer>& backBuffer(mBuffers[backIdx]);
- // reset the width/height with the what we get from the buffer
- mWidth = uint32_t(backBuffer->width);
- mHeight = uint32_t(backBuffer->height);
- mDirtyRegion.set(backBuffer->width, backBuffer->height);
- *buffer = backBuffer.get();
+ if (backBuffer != 0) {
+ mDirtyRegion.set(backBuffer->width, backBuffer->height);
+ *buffer = backBuffer.get();
+ } else {
+ err = NO_MEMORY;
+ }
}
-
+
return err;
}
@@ -716,7 +738,8 @@ status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking)
} else {
newDirtyRegion.andSelf(bounds);
const sp<SurfaceBuffer>& frontBuffer(mBuffers[1-mBackbufferIndex]);
- if (backBuffer->width == frontBuffer->width &&
+ if (frontBuffer !=0 &&
+ backBuffer->width == frontBuffer->width &&
backBuffer->height == frontBuffer->height &&
!(lcblk->flags & eNoCopyBack))
{
@@ -788,18 +811,24 @@ status_t Surface::getBufferLocked(int index, int usage)
if (s == 0) return NO_INIT;
status_t err = NO_MEMORY;
+
+ // free the current buffer
+ sp<SurfaceBuffer>& currentBuffer(mBuffers[index]);
+ if (currentBuffer != 0) {
+ getBufferMapper().unregisterBuffer(currentBuffer->handle);
+ currentBuffer.clear();
+ }
+
sp<SurfaceBuffer> buffer = s->getBuffer(usage);
LOGE_IF(buffer==0, "ISurface::getBuffer() returned NULL");
- if (buffer != 0) {
- sp<SurfaceBuffer>& currentBuffer(mBuffers[index]);
- if (currentBuffer != 0) {
- getBufferMapper().unregisterBuffer(currentBuffer->handle);
- currentBuffer.clear();
- }
- err = getBufferMapper().registerBuffer(buffer->handle);
- LOGW_IF(err, "registerBuffer(...) failed %d (%s)", err, strerror(-err));
- if (err == NO_ERROR) {
- currentBuffer = buffer;
+ if (buffer != 0) { // this should never happen by construction
+ if (buffer->handle != NULL) {
+ err = getBufferMapper().registerBuffer(buffer->handle);
+ LOGW_IF(err, "registerBuffer(...) failed %d (%s)",
+ err, strerror(-err));
+ if (err == NO_ERROR) {
+ currentBuffer = buffer;
+ }
}
}
return err;
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index a00a756..7ca8b52 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -405,6 +405,7 @@ public class WindowManagerService extends IWindowManager.Stub
// If non-null, this is the currently visible window that is associated
// with the wallpaper.
WindowState mWallpaperTarget = null;
+ WindowState mUpcomingWallpaperTarget = null;
int mWallpaperAnimLayerAdjustment;
AppWindowToken mFocusedApp = null;
@@ -1178,60 +1179,136 @@ public class WindowManagerService extends IWindowManager.Stub
boolean adjustWallpaperWindowsLocked() {
boolean changed = false;
+ mUpcomingWallpaperTarget = null;
+
// First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it.
final ArrayList localmWindows = mWindows;
int N = localmWindows.size();
WindowState w = null;
+ WindowState foundW = null;
+ int foundI = 0;
+ AppWindowToken topToken = null;
+ AppWindowToken behindToken = null;
int i = N;
- boolean visible = false;
while (i > 0) {
i--;
w = (WindowState)localmWindows.get(i);
+ if (topToken != null) {
+ if (w.mAppToken == topToken) {
+ continue;
+ }
+ if (w.mAppToken != null) {
+ if (behindToken == null) {
+ // We need to look through for what is behind the
+ // potential new wallpaper target... skip all tokens
+ // that are hidden and not animating, since they can't
+ // be involved with the transition.
+ if (w.mAppToken.hidden && w.mAppToken.animation == null) {
+ continue;
+ }
+ behindToken = w.mAppToken;
+ }
+ if (w.mAppToken != behindToken) {
+ break;
+ }
+ }
+ }
if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
&& !w.mDrawPending && !w.mCommitDrawPending) {
- visible = true;
+ if (behindToken != null && w.mAppToken == behindToken) {
+ // We had previously found a wallpaper window that was
+ // animating, and now we found one behind it. We could
+ // be doing an animation between two windows on top of
+ // the wallpaper!
+ if (mWallpaperTarget == w || mWallpaperTarget == foundW) {
+ // Retain the current wallpaper target (don't move
+ // the wallpaper yet), but note the window that is
+ // going to become the wallpaper target so that
+ // others know about this special state.
+ if (DEBUG_WALLPAPER) Log.v(TAG,
+ "Switching wallpaper activities: cur#" + i + "="
+ + w + " upcoming#" + foundI + "=" + foundW);
+ mUpcomingWallpaperTarget = foundW;
+ foundW = w;
+ foundI = i;
+ break;
+ }
+ }
+ foundW = w;
+ foundI = i;
+ if (w.mAppToken != null && w.mAppToken.animation != null) {
+ // If this app token is animating, we want to keep the
+ // wallpaper below it if it is animating on top of another
+ // app with a wallpaper.
+ topToken = w.mAppToken;
+ continue;
+ }
break;
}
}
- if (!visible) w = null;
- if (DEBUG_WALLPAPER && mWallpaperTarget != w) {
- Log.v(TAG, "New wallpaper target: " + w);
+ if (mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) {
+ // If we are currently waiting for an app transition, and either
+ // the current target or the next target are involved with it,
+ // then hold off on doing anything with the wallpaper.
+ // Note that we are checking here for just whether the target
+ // is part of an app token... which is potentially overly aggressive
+ // (the app token may not be involved in the transition), but good
+ // enough (we'll just wait until whatever transition is pending
+ // executes).
+ if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) {
+ return false;
+ }
+ if (foundW != null && foundW.mAppToken != null) {
+ return false;
+ }
+ if (mUpcomingWallpaperTarget != null && mUpcomingWallpaperTarget.mAppToken != null) {
+ return false;
+ }
+ }
+
+ if (mWallpaperTarget != foundW) {
+ mWallpaperTarget = foundW;
+ if (DEBUG_WALLPAPER) {
+ Log.v(TAG, "New wallpaper target: " + foundW);
+ }
}
- mWallpaperTarget = w;
+ boolean visible = foundW != null;
if (visible) {
// The window is visible to the compositor... but is it visible
// to the user? That is what the wallpaper cares about.
- visible = !w.mObscured;
+ visible = !foundW.mObscured;
if (DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper visibility: " + visible);
// If the wallpaper target is animating, we may need to copy
- // its layer adjustment.
- mWallpaperAnimLayerAdjustment = w.mAppToken != null
- ? w.mAppToken.animLayerAdjustment : 0;
+ // its layer adjustment. Only do this if we are not transfering
+ // between two wallpaper targets.
+ mWallpaperAnimLayerAdjustment =
+ (mUpcomingWallpaperTarget == null && foundW.mAppToken != null)
+ ? foundW.mAppToken.animLayerAdjustment : 0;
// Now w is the window we are supposed to be behind... but we
// need to be sure to also be behind any of its attached windows,
// AND any starting window associated with it.
- while (i > 0) {
- WindowState wb = (WindowState)localmWindows.get(i-1);
- if (wb.mAttachedWindow != w &&
+ while (foundI > 0) {
+ WindowState wb = (WindowState)localmWindows.get(foundI-1);
+ if (wb.mAttachedWindow != foundW &&
(wb.mAttrs.type != TYPE_APPLICATION_STARTING ||
- wb.mToken != w.mToken)) {
+ wb.mToken != foundW.mToken)) {
// This window is not related to the previous one in any
// interesting way, so stop here.
break;
}
- w = wb;
- i--;
+ foundW = wb;
+ foundI--;
}
}
// Okay i is the position immediately above the wallpaper. Look at
// what is below it for later.
- w = i > 0 ? (WindowState)localmWindows.get(i-1) : null;
+ foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null;
final int dw = mDisplay.getWidth();
final int dh = mDisplay.getHeight();
@@ -1271,9 +1348,10 @@ public class WindowManagerService extends IWindowManager.Stub
// First, if this window is at the current index, then all
// is well.
- if (wallpaper == w) {
- i--;
- w = i > 0 ? (WindowState)localmWindows.get(i-1) : null;
+ if (wallpaper == foundW) {
+ foundI--;
+ foundW = foundI > 0
+ ? (WindowState)localmWindows.get(foundI-1) : null;
continue;
}
@@ -1283,16 +1361,16 @@ public class WindowManagerService extends IWindowManager.Stub
int oldIndex = localmWindows.indexOf(wallpaper);
if (oldIndex >= 0) {
localmWindows.remove(oldIndex);
- if (oldIndex < i) {
- i--;
+ if (oldIndex < foundI) {
+ foundI--;
}
}
// Now stick it in.
if (DEBUG_WALLPAPER) Log.v(TAG, "Moving wallpaper " + wallpaper
- + " from " + oldIndex + " to " + i);
+ + " from " + oldIndex + " to " + foundI);
- localmWindows.add(i, wallpaper);
+ localmWindows.add(foundI, wallpaper);
changed = true;
}
}
@@ -2246,6 +2324,16 @@ public class WindowManagerService extends IWindowManager.Stub
? com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation
: com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
break;
+ case WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_OPEN:
+ animAttr = enter
+ ? com.android.internal.R.styleable.WindowAnimation_wallpaperActivityOpenEnterAnimation
+ : com.android.internal.R.styleable.WindowAnimation_wallpaperActivityOpenExitAnimation;
+ break;
+ case WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_CLOSE:
+ animAttr = enter
+ ? com.android.internal.R.styleable.WindowAnimation_wallpaperActivityCloseEnterAnimation
+ : com.android.internal.R.styleable.WindowAnimation_wallpaperActivityCloseExitAnimation;
+ break;
}
a = loadAnimation(lp, animAttr);
if (DEBUG_ANIM) Log.v(TAG, "applyAnimation: wtoken=" + wtoken
@@ -6874,7 +6962,8 @@ public class WindowManagerService extends IWindowManager.Stub
// Wallpapers are animated based on the "real" window they
// are currently targeting.
- if (mAttrs.type == TYPE_WALLPAPER && mWallpaperTarget != null) {
+ if (mAttrs.type == TYPE_WALLPAPER && mUpcomingWallpaperTarget == null
+ && mWallpaperTarget != null) {
if (mWallpaperTarget.mHasLocalTransformation) {
attachedTransformation = mWallpaperTarget.mTransformation;
}
@@ -7511,7 +7600,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (w == mInputMethodTarget) {
setInputMethodAnimLayerAdjustment(adj);
}
- if (w == mWallpaperTarget) {
+ if (w == mWallpaperTarget && mUpcomingWallpaperTarget == null) {
setWallpaperAnimLayerAdjustmentLocked(adj);
}
}
@@ -8636,6 +8725,60 @@ public class WindowManagerService extends IWindowManager.Stub
mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
+ boolean wallpaperMoved = adjustWallpaperWindowsLocked();
+ if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+ "Old wallpaper target=" + mWallpaperTarget
+ + ", upcoming target=" + mUpcomingWallpaperTarget);
+ if (mUpcomingWallpaperTarget != mWallpaperTarget &&
+ mUpcomingWallpaperTarget != null &&
+ mWallpaperTarget != null) {
+ // Need to determine if both the closing and
+ // opening app token sets are wallpaper targets,
+ // in which case special animations are needed
+ // (since the wallpaper needs to stay static
+ // behind them).
+ int found = 0;
+ NN = mOpeningApps.size();
+ for (i=0; i<NN; i++) {
+ AppWindowToken wtoken = mOpeningApps.get(i);
+ if (mUpcomingWallpaperTarget.mAppToken == wtoken) {
+ found |= 1;
+ }
+ if (mWallpaperTarget.mAppToken == wtoken) {
+ found |= 1;
+ }
+ }
+ NN = mClosingApps.size();
+ for (i=0; i<NN; i++) {
+ AppWindowToken wtoken = mClosingApps.get(i);
+ if (mUpcomingWallpaperTarget.mAppToken == wtoken) {
+ found |= 2;
+ }
+ if (mWallpaperTarget.mAppToken == wtoken) {
+ found |= 2;
+ }
+ }
+
+ if (found == 3) {
+ if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+ "Wallpaper animation!");
+ switch (transit) {
+ case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
+ case WindowManagerPolicy.TRANSIT_TASK_OPEN:
+ case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
+ transit = WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_OPEN;
+ break;
+ case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+ case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
+ case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
+ transit = WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_CLOSE;
+ break;
+ }
+ if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+ "New transit: " + transit);
+ }
+ }
+
// We need to figure out which animation to use...
WindowManager.LayoutParams lp = findAnimations(mAppTokens,
mOpeningApps, mClosingApps);
@@ -8671,7 +8814,6 @@ public class WindowManagerService extends IWindowManager.Stub
// This has changed the visibility of windows, so perform
// a new layout to get them all up-to-date.
mLayoutNeeded = true;
- adjustWallpaperWindowsLocked();
if (!moveInputMethodWindowsIfNeededLocked(true)) {
assignLayersLocked();
}