Loading packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +13 −16 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ package com.android.systemui; import android.content.Context; import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.os.Build; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.SurfaceHolder; import com.android.systemui.glwallpaper.ImageWallpaperRenderer; Loading @@ -33,16 +31,8 @@ import com.android.systemui.glwallpaper.ImageWallpaperRenderer; public class ImageWallpaper extends WallpaperService { private static final String TAG = ImageWallpaper.class.getSimpleName(); @Override public void onCreate() { super.onCreate(); } @Override public Engine onCreateEngine() { if (Build.IS_DEBUGGABLE) { Log.v(TAG, "We are using GLEngine"); } return new GLEngine(this); } Loading Loading @@ -72,8 +62,15 @@ public class ImageWallpaper extends WallpaperService { } } @Override public void onDestroy() { if (mWallpaperSurfaceView != null) { mWallpaperSurfaceView.onPause(); } } private class GLWallpaperSurfaceView extends GLSurfaceView implements ImageGLView { private WallpaperStatusListener mWallpaperChangedListener; private WallpaperStatusListener mWallpaperStatusListener; GLWallpaperSurfaceView(Context context) { super(context); Loading @@ -88,18 +85,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void setRenderer(Renderer renderer) { super.setRenderer(renderer); mWallpaperChangedListener = (WallpaperStatusListener) renderer; mWallpaperStatusListener = (WallpaperStatusListener) renderer; } private void notifyAmbientModeChanged(boolean inAmbient, long duration) { if (mWallpaperChangedListener != null) { mWallpaperChangedListener.onAmbientModeChanged(inAmbient, duration); if (mWallpaperStatusListener != null) { mWallpaperStatusListener.onAmbientModeChanged(inAmbient, duration); } } private void notifyOffsetsChanged(float xOffset, float yOffset) { if (mWallpaperChangedListener != null) { mWallpaperChangedListener.onOffsetsChanged( if (mWallpaperStatusListener != null) { mWallpaperStatusListener.onOffsetsChanged( xOffset, yOffset, getHolder().getSurfaceFrame()); } } Loading packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java +6 −12 Original line number Diff line number Diff line Loading @@ -110,9 +110,10 @@ class ImageGLWallpaper { mTextureBuffer.position(0); } void setup() { void setup(Bitmap bitmap) { setupAttributes(); setupUniforms(); setupTexture(bitmap); } private void setupAttributes() { Loading Loading @@ -159,7 +160,7 @@ class ImageGLWallpaper { glDrawArrays(GL_TRIANGLES, 0, VERTICES.length / 2); } void setupTexture(Bitmap bitmap) { private void setupTexture(Bitmap bitmap) { final int[] tids = new int[1]; if (bitmap == null) { Loading @@ -174,7 +175,7 @@ class ImageGLWallpaper { return; } // Bind a named texture to a texturing target. // Bind a named texture to a target. glBindTexture(GL_TEXTURE_2D, tids[0]); // Load the bitmap data and copy it over into the texture object that is currently bound. GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0); Loading @@ -195,15 +196,8 @@ class ImageGLWallpaper { glUniform1i(mUniTexture, 0); } void adjustTextureCoordinates(Bitmap bitmap, int surfaceWidth, int surfaceHeight, float xOffset, float yOffset) { if (bitmap == null) { Log.d(TAG, "adjustTextureCoordinates: invalid bitmap"); return; } int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); void adjustTextureCoordinates(int bitmapWidth, int bitmapHeight, int surfaceWidth, int surfaceHeight, float xOffset, float yOffset) { float ratioW = 1f; float ratioH = 1f; float rX = 0f; Loading packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java +16 −13 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, private int mWidth = 0; private int mHeight = 0; private Bitmap mBitmap; private int mBitmapWidth = 0; private int mBitmapHeight = 0; public ImageWallpaperRenderer(Context context, ImageGLView glView) { mWallpaperManager = context.getSystemService(WallpaperManager.class); if (mWallpaperManager == null) { Loading @@ -71,8 +75,12 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, mGLView = glView; if (mWallpaperManager != null) { mBitmap = mWallpaperManager.getBitmap(); mBitmapWidth = mBitmap.getWidth(); mBitmapHeight = mBitmap.getHeight(); // Compute per85 as transition threshold, this is an async work. mImageProcessHelper.startComputingPercentile85(mWallpaperManager.getBitmap()); mImageProcessHelper.startComputingPercentile85(mBitmap); mWallpaperManager.forgetLoadedWallpaper(); } } Loading @@ -81,8 +89,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, glClearColor(0f, 0f, 0f, 1.0f); mProgram.useGLProgram( R.raw.image_wallpaper_vertex_shader, R.raw.image_wallpaper_fragment_shader); mWallpaper.setup(); mWallpaper.setupTexture(mWallpaperManager.getBitmap()); mWallpaper.setup(mBitmap); mBitmap = null; } @Override Loading @@ -94,8 +102,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, } mWidth = width; mHeight = height; mWallpaper.adjustTextureCoordinates(mWallpaperManager.getBitmap(), width, height, mXOffset, mYOffset); mWallpaper.adjustTextureCoordinates( mBitmapWidth, mBitmapHeight, width, height, mXOffset, mYOffset); } @Override Loading Loading @@ -132,13 +140,7 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, @Override public void onOffsetsChanged(float xOffset, float yOffset, Rect frame) { if (frame == null || mWallpaperManager == null || (xOffset == mXOffset && yOffset == mYOffset)) { return; } Bitmap bitmap = mWallpaperManager.getBitmap(); if (bitmap == null) { if (frame == null || (xOffset == mXOffset && yOffset == mYOffset)) { return; } Loading @@ -151,7 +153,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, Log.d(TAG, "onOffsetsChanged: width=" + width + ", height=" + height + ", xOffset=" + mXOffset + ", yOffset=" + mYOffset); } mWallpaper.adjustTextureCoordinates(bitmap, width, height, mXOffset, mYOffset); mWallpaper.adjustTextureCoordinates( mBitmapWidth, mBitmapHeight, width, height, mXOffset, mYOffset); requestRender(); } Loading Loading
packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +13 −16 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ package com.android.systemui; import android.content.Context; import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.os.Build; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.SurfaceHolder; import com.android.systemui.glwallpaper.ImageWallpaperRenderer; Loading @@ -33,16 +31,8 @@ import com.android.systemui.glwallpaper.ImageWallpaperRenderer; public class ImageWallpaper extends WallpaperService { private static final String TAG = ImageWallpaper.class.getSimpleName(); @Override public void onCreate() { super.onCreate(); } @Override public Engine onCreateEngine() { if (Build.IS_DEBUGGABLE) { Log.v(TAG, "We are using GLEngine"); } return new GLEngine(this); } Loading Loading @@ -72,8 +62,15 @@ public class ImageWallpaper extends WallpaperService { } } @Override public void onDestroy() { if (mWallpaperSurfaceView != null) { mWallpaperSurfaceView.onPause(); } } private class GLWallpaperSurfaceView extends GLSurfaceView implements ImageGLView { private WallpaperStatusListener mWallpaperChangedListener; private WallpaperStatusListener mWallpaperStatusListener; GLWallpaperSurfaceView(Context context) { super(context); Loading @@ -88,18 +85,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void setRenderer(Renderer renderer) { super.setRenderer(renderer); mWallpaperChangedListener = (WallpaperStatusListener) renderer; mWallpaperStatusListener = (WallpaperStatusListener) renderer; } private void notifyAmbientModeChanged(boolean inAmbient, long duration) { if (mWallpaperChangedListener != null) { mWallpaperChangedListener.onAmbientModeChanged(inAmbient, duration); if (mWallpaperStatusListener != null) { mWallpaperStatusListener.onAmbientModeChanged(inAmbient, duration); } } private void notifyOffsetsChanged(float xOffset, float yOffset) { if (mWallpaperChangedListener != null) { mWallpaperChangedListener.onOffsetsChanged( if (mWallpaperStatusListener != null) { mWallpaperStatusListener.onOffsetsChanged( xOffset, yOffset, getHolder().getSurfaceFrame()); } } Loading
packages/SystemUI/src/com/android/systemui/glwallpaper/ImageGLWallpaper.java +6 −12 Original line number Diff line number Diff line Loading @@ -110,9 +110,10 @@ class ImageGLWallpaper { mTextureBuffer.position(0); } void setup() { void setup(Bitmap bitmap) { setupAttributes(); setupUniforms(); setupTexture(bitmap); } private void setupAttributes() { Loading Loading @@ -159,7 +160,7 @@ class ImageGLWallpaper { glDrawArrays(GL_TRIANGLES, 0, VERTICES.length / 2); } void setupTexture(Bitmap bitmap) { private void setupTexture(Bitmap bitmap) { final int[] tids = new int[1]; if (bitmap == null) { Loading @@ -174,7 +175,7 @@ class ImageGLWallpaper { return; } // Bind a named texture to a texturing target. // Bind a named texture to a target. glBindTexture(GL_TEXTURE_2D, tids[0]); // Load the bitmap data and copy it over into the texture object that is currently bound. GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0); Loading @@ -195,15 +196,8 @@ class ImageGLWallpaper { glUniform1i(mUniTexture, 0); } void adjustTextureCoordinates(Bitmap bitmap, int surfaceWidth, int surfaceHeight, float xOffset, float yOffset) { if (bitmap == null) { Log.d(TAG, "adjustTextureCoordinates: invalid bitmap"); return; } int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); void adjustTextureCoordinates(int bitmapWidth, int bitmapHeight, int surfaceWidth, int surfaceHeight, float xOffset, float yOffset) { float ratioW = 1f; float ratioH = 1f; float rX = 0f; Loading
packages/SystemUI/src/com/android/systemui/glwallpaper/ImageWallpaperRenderer.java +16 −13 Original line number Diff line number Diff line Loading @@ -58,6 +58,10 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, private int mWidth = 0; private int mHeight = 0; private Bitmap mBitmap; private int mBitmapWidth = 0; private int mBitmapHeight = 0; public ImageWallpaperRenderer(Context context, ImageGLView glView) { mWallpaperManager = context.getSystemService(WallpaperManager.class); if (mWallpaperManager == null) { Loading @@ -71,8 +75,12 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, mGLView = glView; if (mWallpaperManager != null) { mBitmap = mWallpaperManager.getBitmap(); mBitmapWidth = mBitmap.getWidth(); mBitmapHeight = mBitmap.getHeight(); // Compute per85 as transition threshold, this is an async work. mImageProcessHelper.startComputingPercentile85(mWallpaperManager.getBitmap()); mImageProcessHelper.startComputingPercentile85(mBitmap); mWallpaperManager.forgetLoadedWallpaper(); } } Loading @@ -81,8 +89,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, glClearColor(0f, 0f, 0f, 1.0f); mProgram.useGLProgram( R.raw.image_wallpaper_vertex_shader, R.raw.image_wallpaper_fragment_shader); mWallpaper.setup(); mWallpaper.setupTexture(mWallpaperManager.getBitmap()); mWallpaper.setup(mBitmap); mBitmap = null; } @Override Loading @@ -94,8 +102,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, } mWidth = width; mHeight = height; mWallpaper.adjustTextureCoordinates(mWallpaperManager.getBitmap(), width, height, mXOffset, mYOffset); mWallpaper.adjustTextureCoordinates( mBitmapWidth, mBitmapHeight, width, height, mXOffset, mYOffset); } @Override Loading Loading @@ -132,13 +140,7 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, @Override public void onOffsetsChanged(float xOffset, float yOffset, Rect frame) { if (frame == null || mWallpaperManager == null || (xOffset == mXOffset && yOffset == mYOffset)) { return; } Bitmap bitmap = mWallpaperManager.getBitmap(); if (bitmap == null) { if (frame == null || (xOffset == mXOffset && yOffset == mYOffset)) { return; } Loading @@ -151,7 +153,8 @@ public class ImageWallpaperRenderer implements GLSurfaceView.Renderer, Log.d(TAG, "onOffsetsChanged: width=" + width + ", height=" + height + ", xOffset=" + mXOffset + ", yOffset=" + mYOffset); } mWallpaper.adjustTextureCoordinates(bitmap, width, height, mXOffset, mYOffset); mWallpaper.adjustTextureCoordinates( mBitmapWidth, mBitmapHeight, width, height, mXOffset, mYOffset); requestRender(); } Loading