Loading api/current.txt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -9919,7 +9919,7 @@ package android.graphics { method public abstract void onFrameAvailable(android.graphics.SurfaceTexture); method public abstract void onFrameAvailable(android.graphics.SurfaceTexture); } } public static class SurfaceTexture.OutOfResourcesException extends java.lang.Exception { public static deprecated class SurfaceTexture.OutOfResourcesException extends java.lang.Exception { ctor public SurfaceTexture.OutOfResourcesException(); ctor public SurfaceTexture.OutOfResourcesException(); ctor public SurfaceTexture.OutOfResourcesException(java.lang.String); ctor public SurfaceTexture.OutOfResourcesException(java.lang.String); } } Loading Loading @@ -27304,7 +27304,7 @@ package android.view { field public static final int ROTATION_90 = 1; // 0x1 field public static final int ROTATION_90 = 1; // 0x1 } } public static class Surface.OutOfResourcesException extends java.lang.Exception { public static class Surface.OutOfResourcesException extends java.lang.RuntimeException { ctor public Surface.OutOfResourcesException(); ctor public Surface.OutOfResourcesException(); ctor public Surface.OutOfResourcesException(java.lang.String); ctor public Surface.OutOfResourcesException(java.lang.String); } } core/java/android/view/HardwareRenderer.java +58 −56 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.os.SystemProperties; import android.os.Trace; import android.os.Trace; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Log; import android.util.Log; import android.view.Surface.OutOfResourcesException; import com.google.android.gles_jni.EGLImpl; import com.google.android.gles_jni.EGLImpl; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10; Loading Loading @@ -270,14 +272,14 @@ public abstract class HardwareRenderer { * * * @return True if the initialization was successful, false otherwise. * @return True if the initialization was successful, false otherwise. */ */ abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException; abstract boolean initialize(Surface surface) throws OutOfResourcesException; /** /** * Updates the hardware renderer for the specified surface. * Updates the hardware renderer for the specified surface. * * * @param surface The surface to hardware accelerate * @param surface The surface to hardware accelerate */ */ abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException; abstract void updateSurface(Surface surface) throws OutOfResourcesException; /** /** * Destroys the layers used by the specified view hierarchy. * Destroys the layers used by the specified view hierarchy. Loading Loading @@ -596,7 +598,7 @@ public abstract class HardwareRenderer { * false might mean that the surface was already initialized. * false might mean that the surface was already initialized. */ */ boolean initializeIfNeeded(int width, int height, Surface surface) boolean initializeIfNeeded(int width, int height, Surface surface) throws Surface.OutOfResourcesException { throws OutOfResourcesException { if (isRequested()) { if (isRequested()) { // We lost the gl context, so recreate it. // We lost the gl context, so recreate it. if (!isEnabled()) { if (!isEnabled()) { Loading Loading @@ -1050,7 +1052,7 @@ public abstract class HardwareRenderer { } } @Override @Override boolean initialize(Surface surface) throws Surface.OutOfResourcesException { boolean initialize(Surface surface) throws OutOfResourcesException { if (isRequested() && !isEnabled()) { if (isRequested() && !isEnabled()) { boolean contextCreated = initializeEgl(); boolean contextCreated = initializeEgl(); mGl = createEglSurface(surface); mGl = createEglSurface(surface); Loading Loading @@ -1080,7 +1082,7 @@ public abstract class HardwareRenderer { } } @Override @Override void updateSurface(Surface surface) throws Surface.OutOfResourcesException { void updateSurface(Surface surface) throws OutOfResourcesException { if (isRequested() && isEnabled()) { if (isRequested() && isEnabled()) { createEglSurface(surface); createEglSurface(surface); } } Loading Loading @@ -1216,7 +1218,7 @@ public abstract class HardwareRenderer { Log.d(LOG_TAG, " CONFIG_CAVEAT = 0x" + Integer.toHexString(value[0])); Log.d(LOG_TAG, " CONFIG_CAVEAT = 0x" + Integer.toHexString(value[0])); } } GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException { GL createEglSurface(Surface surface) throws OutOfResourcesException { // Check preconditions. // Check preconditions. if (sEgl == null) { if (sEgl == null) { throw new RuntimeException("egl not initialized"); throw new RuntimeException("egl not initialized"); Loading core/java/android/view/Surface.java +12 −11 Original line number Original line Diff line number Diff line Loading @@ -116,6 +116,7 @@ public class Surface implements Parcelable { * * * @param surfaceTexture The {@link SurfaceTexture} that is updated by this * @param surfaceTexture The {@link SurfaceTexture} that is updated by this * Surface. * Surface. * @throws OutOfResourcesException if the surface could not be created. */ */ public Surface(SurfaceTexture surfaceTexture) { public Surface(SurfaceTexture surfaceTexture) { if (surfaceTexture == null) { if (surfaceTexture == null) { Loading @@ -124,12 +125,7 @@ public class Surface implements Parcelable { synchronized (mLock) { synchronized (mLock) { mName = surfaceTexture.toString(); mName = surfaceTexture.toString(); try { setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture)); setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture)); } catch (OutOfResourcesException ex) { // We can't throw OutOfResourcesException because it would be an API change. throw new RuntimeException(ex); } } } } } Loading Loading @@ -229,9 +225,12 @@ public class Surface implements Parcelable { * The caller may also pass <code>null</code> instead, in the case where the * The caller may also pass <code>null</code> instead, in the case where the * entire surface should be redrawn. * entire surface should be redrawn. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. * * @throws IllegalArgumentException If the inOutDirty rectangle is not valid. * @throws OutOfResourcesException If the canvas cannot be locked. */ */ public Canvas lockCanvas(Rect inOutDirty) public Canvas lockCanvas(Rect inOutDirty) throws OutOfResourcesException, IllegalArgumentException { throws Surface.OutOfResourcesException, IllegalArgumentException { synchronized (mLock) { synchronized (mLock) { checkNotReleasedLocked(); checkNotReleasedLocked(); if (mLockedObject != 0) { if (mLockedObject != 0) { Loading @@ -239,7 +238,7 @@ public class Surface implements Parcelable { // double-lock, but that won't happen if mNativeObject was updated. We can't // double-lock, but that won't happen if mNativeObject was updated. We can't // abandon the old mLockedObject because it might still be in use, so instead // abandon the old mLockedObject because it might still be in use, so instead // we just refuse to re-lock the Surface. // we just refuse to re-lock the Surface. throw new RuntimeException("Surface was already locked"); throw new IllegalStateException("Surface was already locked"); } } mLockedObject = nativeLockCanvas(mNativeObject, mCanvas, inOutDirty); mLockedObject = nativeLockCanvas(mNativeObject, mCanvas, inOutDirty); return mCanvas; return mCanvas; Loading @@ -266,7 +265,7 @@ public class Surface implements Parcelable { Integer.toHexString(mLockedObject) +")"); Integer.toHexString(mLockedObject) +")"); } } if (mLockedObject == 0) { if (mLockedObject == 0) { throw new RuntimeException("Surface was not locked"); throw new IllegalStateException("Surface was not locked"); } } nativeUnlockCanvasAndPost(mLockedObject, canvas); nativeUnlockCanvasAndPost(mLockedObject, canvas); nativeRelease(mLockedObject); nativeRelease(mLockedObject); Loading Loading @@ -411,9 +410,11 @@ public class Surface implements Parcelable { } } /** /** * Exception thrown when a surface couldn't be created or resized. * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or * when a SurfaceTexture could not successfully be allocated. */ */ public static class OutOfResourcesException extends Exception { @SuppressWarnings("serial") public static class OutOfResourcesException extends RuntimeException { public OutOfResourcesException() { public OutOfResourcesException() { } } public OutOfResourcesException(String name) { public OutOfResourcesException(String name) { Loading core/java/android/view/SurfaceControl.java +4 −12 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.view.Surface; import android.os.IBinder; import android.os.IBinder; import android.os.SystemProperties; import android.os.SystemProperties; import android.util.Log; import android.util.Log; import android.view.Surface.OutOfResourcesException; /** /** * SurfaceControl * SurfaceControl Loading Loading @@ -75,23 +76,12 @@ public class SurfaceControl { private final CloseGuard mCloseGuard = CloseGuard.get(); private final CloseGuard mCloseGuard = CloseGuard.get(); private String mName; private final String mName; int mNativeObject; // package visibility only for Surface.java access int mNativeObject; // package visibility only for Surface.java access private static final boolean HEADLESS = "1".equals( private static final boolean HEADLESS = "1".equals( SystemProperties.get("ro.config.headless", "0")); SystemProperties.get("ro.config.headless", "0")); /** * Exception thrown when a surface couldn't be created or resized. */ public static class OutOfResourcesException extends Exception { public OutOfResourcesException() { } public OutOfResourcesException(String name) { super(name); } } /* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */ /* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */ /** /** Loading Loading @@ -220,6 +210,8 @@ public class SurfaceControl { * @param h The surface initial height. * @param h The surface initial height. * @param flags The surface creation flags. Should always include {@link #HIDDEN} * @param flags The surface creation flags. Should always include {@link #HIDDEN} * in the creation flags. * in the creation flags. * * @throws throws OutOfResourcesException If the SurfaceControl cannot be created. */ */ public SurfaceControl(SurfaceSession session, public SurfaceControl(SurfaceSession session, String name, int w, int h, int format, int flags) String name, int w, int h, int format, int flags) Loading core/java/android/view/SurfaceView.java +56 −38 Original line number Original line Diff line number Diff line Loading @@ -134,6 +134,7 @@ public class SurfaceView extends View { final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { public void onScrollChanged() { updateWindow(false, false); updateWindow(false, false); } } Loading Loading @@ -667,10 +668,12 @@ public class SurfaceView extends View { } } } } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible) { // The point of SurfaceView is to let the app control the surface. // The point of SurfaceView is to let the app control the surface. } } @Override public void dispatchGetNewSurface() { public void dispatchGetNewSurface() { SurfaceView surfaceView = mSurfaceView.get(); SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { if (surfaceView != null) { Loading @@ -679,10 +682,12 @@ public class SurfaceView extends View { } } } } @Override public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { Log.w("SurfaceView", "Unexpected focus in surface: focus=" + hasFocus + ", touchEnabled=" + touchEnabled); Log.w("SurfaceView", "Unexpected focus in surface: focus=" + hasFocus + ", touchEnabled=" + touchEnabled); } } @Override public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { } } Loading @@ -690,14 +695,16 @@ public class SurfaceView extends View { int mCurHeight = -1; int mCurHeight = -1; } } private SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private final SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private static final String LOG_TAG = "SurfaceHolder"; private static final String LOG_TAG = "SurfaceHolder"; @Override public boolean isCreating() { public boolean isCreating() { return mIsCreating; return mIsCreating; } } @Override public void addCallback(Callback callback) { public void addCallback(Callback callback) { synchronized (mCallbacks) { synchronized (mCallbacks) { // This is a linear search, but in practice we'll // This is a linear search, but in practice we'll Loading @@ -708,12 +715,14 @@ public class SurfaceView extends View { } } } } @Override public void removeCallback(Callback callback) { public void removeCallback(Callback callback) { synchronized (mCallbacks) { synchronized (mCallbacks) { mCallbacks.remove(callback); mCallbacks.remove(callback); } } } } @Override public void setFixedSize(int width, int height) { public void setFixedSize(int width, int height) { if (mRequestedWidth != width || mRequestedHeight != height) { if (mRequestedWidth != width || mRequestedHeight != height) { mRequestedWidth = width; mRequestedWidth = width; Loading @@ -722,6 +731,7 @@ public class SurfaceView extends View { } } } } @Override public void setSizeFromLayout() { public void setSizeFromLayout() { if (mRequestedWidth != -1 || mRequestedHeight != -1) { if (mRequestedWidth != -1 || mRequestedHeight != -1) { mRequestedWidth = mRequestedHeight = -1; mRequestedWidth = mRequestedHeight = -1; Loading @@ -729,6 +739,7 @@ public class SurfaceView extends View { } } } } @Override public void setFormat(int format) { public void setFormat(int format) { // for backward compatibility reason, OPAQUE always // for backward compatibility reason, OPAQUE always Loading @@ -745,9 +756,11 @@ public class SurfaceView extends View { /** /** * @deprecated setType is now ignored. * @deprecated setType is now ignored. */ */ @Override @Deprecated @Deprecated public void setType(int type) { } public void setType(int type) { } @Override public void setKeepScreenOn(boolean screenOn) { public void setKeepScreenOn(boolean screenOn) { Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG); Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG); msg.arg1 = screenOn ? 1 : 0; msg.arg1 = screenOn ? 1 : 0; Loading @@ -763,6 +776,7 @@ public class SurfaceView extends View { * The caller must redraw the entire surface. * The caller must redraw the entire surface. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. */ */ @Override public Canvas lockCanvas() { public Canvas lockCanvas() { return internalLockCanvas(null); return internalLockCanvas(null); } } Loading @@ -782,6 +796,7 @@ public class SurfaceView extends View { * entire surface should be redrawn. * entire surface should be redrawn. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. */ */ @Override public Canvas lockCanvas(Rect inOutDirty) { public Canvas lockCanvas(Rect inOutDirty) { return internalLockCanvas(inOutDirty); return internalLockCanvas(inOutDirty); } } Loading Loading @@ -831,15 +846,18 @@ public class SurfaceView extends View { * * * @param canvas The canvas previously obtained from {@link #lockCanvas}. * @param canvas The canvas previously obtained from {@link #lockCanvas}. */ */ @Override public void unlockCanvasAndPost(Canvas canvas) { public void unlockCanvasAndPost(Canvas canvas) { mSurface.unlockCanvasAndPost(canvas); mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); mSurfaceLock.unlock(); } } @Override public Surface getSurface() { public Surface getSurface() { return mSurface; return mSurface; } } @Override public Rect getSurfaceFrame() { public Rect getSurfaceFrame() { return mSurfaceFrame; return mSurfaceFrame; } } Loading Loading
api/current.txt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -9919,7 +9919,7 @@ package android.graphics { method public abstract void onFrameAvailable(android.graphics.SurfaceTexture); method public abstract void onFrameAvailable(android.graphics.SurfaceTexture); } } public static class SurfaceTexture.OutOfResourcesException extends java.lang.Exception { public static deprecated class SurfaceTexture.OutOfResourcesException extends java.lang.Exception { ctor public SurfaceTexture.OutOfResourcesException(); ctor public SurfaceTexture.OutOfResourcesException(); ctor public SurfaceTexture.OutOfResourcesException(java.lang.String); ctor public SurfaceTexture.OutOfResourcesException(java.lang.String); } } Loading Loading @@ -27304,7 +27304,7 @@ package android.view { field public static final int ROTATION_90 = 1; // 0x1 field public static final int ROTATION_90 = 1; // 0x1 } } public static class Surface.OutOfResourcesException extends java.lang.Exception { public static class Surface.OutOfResourcesException extends java.lang.RuntimeException { ctor public Surface.OutOfResourcesException(); ctor public Surface.OutOfResourcesException(); ctor public Surface.OutOfResourcesException(java.lang.String); ctor public Surface.OutOfResourcesException(java.lang.String); } }
core/java/android/view/HardwareRenderer.java +58 −56 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.os.SystemProperties; import android.os.Trace; import android.os.Trace; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.util.Log; import android.util.Log; import android.view.Surface.OutOfResourcesException; import com.google.android.gles_jni.EGLImpl; import com.google.android.gles_jni.EGLImpl; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10; Loading Loading @@ -270,14 +272,14 @@ public abstract class HardwareRenderer { * * * @return True if the initialization was successful, false otherwise. * @return True if the initialization was successful, false otherwise. */ */ abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException; abstract boolean initialize(Surface surface) throws OutOfResourcesException; /** /** * Updates the hardware renderer for the specified surface. * Updates the hardware renderer for the specified surface. * * * @param surface The surface to hardware accelerate * @param surface The surface to hardware accelerate */ */ abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException; abstract void updateSurface(Surface surface) throws OutOfResourcesException; /** /** * Destroys the layers used by the specified view hierarchy. * Destroys the layers used by the specified view hierarchy. Loading Loading @@ -596,7 +598,7 @@ public abstract class HardwareRenderer { * false might mean that the surface was already initialized. * false might mean that the surface was already initialized. */ */ boolean initializeIfNeeded(int width, int height, Surface surface) boolean initializeIfNeeded(int width, int height, Surface surface) throws Surface.OutOfResourcesException { throws OutOfResourcesException { if (isRequested()) { if (isRequested()) { // We lost the gl context, so recreate it. // We lost the gl context, so recreate it. if (!isEnabled()) { if (!isEnabled()) { Loading Loading @@ -1050,7 +1052,7 @@ public abstract class HardwareRenderer { } } @Override @Override boolean initialize(Surface surface) throws Surface.OutOfResourcesException { boolean initialize(Surface surface) throws OutOfResourcesException { if (isRequested() && !isEnabled()) { if (isRequested() && !isEnabled()) { boolean contextCreated = initializeEgl(); boolean contextCreated = initializeEgl(); mGl = createEglSurface(surface); mGl = createEglSurface(surface); Loading Loading @@ -1080,7 +1082,7 @@ public abstract class HardwareRenderer { } } @Override @Override void updateSurface(Surface surface) throws Surface.OutOfResourcesException { void updateSurface(Surface surface) throws OutOfResourcesException { if (isRequested() && isEnabled()) { if (isRequested() && isEnabled()) { createEglSurface(surface); createEglSurface(surface); } } Loading Loading @@ -1216,7 +1218,7 @@ public abstract class HardwareRenderer { Log.d(LOG_TAG, " CONFIG_CAVEAT = 0x" + Integer.toHexString(value[0])); Log.d(LOG_TAG, " CONFIG_CAVEAT = 0x" + Integer.toHexString(value[0])); } } GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException { GL createEglSurface(Surface surface) throws OutOfResourcesException { // Check preconditions. // Check preconditions. if (sEgl == null) { if (sEgl == null) { throw new RuntimeException("egl not initialized"); throw new RuntimeException("egl not initialized"); Loading
core/java/android/view/Surface.java +12 −11 Original line number Original line Diff line number Diff line Loading @@ -116,6 +116,7 @@ public class Surface implements Parcelable { * * * @param surfaceTexture The {@link SurfaceTexture} that is updated by this * @param surfaceTexture The {@link SurfaceTexture} that is updated by this * Surface. * Surface. * @throws OutOfResourcesException if the surface could not be created. */ */ public Surface(SurfaceTexture surfaceTexture) { public Surface(SurfaceTexture surfaceTexture) { if (surfaceTexture == null) { if (surfaceTexture == null) { Loading @@ -124,12 +125,7 @@ public class Surface implements Parcelable { synchronized (mLock) { synchronized (mLock) { mName = surfaceTexture.toString(); mName = surfaceTexture.toString(); try { setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture)); setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture)); } catch (OutOfResourcesException ex) { // We can't throw OutOfResourcesException because it would be an API change. throw new RuntimeException(ex); } } } } } Loading Loading @@ -229,9 +225,12 @@ public class Surface implements Parcelable { * The caller may also pass <code>null</code> instead, in the case where the * The caller may also pass <code>null</code> instead, in the case where the * entire surface should be redrawn. * entire surface should be redrawn. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. * * @throws IllegalArgumentException If the inOutDirty rectangle is not valid. * @throws OutOfResourcesException If the canvas cannot be locked. */ */ public Canvas lockCanvas(Rect inOutDirty) public Canvas lockCanvas(Rect inOutDirty) throws OutOfResourcesException, IllegalArgumentException { throws Surface.OutOfResourcesException, IllegalArgumentException { synchronized (mLock) { synchronized (mLock) { checkNotReleasedLocked(); checkNotReleasedLocked(); if (mLockedObject != 0) { if (mLockedObject != 0) { Loading @@ -239,7 +238,7 @@ public class Surface implements Parcelable { // double-lock, but that won't happen if mNativeObject was updated. We can't // double-lock, but that won't happen if mNativeObject was updated. We can't // abandon the old mLockedObject because it might still be in use, so instead // abandon the old mLockedObject because it might still be in use, so instead // we just refuse to re-lock the Surface. // we just refuse to re-lock the Surface. throw new RuntimeException("Surface was already locked"); throw new IllegalStateException("Surface was already locked"); } } mLockedObject = nativeLockCanvas(mNativeObject, mCanvas, inOutDirty); mLockedObject = nativeLockCanvas(mNativeObject, mCanvas, inOutDirty); return mCanvas; return mCanvas; Loading @@ -266,7 +265,7 @@ public class Surface implements Parcelable { Integer.toHexString(mLockedObject) +")"); Integer.toHexString(mLockedObject) +")"); } } if (mLockedObject == 0) { if (mLockedObject == 0) { throw new RuntimeException("Surface was not locked"); throw new IllegalStateException("Surface was not locked"); } } nativeUnlockCanvasAndPost(mLockedObject, canvas); nativeUnlockCanvasAndPost(mLockedObject, canvas); nativeRelease(mLockedObject); nativeRelease(mLockedObject); Loading Loading @@ -411,9 +410,11 @@ public class Surface implements Parcelable { } } /** /** * Exception thrown when a surface couldn't be created or resized. * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or * when a SurfaceTexture could not successfully be allocated. */ */ public static class OutOfResourcesException extends Exception { @SuppressWarnings("serial") public static class OutOfResourcesException extends RuntimeException { public OutOfResourcesException() { public OutOfResourcesException() { } } public OutOfResourcesException(String name) { public OutOfResourcesException(String name) { Loading
core/java/android/view/SurfaceControl.java +4 −12 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.view.Surface; import android.os.IBinder; import android.os.IBinder; import android.os.SystemProperties; import android.os.SystemProperties; import android.util.Log; import android.util.Log; import android.view.Surface.OutOfResourcesException; /** /** * SurfaceControl * SurfaceControl Loading Loading @@ -75,23 +76,12 @@ public class SurfaceControl { private final CloseGuard mCloseGuard = CloseGuard.get(); private final CloseGuard mCloseGuard = CloseGuard.get(); private String mName; private final String mName; int mNativeObject; // package visibility only for Surface.java access int mNativeObject; // package visibility only for Surface.java access private static final boolean HEADLESS = "1".equals( private static final boolean HEADLESS = "1".equals( SystemProperties.get("ro.config.headless", "0")); SystemProperties.get("ro.config.headless", "0")); /** * Exception thrown when a surface couldn't be created or resized. */ public static class OutOfResourcesException extends Exception { public OutOfResourcesException() { } public OutOfResourcesException(String name) { super(name); } } /* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */ /* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */ /** /** Loading Loading @@ -220,6 +210,8 @@ public class SurfaceControl { * @param h The surface initial height. * @param h The surface initial height. * @param flags The surface creation flags. Should always include {@link #HIDDEN} * @param flags The surface creation flags. Should always include {@link #HIDDEN} * in the creation flags. * in the creation flags. * * @throws throws OutOfResourcesException If the SurfaceControl cannot be created. */ */ public SurfaceControl(SurfaceSession session, public SurfaceControl(SurfaceSession session, String name, int w, int h, int format, int flags) String name, int w, int h, int format, int flags) Loading
core/java/android/view/SurfaceView.java +56 −38 Original line number Original line Diff line number Diff line Loading @@ -134,6 +134,7 @@ public class SurfaceView extends View { final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { public void onScrollChanged() { updateWindow(false, false); updateWindow(false, false); } } Loading Loading @@ -667,10 +668,12 @@ public class SurfaceView extends View { } } } } @Override public void dispatchAppVisibility(boolean visible) { public void dispatchAppVisibility(boolean visible) { // The point of SurfaceView is to let the app control the surface. // The point of SurfaceView is to let the app control the surface. } } @Override public void dispatchGetNewSurface() { public void dispatchGetNewSurface() { SurfaceView surfaceView = mSurfaceView.get(); SurfaceView surfaceView = mSurfaceView.get(); if (surfaceView != null) { if (surfaceView != null) { Loading @@ -679,10 +682,12 @@ public class SurfaceView extends View { } } } } @Override public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) { Log.w("SurfaceView", "Unexpected focus in surface: focus=" + hasFocus + ", touchEnabled=" + touchEnabled); Log.w("SurfaceView", "Unexpected focus in surface: focus=" + hasFocus + ", touchEnabled=" + touchEnabled); } } @Override public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { } } Loading @@ -690,14 +695,16 @@ public class SurfaceView extends View { int mCurHeight = -1; int mCurHeight = -1; } } private SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private final SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private static final String LOG_TAG = "SurfaceHolder"; private static final String LOG_TAG = "SurfaceHolder"; @Override public boolean isCreating() { public boolean isCreating() { return mIsCreating; return mIsCreating; } } @Override public void addCallback(Callback callback) { public void addCallback(Callback callback) { synchronized (mCallbacks) { synchronized (mCallbacks) { // This is a linear search, but in practice we'll // This is a linear search, but in practice we'll Loading @@ -708,12 +715,14 @@ public class SurfaceView extends View { } } } } @Override public void removeCallback(Callback callback) { public void removeCallback(Callback callback) { synchronized (mCallbacks) { synchronized (mCallbacks) { mCallbacks.remove(callback); mCallbacks.remove(callback); } } } } @Override public void setFixedSize(int width, int height) { public void setFixedSize(int width, int height) { if (mRequestedWidth != width || mRequestedHeight != height) { if (mRequestedWidth != width || mRequestedHeight != height) { mRequestedWidth = width; mRequestedWidth = width; Loading @@ -722,6 +731,7 @@ public class SurfaceView extends View { } } } } @Override public void setSizeFromLayout() { public void setSizeFromLayout() { if (mRequestedWidth != -1 || mRequestedHeight != -1) { if (mRequestedWidth != -1 || mRequestedHeight != -1) { mRequestedWidth = mRequestedHeight = -1; mRequestedWidth = mRequestedHeight = -1; Loading @@ -729,6 +739,7 @@ public class SurfaceView extends View { } } } } @Override public void setFormat(int format) { public void setFormat(int format) { // for backward compatibility reason, OPAQUE always // for backward compatibility reason, OPAQUE always Loading @@ -745,9 +756,11 @@ public class SurfaceView extends View { /** /** * @deprecated setType is now ignored. * @deprecated setType is now ignored. */ */ @Override @Deprecated @Deprecated public void setType(int type) { } public void setType(int type) { } @Override public void setKeepScreenOn(boolean screenOn) { public void setKeepScreenOn(boolean screenOn) { Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG); Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG); msg.arg1 = screenOn ? 1 : 0; msg.arg1 = screenOn ? 1 : 0; Loading @@ -763,6 +776,7 @@ public class SurfaceView extends View { * The caller must redraw the entire surface. * The caller must redraw the entire surface. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. */ */ @Override public Canvas lockCanvas() { public Canvas lockCanvas() { return internalLockCanvas(null); return internalLockCanvas(null); } } Loading @@ -782,6 +796,7 @@ public class SurfaceView extends View { * entire surface should be redrawn. * entire surface should be redrawn. * @return A canvas for drawing into the surface. * @return A canvas for drawing into the surface. */ */ @Override public Canvas lockCanvas(Rect inOutDirty) { public Canvas lockCanvas(Rect inOutDirty) { return internalLockCanvas(inOutDirty); return internalLockCanvas(inOutDirty); } } Loading Loading @@ -831,15 +846,18 @@ public class SurfaceView extends View { * * * @param canvas The canvas previously obtained from {@link #lockCanvas}. * @param canvas The canvas previously obtained from {@link #lockCanvas}. */ */ @Override public void unlockCanvasAndPost(Canvas canvas) { public void unlockCanvasAndPost(Canvas canvas) { mSurface.unlockCanvasAndPost(canvas); mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); mSurfaceLock.unlock(); } } @Override public Surface getSurface() { public Surface getSurface() { return mSurface; return mSurface; } } @Override public Rect getSurfaceFrame() { public Rect getSurfaceFrame() { return mSurfaceFrame; return mSurfaceFrame; } } Loading