diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-01-12 15:19:26 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2010-01-12 15:19:26 -0800 |
commit | 11d103bd137489d0a011336bddf59e3db1f20467 (patch) | |
tree | 6e782e265e4b0524c9f04454d2933891c26fae48 | |
parent | ba4147cf9e24819e90c56a8fdb1e62af3914aba7 (diff) | |
download | android_packages_wallpapers_MagicSmoke-11d103bd137489d0a011336bddf59e3db1f20467.tar.gz android_packages_wallpapers_MagicSmoke-11d103bd137489d0a011336bddf59e3db1f20467.tar.bz2 android_packages_wallpapers_MagicSmoke-11d103bd137489d0a011336bddf59e3db1f20467.zip |
android-2.1_r1 snapshot
41 files changed, 2041 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..49b8719 --- /dev/null +++ b/Android.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2008 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. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +# LOCAL_MODULE_TAGS := user + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_PACKAGE_NAME := MagicSmokeWallpapers +LOCAL_CERTIFICATE := shared + +include $(BUILD_PACKAGE) diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..5e79225 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2008, 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. +*/ +--> +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.magicsmoke"> + + <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" /> + <uses-permission android:name="android.permission.BIND_WALLPAPER" /> + + <application + android:label="@string/wallpapers" + android:icon="@drawable/ic_launcher_wallpaper"> + + <service + android:label="@string/wallpaper_magicsmoke" + android:name="MagicSmoke" + android:permission="android.permission.BIND_WALLPAPER"> + <intent-filter> + <action android:name="android.service.wallpaper.WallpaperService" /> + </intent-filter> + <meta-data android:name="android.service.wallpaper" android:resource="@xml/magicsmoke" /> + </service> + + <activity + android:name="com.android.magicsmoke.MagicSmokeSelector" + android:theme="@style/Preview" + android:exported="true"> + </activity> + + </application> + +</manifest> diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_APACHE2 @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/res/drawable-hdpi/noise1.png b/res/drawable-hdpi/noise1.png Binary files differnew file mode 100644 index 0000000..fee1cf9 --- /dev/null +++ b/res/drawable-hdpi/noise1.png diff --git a/res/drawable-hdpi/noise2.png b/res/drawable-hdpi/noise2.png Binary files differnew file mode 100644 index 0000000..0d13662 --- /dev/null +++ b/res/drawable-hdpi/noise2.png diff --git a/res/drawable-hdpi/noise3.png b/res/drawable-hdpi/noise3.png Binary files differnew file mode 100644 index 0000000..c9c610b --- /dev/null +++ b/res/drawable-hdpi/noise3.png diff --git a/res/drawable-hdpi/noise4.png b/res/drawable-hdpi/noise4.png Binary files differnew file mode 100644 index 0000000..02261c9 --- /dev/null +++ b/res/drawable-hdpi/noise4.png diff --git a/res/drawable-hdpi/noise5.png b/res/drawable-hdpi/noise5.png Binary files differnew file mode 100644 index 0000000..2f9a713 --- /dev/null +++ b/res/drawable-hdpi/noise5.png diff --git a/res/drawable/ic_launcher_wallpaper.png b/res/drawable/ic_launcher_wallpaper.png Binary files differnew file mode 100644 index 0000000..965fb71 --- /dev/null +++ b/res/drawable/ic_launcher_wallpaper.png diff --git a/res/drawable/magicsmoke_thumb.png b/res/drawable/magicsmoke_thumb.png Binary files differnew file mode 100644 index 0000000..8c937b8 --- /dev/null +++ b/res/drawable/magicsmoke_thumb.png diff --git a/res/layout/selector.xml b/res/layout/selector.xml new file mode 100644 index 0000000..e202733 --- /dev/null +++ b/res/layout/selector.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 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. +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/backgroundview" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingBottom="4dip"> + + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/taptochange" + android:textSize="24dip" + android:gravity="center_horizontal" + android:layout_alignParentTop="true" + android:padding="12dip" + android:background="#40000000" + /> + + <Button + android:layout_width="160dip" + android:layout_height="wrap_content" + android:text="@string/ok" + android:onClick="setLiveWallpaper" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + /> + +</RelativeLayout> diff --git a/res/raw/clouds.rs b/res/raw/clouds.rs new file mode 100644 index 0000000..a6ab846 --- /dev/null +++ b/res/raw/clouds.rs @@ -0,0 +1,316 @@ +// Copyright (C) 2009 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. + +#pragma version(1) +#pragma stateVertex(PVBackground) +#pragma stateRaster(parent) +#pragma stateFragment(PFBackground) + +#define RSID_NOISESRC1 1 +#define RSID_NOISESRC2 2 +#define RSID_NOISESRC3 3 +#define RSID_NOISESRC4 4 +#define RSID_NOISESRC5 5 +#define RSID_NOISEDST1 6 +#define RSID_NOISEDST2 7 +#define RSID_NOISEDST3 8 +#define RSID_NOISEDST4 9 +#define RSID_NOISEDST5 10 + +float xshift[5]; +float rotation[5]; +float scale[5]; +float alphafactor; +int currentpreset; +int lastuptime; +float timedelta; + +void drawCloud(float *ident, int id, int idx) { + float mat1[16]; + float z = -8.f * idx; + matrixLoadMat(mat1,ident); + matrixTranslate(mat1, -State->mXOffset * 8.f * idx, -State->mTilt * idx / 3.f, 0.f); + matrixRotate(mat1, rotation[idx], 0.f, 0.f, 1.f); + vpLoadModelMatrix(mat1); + + bindTexture(NAMED_PFBackground, 0, id); + drawQuadTexCoords( + -1200.0f, -1200.0f, z, // space + 0.f + xshift[idx], 0.f, // texture + 1200, -1200.0f, z, // space + scale[idx] + xshift[idx], 0.f, // texture + 1200, 1200.0f, z, // space + scale[idx] + xshift[idx], scale[idx], // texture + -1200.0f, 1200.0f, z, // space + 0.f + xshift[idx], scale[idx]); // texture +} + +void drawClouds(float* ident) { + + int i; + + float mat1[16]; + + matrixLoadMat(mat1,ident); + + if (State->mRotate != 0) { + rotation[0] += 0.10 * timedelta; + rotation[1] += 0.102f * timedelta; + rotation[2] += 0.106f * timedelta; + rotation[3] += 0.114f * timedelta; + rotation[4] += 0.123f * timedelta; + } + + int mask = State->mTextureMask; + if (mask & 1) { + xshift[0] += 0.0010f * timedelta; + if (State->mTextureSwap != 0) { + drawCloud(mat1, NAMED_Tnoise5, 0); + } else { + drawCloud(mat1, NAMED_Tnoise1, 0); + } + } + + if (mask & 2) { + xshift[1] += 0.00106 * timedelta; + drawCloud(mat1, NAMED_Tnoise2, 1); + } + + if (mask & 4) { + xshift[2] += 0.00114f * timedelta; + drawCloud(mat1, NAMED_Tnoise3, 2); + } + + if (mask & 8) { + xshift[3] += 0.00118f * timedelta; + drawCloud(mat1, NAMED_Tnoise4, 3); + } + + if (mask & 16) { + xshift[4] += 0.00127f * timedelta; + drawCloud(mat1, NAMED_Tnoise5, 4); + } + + // Make sure the texture coordinates don't continuously increase + for(i = 0; i < 5; i++) { + while (xshift[i] >= 1.f) { + xshift[i] -= 1.f; + } + } + // Make sure the rotation angles don't continuously increase + for(i = 0; i < 5; i++) { + while (rotation[i] >= 360.f) { + rotation[i] -= 360.f; + } + } +} + +int premul(int rgb, int a) { + int r = (rgb >> 16) * a + 1; + r = (r + (r >> 8)) >> 8; + int g = ((rgb >> 8) & 0xff) * a + 1; + g = (g + (g >> 8)) >> 8; + int b = (rgb & 0xff) * a + 1; + b = (b + (b >> 8)) >> 8; + return r << 16 | g << 8 | b; +} + +void makeTexture(int *src, int *dst, int rsid) { + + int x; + int y; + int pm = State->mPreMul; + + if (State->mProcessTextureMode == 1) { + int lowcol = State->mLowCol; + int highcol = State->mHighCol; + + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int pix = src[y*256+x]; + int lum = pix & 0x00ff; + int newpix; + if (lum < 128) { + newpix = lowcol; + int newalpha = 255 - (lum * 2); + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } else { + newpix = highcol; + int newalpha = (lum - 128) * 2; + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + alphafactor *= State->mAlphaMul; + } else if (State->mProcessTextureMode == 2) { + int lowcol = State->mLowCol; + int highcol = State->mHighCol; + float scale = 255.f / (255.f - lowcol); + + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int pix = src[y*256+x]; + int alpha = pix & 0x00ff; + if (alpha < lowcol) { + alpha = 0; + } else { + alpha = (alpha - lowcol) * scale; + } + alpha /= alphafactor; + int newpix = highcol; + if (pm) newpix = premul(newpix, alpha); + newpix = newpix | (alpha << 24); + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + alphafactor *= State->mAlphaMul; + } else if (State->mProcessTextureMode == 3) { + int lowcol = State->mLowCol; + int highcol = State->mHighCol; + float scale = 255.f / (255.f - lowcol); + + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int pix = src[y*256+x]; + int lum = pix & 0x00ff; + int newpix; + if (lum < 128) lum *= 2; + else lum = (255 - (lum - 128) * 2); + if (lum < 128) { + newpix = lowcol; + int newalpha = 255 - (lum * 2); + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } else { + newpix = highcol; + int newalpha = (lum - 128) * 2; + newalpha /= alphafactor; + if (pm) newpix = premul(newpix, newalpha); + newpix = newpix | (newalpha << 24); + } + // have ARGB, need ABGR + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + dst[y*256+x] = newpix; + } + } + alphafactor *= State->mAlphaMul; + } else { + + for (y=0;y<256;y++) { + for (x=0;x<256;x++) { + int rgb = *src++; + int a = (rgb >> 24) & 0xff; + rgb &= 0x00ffffff; + rgb = premul(rgb, a); + int newpix = (a << 24) | rgb; + newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) & 0xff); + *dst++ = newpix; + } + } + } + uploadToTexture(rsid, 0); +} + +void makeTextures() { + debugI32("makeTextures", State->mPreset); + alphafactor = 1.f; + makeTexture((int*)noisesrc1, (int*)noisedst1, NAMED_Tnoise1); + makeTexture((int*)noisesrc2, (int*)noisedst2, NAMED_Tnoise2); + makeTexture((int*)noisesrc3, (int*)noisedst3, NAMED_Tnoise3); + makeTexture((int*)noisesrc4, (int*)noisedst4, NAMED_Tnoise4); + makeTexture((int*)noisesrc5, (int*)noisedst5, NAMED_Tnoise5); +} + + + +struct color { + float r; + float g; + float b; +}; + +void init() { + int i; + for (i=0;i<4;i++) { + xshift[i] = 0.f; + rotation[i] = 360.f * i / 5.f; + } + scale[0] = 4.0f; // changed below based on preset + scale[1] = 3.0f; + scale[2] = 3.4f; + scale[3] = 3.8f; + scale[4] = 4.2f; + + currentpreset = -1; + lastuptime = uptimeMillis(); + timedelta = 0; +} + + +int main(int launchID) { + + int i; + float ident[16]; + float masterscale = 0.0041f;// / (State->mXOffset * 4.f + 1.f); + matrixLoadIdentity(ident); + matrixTranslate(ident, -State->mXOffset, 0.f, 0.f); + matrixScale(ident, masterscale, masterscale, masterscale); + //matrixRotate(ident, 0.f, 0.f, 0.f, 1.f); + matrixRotate(ident, -State->mTilt, 1.f, 0.f, 0.f); + + if (State->mBlendFunc) { + bindProgramStore(NAMED_PFSBackgroundOne); + } else { + bindProgramStore(NAMED_PFSBackgroundSrc); + } + + int now = uptimeMillis(); + timedelta = ((float)(now - lastuptime)) / 44.f; + lastuptime = now; + if (timedelta > 100) { + // If we didn't render anything for several seconds, just pretend time stopped. + timedelta = 1; + } + + i = State->mPreset; + if (i != currentpreset) { + currentpreset = i; + int rgb = State->mBackCol; + pfClearColor( + ((float)((rgb >> 16) & 0xff)) / 255.0f, + ((float)((rgb >> 8) & 0xff)) / 255.0f, + ((float)(rgb & 0xff)) / 255.0f, + 1.0f); + makeTextures(); + } + + if (State->mTextureSwap != 0) { + scale[0] = .25f; + } else { + scale[0] = 4.f; + } + drawClouds(ident); + + return 55; +} diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml new file mode 100644 index 0000000..4e2762f --- /dev/null +++ b/res/values-cs/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Magic Smoke Wallpapers"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magický kouř"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Kreslí kouř, mraky, vodu a plazmu."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Klepnutím změníte"</string> +</resources> diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml new file mode 100644 index 0000000..e4210cc --- /dev/null +++ b/res/values-da/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Tapeter med magisk røg"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magisk røg"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Tegner røg, skyer, vand og plasma."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Tast for at ændre"</string> +</resources> diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml new file mode 100644 index 0000000..d34ea82 --- /dev/null +++ b/res/values-de/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Magic Smoke Wallpapers"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magic Smoke"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Zeichnet Rauch, Wolken, Wasser und Plasmen."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Zum Ändern berühren"</string> +</resources> diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml new file mode 100644 index 0000000..3e9c79a --- /dev/null +++ b/res/values-el/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Ταπετσαρίες μαγικού καπνού"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Μαγικός καπνός"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Σκιαγραφεί καπνό, σύννεφα, νερό και αέρια."</string> + <string name="ok" msgid="2096612745586722488">"ΟΚ"</string> + <string name="taptochange" msgid="2128130912969723119">"Πατήστε για αλλαγή"</string> +</resources> diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml new file mode 100644 index 0000000..fe81395 --- /dev/null +++ b/res/values-es-rUS/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Fondos de pantalla humo mágico"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Humo mágico"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Dibuja humo, nubes, agua y plasmas."</string> + <string name="ok" msgid="2096612745586722488">"Aceptar"</string> + <string name="taptochange" msgid="2128130912969723119">"Presionar para cambiar:"</string> +</resources> diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml new file mode 100644 index 0000000..45c9fa7 --- /dev/null +++ b/res/values-es/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Fondos de pantalla de humo mágico"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Humo mágico"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Representa humo, nubes, agua y plasma."</string> + <string name="ok" msgid="2096612745586722488">"Aceptar"</string> + <string name="taptochange" msgid="2128130912969723119">"Tocar para cambiar"</string> +</resources> diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml new file mode 100644 index 0000000..410e881 --- /dev/null +++ b/res/values-fr/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Fonds d\'écran fumée magique"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Fumée magique"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Représente de la fumée, des nuages, de l\'eau et des matières liquides."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Appuyer pour modifier la sélection"</string> +</resources> diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml new file mode 100644 index 0000000..cdd91e8 --- /dev/null +++ b/res/values-it/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Sfondi fumo magico"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Fumo magico"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Traccia fumo, nuvole, acqua e plasma."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Tocca per cambiare"</string> +</resources> diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml new file mode 100644 index 0000000..95a63be --- /dev/null +++ b/res/values-ja/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"マジックスモーク壁紙"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"マジックスモーク"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"煙、雲、水、プラズマを描画します。"</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"タップで変更"</string> +</resources> diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml new file mode 100644 index 0000000..c63e455 --- /dev/null +++ b/res/values-ko/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"마법의 연기 배경화면"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"마법의 연기"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"연기와 구름, 물, 플라즈마를 그립니다."</string> + <string name="ok" msgid="2096612745586722488">"확인"</string> + <string name="taptochange" msgid="2128130912969723119">"눌러서 변경하기"</string> +</resources> diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml new file mode 100644 index 0000000..d76362b --- /dev/null +++ b/res/values-nb/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Bakgrunner med magisk røyk"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magisk røyk"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Viser røyk, skyer, vann og plasma"</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Tapp for å endre"</string> +</resources> diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml new file mode 100644 index 0000000..dfdbf4d --- /dev/null +++ b/res/values-nl/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Achtergronden met magische rook"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magische rook"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Tekent rook, wolken, water en plasmagassen."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Tik om te wijzigen"</string> +</resources> diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml new file mode 100644 index 0000000..01fd1fc --- /dev/null +++ b/res/values-pl/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Tapety z magicznym dymem"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magiczny dym"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Rysunek dymu, chmur, wody i plazmy"</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Dotknij, aby zmienić"</string> +</resources> diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml new file mode 100644 index 0000000..2e3b4fb --- /dev/null +++ b/res/values-pt-rPT/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Imagens de fundo de fumo mágico"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Fumo mágico"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Desenha fumo, nuvens, água e plasmas."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Toque para alterar"</string> +</resources> diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml new file mode 100644 index 0000000..30d6148 --- /dev/null +++ b/res/values-pt/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Planos de fundo de fumaça mágica"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Fumaça mágica"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Desenha fumaça, nuvens, água e plasmas."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Toque para alterar"</string> +</resources> diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml new file mode 100644 index 0000000..a5b4f5d --- /dev/null +++ b/res/values-ru/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Фоновые рисунки: волшебный дым"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Волшебный дым"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Показывает дым, облака, воду и плазму."</string> + <string name="ok" msgid="2096612745586722488">"ОК"</string> + <string name="taptochange" msgid="2128130912969723119">"Нажмите, чтобы изменить"</string> +</resources> diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml new file mode 100644 index 0000000..23c9002 --- /dev/null +++ b/res/values-sv/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Bakgrunder med magisk rök"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Magisk rök"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Bildar rök, moln, vatten och plasma."</string> + <string name="ok" msgid="2096612745586722488">"OK"</string> + <string name="taptochange" msgid="2128130912969723119">"Peka om du vill ändra"</string> +</resources> diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml new file mode 100644 index 0000000..167b68f --- /dev/null +++ b/res/values-tr/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"Sihirli Duman Duvar Kağıtları"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"Sihirli Duman"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"Duman, bulut, su ve plazmalar çizer."</string> + <string name="ok" msgid="2096612745586722488">"Tamam"</string> + <string name="taptochange" msgid="2128130912969723119">"Değiştirmek için hafifçe vurun"</string> +</resources> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..45440c1 --- /dev/null +++ b/res/values-zh-rCN/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"魔幻烟雾壁纸"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"魔幻烟雾"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"绘制烟雾、云、水和等离子体。"</string> + <string name="ok" msgid="2096612745586722488">"确定"</string> + <string name="taptochange" msgid="2128130912969723119">"点按可进行更改"</string> +</resources> diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml new file mode 100644 index 0000000..d32d105 --- /dev/null +++ b/res/values-zh-rTW/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2009 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. +--> +<resources xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string name="wallpapers" msgid="9040514152147134380">"魔法煙霧桌布"</string> + <string name="wallpaper_magicsmoke" msgid="1982855461335812678">"魔法煙霧"</string> + <string name="author" msgid="3728706901510651795">"Google"</string> + <string name="magicsmoke_desc" msgid="4882321171007683983">"繪製煙霧、雲朵、水和電漿。"</string> + <string name="ok" msgid="2096612745586722488">"確定"</string> + <string name="taptochange" msgid="2128130912969723119">"輕按以變更"</string> +</resources> diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..c92b122 --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +* Copyright (C) 2008 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. +*/ +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- General --> + <skip /> + <!-- Application name --> + <string name="wallpapers">Magic Smoke Wallpapers</string> + + <!-- Wallpapers showing smoke, clouds, water, plasmas --> + <string name="wallpaper_magicsmoke">Magic Smoke</string> + + <string name="author">Google</string> + <string name="magicsmoke_desc">Draws smoke, clouds, water and plasmas.</string> + + <!-- button label --> + <string name="ok">OK</string> + + <!-- overlay text --> + <string name="taptochange">Tap to change</string> +</resources> diff --git a/res/values/styles.xml b/res/values/styles.xml new file mode 100644 index 0000000..a55fbdb --- /dev/null +++ b/res/values/styles.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +* Copyright (C) 2008 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. +*/ +--> + +<resources> + <style name="WallpaperTitle"> + <item name="android:textSize">20dip</item> + <item name="android:shadowColor">#FF000000</item> + <item name="android:shadowRadius">2.5</item> + <item name="android:shadowDx">0</item> + <item name="android:shadowDy">0</item> + <item name="android:textColor">#FFFFFFFF</item> + <item name="android:gravity">left</item> + </style> + + <style name="Preview" parent="@android:style/Theme.NoTitleBar"> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:colorBackgroundCacheHint">@null</item> + <item name="android:windowAnimationStyle">@android:style/Animation.Activity</item> + </style> +</resources> diff --git a/res/xml/magicsmoke.xml b/res/xml/magicsmoke.xml new file mode 100644 index 0000000..f1f5cd2 --- /dev/null +++ b/res/xml/magicsmoke.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2009, 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. + */ +--> + +<!-- The attributes in this XML file provide configuration information --> +<!-- for the cube. --> + +<wallpaper xmlns:android="http://schemas.android.com/apk/res/android" + android:author="@string/author" + android:description="@string/magicsmoke_desc" + android:thumbnail="@drawable/magicsmoke_thumb" + android:settingsActivity="com.android.magicsmoke.MagicSmokeSelector" +/> diff --git a/src/com/android/magicsmoke/MagicSmoke.java b/src/com/android/magicsmoke/MagicSmoke.java new file mode 100644 index 0000000..e0ff258 --- /dev/null +++ b/src/com/android/magicsmoke/MagicSmoke.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2009 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. + */ + +package com.android.magicsmoke; + +public class MagicSmoke extends RenderScriptWallpaper<MagicSmokeRS> { + + @Override + protected MagicSmokeRS createScene(int width, int height) { + return new MagicSmokeRS(this, width, height); + } +} + diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java new file mode 100644 index 0000000..03a1106 --- /dev/null +++ b/src/com/android/magicsmoke/MagicSmokeRS.java @@ -0,0 +1,366 @@ +/* + * Copyright (C) 2009 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. + */ + +package com.android.magicsmoke; + +import static android.renderscript.ProgramFragment.EnvMode.REPLACE; +import static android.renderscript.Sampler.Value.LINEAR; +import static android.renderscript.Sampler.Value.WRAP; + +import com.android.magicsmoke.R; + +import android.content.Context; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.media.MediaPlayer; +import android.os.Handler; +import android.renderscript.Allocation; +import android.renderscript.Dimension; +import android.renderscript.Element; +import android.renderscript.Primitive; +import android.renderscript.ProgramFragment; +import android.renderscript.ProgramStore; +import android.renderscript.ProgramVertex; +import android.renderscript.Sampler; +import android.renderscript.ScriptC; +import android.renderscript.SimpleMesh; +import android.renderscript.Type; +import android.renderscript.Element.Builder; +import android.renderscript.ProgramStore.BlendDstFunc; +import android.renderscript.ProgramStore.BlendSrcFunc; +import android.util.Log; +import android.view.MotionEvent; + +import java.util.TimeZone; + +class MagicSmokeRS extends RenderScriptScene implements OnSharedPreferenceChangeListener { + + static class WorldState { + public float mXOffset; + public float mTilt; + public int mPreset; + public int mTextureMask; + public int mRotate; + public int mTextureSwap; + public int mProcessTextureMode; + public int mBackCol; + public int mLowCol; + public int mHighCol; + public float mAlphaMul; + public int mPreMul; + public int mBlendFunc; + } + WorldState mWorldState = new WorldState(); + private Type mStateType; + private Allocation mState; + + private ProgramStore mPfsBackgroundOne; + private ProgramStore mPfsBackgroundSrc; + private ProgramFragment mPfBackground; + private Sampler mSampler; + private Allocation[] mSourceTextures; + private Allocation[] mRealTextures; + + private ProgramVertex mPVBackground; + private ProgramVertex.MatrixAllocation mPVAlloc; + + private static final int RSID_STATE = 0; + //private static final int RSID_PROGRAMVERTEX = 3; + private static final int RSID_NOISESRC1 = 1; + private static final int RSID_NOISESRC2 = 2; + private static final int RSID_NOISESRC3 = 3; + private static final int RSID_NOISESRC4 = 4; + private static final int RSID_NOISESRC5 = 5; + private static final int RSID_NOISEDST1 = 6; + private static final int RSID_NOISEDST2 = 7; + private static final int RSID_NOISEDST3 = 8; + private static final int RSID_NOISEDST4 = 9; + private static final int RSID_NOISEDST5 = 10; + + private Context mContext; + private SharedPreferences mSharedPref; + + static class Preset { + Preset(int processmode, int backcol, int locol, int hicol, float mul, int mask, + boolean rot, int blend, boolean texswap, boolean premul) { + mProcessTextureMode = processmode; + mBackColor = backcol; + mLowColor = locol; + mHighColor = hicol; + mAlphaMul = mul; + mTextureMask = mask; + mRotate = rot; + mBlendFunc = blend; + mTextureSwap = texswap; + mPreMul = premul; + } + public int mProcessTextureMode; + public int mBackColor; + public int mLowColor; + public int mHighColor; + public float mAlphaMul; + public int mTextureMask; + public boolean mRotate; + public int mBlendFunc; + public boolean mTextureSwap; + public boolean mPreMul; + } + + public static final int DEFAULT_PRESET = 4; + public static final Preset [] mPreset = new Preset[] { + // proc back low high alph mask rot blend swap premul + new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false), + new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false), + new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false), + new Preset(1, 0x00ff00, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true), + new Preset(1, 0x00ff00, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, 0, true, true), + new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, 0, true, false), + new Preset(0, 0x000000, 0x000000, 0xffffff, 0.0f, 0x1f, true, 0, false, false), + new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, 0, true, false), + new Preset(1, 0x008000, 0x00ff00, 0xffffff, 2.5f, 0x1f, true, 0, true, false), + new Preset(1, 0x800000, 0xff0000, 0xffffff, 2.5f, 0x1f, true, 0, true, true), + new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true), + new Preset(1, 0x0000ff, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, true), + new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, false, 0, false, true), + new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 2.0f, 0x1f, true, 0, true, true), + new Preset(1, 0x0000ff, 0x00ff00, 0xffff00, 1.5f, 0x1f, true, 0, true, true), + new Preset(1, 0x808080, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, false, false), + new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, true, false), + new Preset(2, 0x000000, 0x000070, 0xff2020, 2.5f, 0x1f, true, 0, false, false), + new Preset(2, 0x6060ff, 0x000070, 0xffffff, 2.5f, 0x1f, true, 0, false, false), + new Preset(3, 0x0000f0, 0x000000, 0xffffff, 2.0f, 0x0f, true, 0, true, false), + }; + + private float mTouchY; + + MagicSmokeRS(Context context, int width, int height) { + super(width, height); + mWidth = width; + mHeight = height; + mWorldState.mTilt = 0; + mContext = context; + mSharedPref = mContext.getSharedPreferences("magicsmoke", Context.MODE_PRIVATE); + makeNewState(); + } + + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + + makeNewState(); + mState.data(mWorldState); + } + + void makeNewState() { + int p = mSharedPref.getInt("preset", DEFAULT_PRESET); + if (p >= mPreset.length) { + p = 0; + } + mWorldState.mPreset = p; + mWorldState.mTextureMask = mPreset[p].mTextureMask; + mWorldState.mRotate = mPreset[p].mRotate ? 1 : 0; + mWorldState.mTextureSwap = mPreset[p].mTextureSwap ? 1 : 0; + mWorldState.mProcessTextureMode = mPreset[p].mProcessTextureMode; + mWorldState.mBackCol = mPreset[p].mBackColor; + mWorldState.mLowCol = mPreset[p].mLowColor; + mWorldState.mHighCol = mPreset[p].mHighColor; + mWorldState.mAlphaMul = mPreset[p].mAlphaMul; + mWorldState.mPreMul = mPreset[p].mPreMul ? 1 : 0; + mWorldState.mBlendFunc = mPreset[p].mBlendFunc; + } + + @Override + public void resize(int width, int height) { + super.resize(width, height); + if (mPVAlloc != null) { + mPVAlloc.setupProjectionNormalized(width, height); + } + } + + @Override + public void onTouchEvent(MotionEvent event) { + switch(event.getAction()) { + case MotionEvent.ACTION_DOWN: + mTouchY = event.getY(); + break; + case MotionEvent.ACTION_MOVE: + float dy = event.getY() - mTouchY; + mTouchY += dy; + dy /= 20; + dy += mWorldState.mTilt; + if (dy > 4) { + dy = 4; + } else if (dy < -4) { + dy = -4; + } + mWorldState.mTilt = dy; + mState.data(mWorldState); + } + } + + @Override + public void setOffset(float xOffset, float yOffset, float xStep, float yStep, + int xPixels, int yPixels) { + // update our state, then push it to the renderscript + mWorldState.mXOffset = xOffset; + mState.data(mWorldState); + } + + @Override + public void stop() { + mSharedPref.unregisterOnSharedPreferenceChangeListener(this); + super.stop(); + } + + @Override + public void start() { + super.start(); + mSharedPref.registerOnSharedPreferenceChangeListener(this); + makeNewState(); + mState.data(mWorldState); + } + + float alphafactor; + Type mTextureType; + + void loadBitmap(int id, int index, String name, float alphamul, int lowcol, int highcol) { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inPreferredConfig = Bitmap.Config.ARGB_8888; + Bitmap in = BitmapFactory.decodeResource(mResources, id, opts); + + int pixels[] = new int[65536]; + in.getPixels(pixels, 0, 256, 0, 0, 256, 256); + mRealTextures[index] = Allocation.createTyped(mRS, mTextureType); + mSourceTextures[index] = Allocation.createTyped(mRS, mTextureType); + mSourceTextures[index].setName(name+"_src"); + mSourceTextures[index].data(pixels); + mRealTextures[index].setName(name); + in.recycle(); + } + + void loadBitmaps() { + alphafactor = 1f; + float alphamul = mPreset[mWorldState.mPreset].mAlphaMul; + int lowcol = mPreset[mWorldState.mPreset].mLowColor; + int highcol = mPreset[mWorldState.mPreset].mHighColor; + //Log.i("@@@@", "preset " + mWorldState.mPreset + ", mul: " + alphamul + + // ", colors: " + Integer.toHexString(lowcol) + "/" + Integer.toHexString(highcol)); + + // TODO: using different high and low colors for each layer offers some cool effects too + loadBitmap(R.drawable.noise1, 0, "Tnoise1", alphamul, lowcol, highcol); + loadBitmap(R.drawable.noise2, 1, "Tnoise2", alphamul, lowcol, highcol); + loadBitmap(R.drawable.noise3, 2, "Tnoise3", alphamul, lowcol, highcol); + loadBitmap(R.drawable.noise4, 3, "Tnoise4", alphamul, lowcol, highcol); + loadBitmap(R.drawable.noise5, 4, "Tnoise5", alphamul, lowcol, highcol); + } + + @Override + protected ScriptC createScript() { + + // Create a renderscript type from a java class. The specified name doesn't + // really matter; the name by which we refer to the object in RenderScript + // will be specified later. + mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState"); + // Create an allocation from the type we just created. + mState = Allocation.createTyped(mRS, mStateType); + mState.data(mWorldState); + + // First set up the coordinate system and such + ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); + mPVBackground = pvb.create(); + mPVBackground.setName("PVBackground"); + mPVAlloc = new ProgramVertex.MatrixAllocation(mRS); + mPVBackground.bindAllocation(mPVAlloc); + mPVAlloc.setupProjectionNormalized(mWidth, mHeight); + + mSourceTextures = new Allocation[5]; + mRealTextures = new Allocation[5]; + + Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS)); + tb.add(Dimension.X, 256); + tb.add(Dimension.Y, 256); + mTextureType = tb.create(); + loadBitmaps(); + + Sampler.Builder samplerBuilder = new Sampler.Builder(mRS); + samplerBuilder.setMin(LINEAR); + samplerBuilder.setMag(LINEAR); + samplerBuilder.setWrapS(WRAP); + samplerBuilder.setWrapT(WRAP); + mSampler = samplerBuilder.create(); + + { + ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null); + builder.setTexEnable(true, 0); + builder.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); + mPfBackground = builder.create(); + mPfBackground.setName("PFBackground"); + mPfBackground.bindSampler(mSampler, 0); + } + + { + ProgramStore.Builder builder = new ProgramStore.Builder(mRS, null, null); + builder.setDepthFunc(ProgramStore.DepthFunc.EQUAL); + builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE_MINUS_SRC_ALPHA); + builder.setDitherEnable(true); // without dithering there is severe banding + builder.setDepthMask(false); + mPfsBackgroundOne = builder.create(); + mPfsBackgroundOne.setName("PFSBackgroundOne"); + builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA); + mPfsBackgroundSrc = builder.create(); + mPfsBackgroundSrc.setName("PFSBackgroundSrc"); + } + + // Time to create the script + ScriptC.Builder sb = new ScriptC.Builder(mRS); + // Specify the name by which to refer to the WorldState object in the + // renderscript. + sb.setType(mStateType, "State", RSID_STATE); + sb.setType(mTextureType, "noisesrc1", RSID_NOISESRC1); + sb.setType(mTextureType, "noisedst1", RSID_NOISEDST1); + sb.setType(mTextureType, "noisesrc2", RSID_NOISESRC2); + sb.setType(mTextureType, "noisedst2", RSID_NOISEDST2); + sb.setType(mTextureType, "noisesrc3", RSID_NOISESRC3); + sb.setType(mTextureType, "noisedst3", RSID_NOISEDST3); + sb.setType(mTextureType, "noisesrc4", RSID_NOISESRC4); + sb.setType(mTextureType, "noisedst4", RSID_NOISEDST4); + sb.setType(mTextureType, "noisesrc5", RSID_NOISESRC5); + sb.setType(mTextureType, "noisedst5", RSID_NOISEDST5); + sb.setScript(mResources, R.raw.clouds); + sb.setRoot(true); + + ScriptC script = sb.create(); + script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f); + script.setTimeZone(TimeZone.getDefault().getID()); + + script.bindAllocation(mState, RSID_STATE); + script.bindAllocation(mSourceTextures[0], RSID_NOISESRC1); + script.bindAllocation(mRealTextures[0], RSID_NOISEDST1); + script.bindAllocation(mSourceTextures[1], RSID_NOISESRC2); + script.bindAllocation(mRealTextures[1], RSID_NOISEDST2); + script.bindAllocation(mSourceTextures[2], RSID_NOISESRC3); + script.bindAllocation(mRealTextures[2], RSID_NOISEDST3); + script.bindAllocation(mSourceTextures[3], RSID_NOISESRC4); + script.bindAllocation(mRealTextures[3], RSID_NOISEDST4); + script.bindAllocation(mSourceTextures[4], RSID_NOISESRC5); + script.bindAllocation(mRealTextures[4], RSID_NOISEDST5); + //script.bindAllocation(mPVAlloc.mAlloc, RSID_PROGRAMVERTEX); + + + return script; + } +} diff --git a/src/com/android/magicsmoke/MagicSmokeSelector.java b/src/com/android/magicsmoke/MagicSmokeSelector.java new file mode 100644 index 0000000..fbe335d --- /dev/null +++ b/src/com/android/magicsmoke/MagicSmokeSelector.java @@ -0,0 +1,234 @@ +/* + * Copyright (C) 2009 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. + */ + +package com.android.magicsmoke; + +import android.app.Activity; +import android.app.WallpaperManager; +import android.app.WallpaperInfo; +import android.app.Dialog; +import android.service.wallpaper.IWallpaperConnection; +import android.service.wallpaper.IWallpaperService; +import android.service.wallpaper.IWallpaperEngine; +import android.service.wallpaper.WallpaperSettingsActivity; +import android.content.ServiceConnection; +import android.content.Intent; +import android.content.Context; +import android.content.ComponentName; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.os.RemoteException; +import android.os.IBinder; +import android.os.ParcelFileDescriptor; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; +import android.view.WindowManager; +import android.view.ViewGroup; +import android.view.Window; +import android.view.LayoutInflater; +import android.util.Log; +import android.widget.TextView; + +public class MagicSmokeSelector extends Activity { + + private static final String LOG_TAG = "MagicSmokeSelector"; + + private WallpaperManager mWallpaperManager; + private WallpaperConnection mWallpaperConnection; + + private Intent mWallpaperIntent; + private SharedPreferences mSharedPref; + private int mCurrentPreset; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.selector); + + mWallpaperIntent = new Intent(this, MagicSmoke.class); + + mWallpaperManager = WallpaperManager.getInstance(this); + mWallpaperConnection = new WallpaperConnection(mWallpaperIntent); + + mSharedPref = getSharedPreferences("magicsmoke", Context.MODE_PRIVATE); + mCurrentPreset = mSharedPref.getInt("preset", MagicSmokeRS.DEFAULT_PRESET); + if (mCurrentPreset >= MagicSmokeRS.mPreset.length) { + mCurrentPreset = 0; + updatePrefs(); + } + } + + // button hook + public void setLiveWallpaper(View v) { + finish(); + } + + + @Override + public void onResume() { + super.onResume(); + if (mWallpaperConnection != null && mWallpaperConnection.mEngine != null) { + try { + mWallpaperConnection.mEngine.setVisibility(true); + } catch (RemoteException e) { + // Ignore + } + } + } + + @Override + public void onPause() { + super.onPause(); + if (mWallpaperConnection != null && mWallpaperConnection.mEngine != null) { + try { + mWallpaperConnection.mEngine.setVisibility(false); + } catch (RemoteException e) { + // Ignore + } + } + } + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + + if (!mWallpaperConnection.connect()) { + mWallpaperConnection = null; + } + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + if (mWallpaperConnection != null) { + mWallpaperConnection.disconnect(); + } + mWallpaperConnection = null; + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + // TODO: make this conditional on preview mode. Right now we + // don't get touch events in preview mode. + switch(event.getAction()) { + case MotionEvent.ACTION_DOWN: + if (mCurrentPreset == 0) { + mCurrentPreset = MagicSmokeRS.mPreset.length - 1; + } else { + mCurrentPreset--; + } + updatePrefs(); + return true; + } + + return super.onTouchEvent(event); + } + + private void updatePrefs() { + + Editor edit = mSharedPref.edit(); + edit.putInt("preset", mCurrentPreset); + edit.commit(); + + } + + class WallpaperConnection extends IWallpaperConnection.Stub implements ServiceConnection { + final Intent mIntent; + IWallpaperService mService; + IWallpaperEngine mEngine; + boolean mConnected; + + WallpaperConnection(Intent intent) { + mIntent = intent; + } + + public boolean connect() { + synchronized (this) { + if (!bindService(mIntent, this, Context.BIND_AUTO_CREATE)) { + return false; + } + + mConnected = true; + return true; + } + } + + public void disconnect() { + synchronized (this) { + mConnected = false; + if (mEngine != null) { + try { + mEngine.destroy(); + } catch (RemoteException e) { + // Ignore + } + mEngine = null; + } + unbindService(this); + mService = null; + } + } + + public void onServiceConnected(ComponentName name, IBinder service) { + if (mWallpaperConnection == this) { + mService = IWallpaperService.Stub.asInterface(service); + try { + final View view = findViewById(R.id.backgroundview); + final View root = view.getRootView(); + mService.attach(this, view.getWindowToken(), + WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY, + true, root.getWidth(), root.getHeight()); + } catch (RemoteException e) { + Log.w(LOG_TAG, "Failed attaching wallpaper; clearing", e); + } + } + } + + public void onServiceDisconnected(ComponentName name) { + mService = null; + mEngine = null; + if (mWallpaperConnection == this) { + Log.w(LOG_TAG, "Wallpaper service gone: " + name); + } + } + + public void attachEngine(IWallpaperEngine engine) { + synchronized (this) { + if (mConnected) { + mEngine = engine; + try { + engine.setVisibility(true); + } catch (RemoteException e) { + // Ignore + } + } else { + try { + engine.destroy(); + } catch (RemoteException e) { + // Ignore + } + } + } + } + + public ParcelFileDescriptor setWallpaper(String name) { + return null; + } + } +} diff --git a/src/com/android/magicsmoke/RenderScriptScene.java b/src/com/android/magicsmoke/RenderScriptScene.java new file mode 100644 index 0000000..446e01f --- /dev/null +++ b/src/com/android/magicsmoke/RenderScriptScene.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 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. + */ + + +package com.android.magicsmoke; + +import android.content.res.Resources; +import android.renderscript.RenderScript; +import android.renderscript.ScriptC; +import android.view.MotionEvent; + +public abstract class RenderScriptScene { + protected int mWidth; + protected int mHeight; + protected boolean mPreview; + protected Resources mResources; + protected RenderScript mRS; + protected ScriptC mScript; + + public RenderScriptScene(int width, int height) { + mWidth = width; + mHeight = height; + } + + public void init(RenderScript rs, Resources res, boolean isPreview) { + mRS = rs; + mResources = res; + mPreview = isPreview; + mScript = createScript(); + } + + public boolean isPreview() { + return mPreview; + } + + public int getWidth() { + return mWidth; + } + + public int getHeight() { + return mHeight; + } + + public Resources getResources() { + return mResources; + } + + public RenderScript getRS() { + return mRS; + } + + public ScriptC getScript() { + return mScript; + } + + protected abstract ScriptC createScript(); + + public void stop() { + mRS.contextBindRootScript(null); + } + + public void start() { + mRS.contextBindRootScript(mScript); + } + + public void resize(int width, int height) { + mWidth = width; + mHeight = height; + } + + @SuppressWarnings({"UnusedDeclaration"}) + public void setOffset(float xOffset, float yOffset, + float xStep, float yStep, int xPixels, int yPixels) { + } + public void onTouchEvent(MotionEvent event) { + } + +} diff --git a/src/com/android/magicsmoke/RenderScriptWallpaper.java b/src/com/android/magicsmoke/RenderScriptWallpaper.java new file mode 100644 index 0000000..87c8729 --- /dev/null +++ b/src/com/android/magicsmoke/RenderScriptWallpaper.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 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. + */ + + +package com.android.magicsmoke; + +import android.service.wallpaper.WallpaperService; +import android.renderscript.RenderScript; +import android.util.Log; +import android.view.MotionEvent; +import android.view.SurfaceHolder; +import android.view.Surface; + +public abstract class RenderScriptWallpaper<T extends RenderScriptScene> extends WallpaperService { + public Engine onCreateEngine() { + return new RenderScriptEngine(); + } + + protected abstract T createScene(int width, int height); + + private class RenderScriptEngine extends Engine { + private RenderScript mRs; + private T mRenderer; + + @Override + public void onCreate(SurfaceHolder surfaceHolder) { + super.onCreate(surfaceHolder); + setTouchEventsEnabled(true); + surfaceHolder.setSizeFromLayout(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + destroyRenderer(); + } + + private void destroyRenderer() { + if (mRenderer != null) { + mRenderer.stop(); + mRenderer = null; + } + if (mRs != null) { + mRs.destroy(); + mRs = null; + } + } + + @Override + public void onVisibilityChanged(boolean visible) { + super.onVisibilityChanged(visible); + if (mRenderer != null) { + if (visible) { + mRenderer.start(); + } else { + mRenderer.stop(); + } + } + } + + @Override + public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { + super.onSurfaceChanged(holder, format, width, height); + if (mRs != null) { + mRs.contextSetSurface(width, height, holder.getSurface()); + } + if (mRenderer == null) { + mRenderer = createScene(width, height); + mRenderer.init(mRs, getResources(), isPreview()); + mRenderer.start(); + } else { + mRenderer.resize(width, height); + } + } + + @Override + public void onTouchEvent(MotionEvent event) { + mRenderer.onTouchEvent(event); + } + + @Override + public void onOffsetsChanged(float xOffset, float yOffset, + float xStep, float yStep, int xPixels, int yPixels) { + mRenderer.setOffset(xOffset, yOffset, xStep, yStep, xPixels, yPixels); + } + + @Override + public void onSurfaceCreated(SurfaceHolder holder) { + super.onSurfaceCreated(holder); + + Surface surface = null; + while (surface == null) { + surface = holder.getSurface(); + } + mRs = new RenderScript(false, false); + mRs.contextSetPriority(RenderScript.Priority.LOW); + } + + @Override + public void onSurfaceDestroyed(SurfaceHolder holder) { + super.onSurfaceDestroyed(holder); + destroyRenderer(); + } + } +} |