Loading core/java/android/view/HardwareRenderer.java +22 −22 Original line number Diff line number Diff line Loading @@ -197,18 +197,18 @@ public abstract class HardwareRenderer { /** * Initializes the hardware renderer for the specified surface. * * @param holder The holder for the surface to hardware accelerate. * @param surface The surface to hardware accelerate * * @return True if the initialization was successful, false otherwise. */ abstract boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException; abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException; /** * Updates the hardware renderer for the specified surface. * * @param holder The holder for the surface to hardware accelerate * @param surface The surface to hardware accelerate */ abstract void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException; abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException; /** * Destroys the layers used by the specified view hierarchy. Loading @@ -229,9 +229,9 @@ public abstract class HardwareRenderer { * This method should be invoked whenever the current hardware renderer * context should be reset. * * @param holder The holder for the surface to hardware accelerate * @param surface The surface to hardware accelerate */ abstract void invalidate(SurfaceHolder holder); abstract void invalidate(Surface surface); /** * This method should be invoked to ensure the hardware renderer is in Loading Loading @@ -474,14 +474,14 @@ public abstract class HardwareRenderer { * * @param width The width of the drawing surface. * @param height The height of the drawing surface. * @param holder The target surface * @param surface The surface to hardware accelerate */ void initializeIfNeeded(int width, int height, SurfaceHolder holder) void initializeIfNeeded(int width, int height, Surface surface) throws Surface.OutOfResourcesException { if (isRequested()) { // We lost the gl context, so recreate it. if (!isEnabled()) { if (initialize(holder)) { if (initialize(surface)) { setup(width, height); } } Loading Loading @@ -742,10 +742,10 @@ public abstract class HardwareRenderer { } @Override boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException { boolean initialize(Surface surface) throws Surface.OutOfResourcesException { if (isRequested() && !isEnabled()) { initializeEgl(); mGl = createEglSurface(holder); mGl = createEglSurface(surface); mDestroyed = false; if (mGl != null) { Loading @@ -771,9 +771,9 @@ public abstract class HardwareRenderer { } @Override void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException { void updateSurface(Surface surface) throws Surface.OutOfResourcesException { if (isRequested() && isEnabled()) { createEglSurface(holder); createEglSurface(surface); } } Loading Loading @@ -888,7 +888,7 @@ public abstract class HardwareRenderer { Log.d(LOG_TAG, " SURFACE_TYPE = 0x" + Integer.toHexString(value[0])); } GL createEglSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException { GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException { // Check preconditions. if (sEgl == null) { throw new RuntimeException("egl not initialized"); Loading @@ -908,7 +908,7 @@ public abstract class HardwareRenderer { destroySurface(); // Create an EGL surface we can render into. if (!createSurface(holder)) { if (!createSurface(surface)) { return null; } Loading Loading @@ -982,7 +982,7 @@ public abstract class HardwareRenderer { } @Override void invalidate(SurfaceHolder holder) { void invalidate(Surface surface) { // Cancels any existing buffer to ensure we'll get a buffer // of the right size before we call eglSwapBuffers sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); Loading @@ -993,8 +993,8 @@ public abstract class HardwareRenderer { setEnabled(false); } if (holder.getSurface().isValid()) { if (!createSurface(holder)) { if (surface.isValid()) { if (!createSurface(surface)) { return; } Loading @@ -1006,8 +1006,8 @@ public abstract class HardwareRenderer { } } private boolean createSurface(SurfaceHolder holder) { mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null); private boolean createSurface(Surface surface) { mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, surface, null); if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) { int error = sEgl.eglGetError(); Loading core/java/android/view/ViewRootImpl.java +5 −4 Original line number Diff line number Diff line Loading @@ -1500,7 +1500,8 @@ public final class ViewRootImpl implements ViewParent, if (mAttachInfo.mHardwareRenderer != null) { try { hwInitialized = mAttachInfo.mHardwareRenderer.initialize(mHolder); hwInitialized = mAttachInfo.mHardwareRenderer.initialize( mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException initializing HW surface", e); try { Loading Loading @@ -1533,7 +1534,7 @@ public final class ViewRootImpl implements ViewParent, mSurfaceHolder == null && mAttachInfo.mHardwareRenderer != null) { mFullRedrawNeeded = true; try { mAttachInfo.mHardwareRenderer.updateSurface(mHolder); mAttachInfo.mHardwareRenderer.updateSurface(mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException updating HW surface", e); try { Loading Loading @@ -1624,7 +1625,7 @@ public final class ViewRootImpl implements ViewParent, mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); if (!hwInitialized) { mAttachInfo.mHardwareRenderer.invalidate(mHolder); mAttachInfo.mHardwareRenderer.invalidate(mHolder.getSurface()); } } } Loading Loading @@ -2887,7 +2888,7 @@ public final class ViewRootImpl implements ViewParent, mFullRedrawNeeded = true; try { mAttachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, mHolder); mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException locking surface", e); try { Loading opengl/java/com/google/android/gles_jni/EGLImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public class EGLImpl implements EGL10 { } else if (native_window instanceof SurfaceHolder) { SurfaceHolder holder = (SurfaceHolder)native_window; sur = holder.getSurface(); } else if (native_window instanceof Surface) { sur = (Surface) native_window; } int eglSurfaceId; Loading @@ -94,8 +96,7 @@ public class EGLImpl implements EGL10 { } else { throw new java.lang.UnsupportedOperationException( "eglCreateWindowSurface() can only be called with an instance of " + "SurfaceView, SurfaceHolder or SurfaceTexture at the moment, " + "this will be fixed later."); "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment."); } if (eglSurfaceId == 0) { Loading tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java +4 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.Activity; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.opengl.GLUtils; import android.os.Bundle; Loading Loading @@ -278,7 +277,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return texture; } private int buildProgram(String vertex, String fragment) { private static int buildProgram(String vertex, String fragment) { int vertexShader = buildShader(vertex, GL_VERTEX_SHADER); if (vertexShader == 0) return 0; Loading Loading @@ -309,7 +308,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return program; } private int buildShader(String source, int type) { private static int buildShader(String source, int type) { int shader = glCreateShader(type); glShaderSource(shader, source); Loading Loading @@ -337,7 +336,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa } } private void checkGlError() { private static void checkGlError() { int error = glGetError(); if (error != GL_NO_ERROR) { Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error)); Loading Loading @@ -420,7 +419,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return null; } private int[] getConfig() { private static int[] getConfig() { return new int[] { EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, Loading Loading
core/java/android/view/HardwareRenderer.java +22 −22 Original line number Diff line number Diff line Loading @@ -197,18 +197,18 @@ public abstract class HardwareRenderer { /** * Initializes the hardware renderer for the specified surface. * * @param holder The holder for the surface to hardware accelerate. * @param surface The surface to hardware accelerate * * @return True if the initialization was successful, false otherwise. */ abstract boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException; abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException; /** * Updates the hardware renderer for the specified surface. * * @param holder The holder for the surface to hardware accelerate * @param surface The surface to hardware accelerate */ abstract void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException; abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException; /** * Destroys the layers used by the specified view hierarchy. Loading @@ -229,9 +229,9 @@ public abstract class HardwareRenderer { * This method should be invoked whenever the current hardware renderer * context should be reset. * * @param holder The holder for the surface to hardware accelerate * @param surface The surface to hardware accelerate */ abstract void invalidate(SurfaceHolder holder); abstract void invalidate(Surface surface); /** * This method should be invoked to ensure the hardware renderer is in Loading Loading @@ -474,14 +474,14 @@ public abstract class HardwareRenderer { * * @param width The width of the drawing surface. * @param height The height of the drawing surface. * @param holder The target surface * @param surface The surface to hardware accelerate */ void initializeIfNeeded(int width, int height, SurfaceHolder holder) void initializeIfNeeded(int width, int height, Surface surface) throws Surface.OutOfResourcesException { if (isRequested()) { // We lost the gl context, so recreate it. if (!isEnabled()) { if (initialize(holder)) { if (initialize(surface)) { setup(width, height); } } Loading Loading @@ -742,10 +742,10 @@ public abstract class HardwareRenderer { } @Override boolean initialize(SurfaceHolder holder) throws Surface.OutOfResourcesException { boolean initialize(Surface surface) throws Surface.OutOfResourcesException { if (isRequested() && !isEnabled()) { initializeEgl(); mGl = createEglSurface(holder); mGl = createEglSurface(surface); mDestroyed = false; if (mGl != null) { Loading @@ -771,9 +771,9 @@ public abstract class HardwareRenderer { } @Override void updateSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException { void updateSurface(Surface surface) throws Surface.OutOfResourcesException { if (isRequested() && isEnabled()) { createEglSurface(holder); createEglSurface(surface); } } Loading Loading @@ -888,7 +888,7 @@ public abstract class HardwareRenderer { Log.d(LOG_TAG, " SURFACE_TYPE = 0x" + Integer.toHexString(value[0])); } GL createEglSurface(SurfaceHolder holder) throws Surface.OutOfResourcesException { GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException { // Check preconditions. if (sEgl == null) { throw new RuntimeException("egl not initialized"); Loading @@ -908,7 +908,7 @@ public abstract class HardwareRenderer { destroySurface(); // Create an EGL surface we can render into. if (!createSurface(holder)) { if (!createSurface(surface)) { return null; } Loading Loading @@ -982,7 +982,7 @@ public abstract class HardwareRenderer { } @Override void invalidate(SurfaceHolder holder) { void invalidate(Surface surface) { // Cancels any existing buffer to ensure we'll get a buffer // of the right size before we call eglSwapBuffers sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); Loading @@ -993,8 +993,8 @@ public abstract class HardwareRenderer { setEnabled(false); } if (holder.getSurface().isValid()) { if (!createSurface(holder)) { if (surface.isValid()) { if (!createSurface(surface)) { return; } Loading @@ -1006,8 +1006,8 @@ public abstract class HardwareRenderer { } } private boolean createSurface(SurfaceHolder holder) { mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, holder, null); private boolean createSurface(Surface surface) { mEglSurface = sEgl.eglCreateWindowSurface(sEglDisplay, sEglConfig, surface, null); if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) { int error = sEgl.eglGetError(); Loading
core/java/android/view/ViewRootImpl.java +5 −4 Original line number Diff line number Diff line Loading @@ -1500,7 +1500,8 @@ public final class ViewRootImpl implements ViewParent, if (mAttachInfo.mHardwareRenderer != null) { try { hwInitialized = mAttachInfo.mHardwareRenderer.initialize(mHolder); hwInitialized = mAttachInfo.mHardwareRenderer.initialize( mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException initializing HW surface", e); try { Loading Loading @@ -1533,7 +1534,7 @@ public final class ViewRootImpl implements ViewParent, mSurfaceHolder == null && mAttachInfo.mHardwareRenderer != null) { mFullRedrawNeeded = true; try { mAttachInfo.mHardwareRenderer.updateSurface(mHolder); mAttachInfo.mHardwareRenderer.updateSurface(mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException updating HW surface", e); try { Loading Loading @@ -1624,7 +1625,7 @@ public final class ViewRootImpl implements ViewParent, mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); if (!hwInitialized) { mAttachInfo.mHardwareRenderer.invalidate(mHolder); mAttachInfo.mHardwareRenderer.invalidate(mHolder.getSurface()); } } } Loading Loading @@ -2887,7 +2888,7 @@ public final class ViewRootImpl implements ViewParent, mFullRedrawNeeded = true; try { mAttachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, mHolder); mHolder.getSurface()); } catch (Surface.OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException locking surface", e); try { Loading
opengl/java/com/google/android/gles_jni/EGLImpl.java +3 −2 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public class EGLImpl implements EGL10 { } else if (native_window instanceof SurfaceHolder) { SurfaceHolder holder = (SurfaceHolder)native_window; sur = holder.getSurface(); } else if (native_window instanceof Surface) { sur = (Surface) native_window; } int eglSurfaceId; Loading @@ -94,8 +96,7 @@ public class EGLImpl implements EGL10 { } else { throw new java.lang.UnsupportedOperationException( "eglCreateWindowSurface() can only be called with an instance of " + "SurfaceView, SurfaceHolder or SurfaceTexture at the moment, " + "this will be fixed later."); "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment."); } if (eglSurfaceId == 0) { Loading
tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java +4 −5 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.app.Activity; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.opengl.GLUtils; import android.os.Bundle; Loading Loading @@ -278,7 +277,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return texture; } private int buildProgram(String vertex, String fragment) { private static int buildProgram(String vertex, String fragment) { int vertexShader = buildShader(vertex, GL_VERTEX_SHADER); if (vertexShader == 0) return 0; Loading Loading @@ -309,7 +308,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return program; } private int buildShader(String source, int type) { private static int buildShader(String source, int type) { int shader = glCreateShader(type); glShaderSource(shader, source); Loading Loading @@ -337,7 +336,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa } } private void checkGlError() { private static void checkGlError() { int error = glGetError(); if (error != GL_NO_ERROR) { Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error)); Loading Loading @@ -420,7 +419,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa return null; } private int[] getConfig() { private static int[] getConfig() { return new int[] { EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, Loading