diff options
| author | Romain Guy <romainguy@google.com> | 2013-04-30 18:58:17 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-30 18:58:17 +0000 |
| commit | 4225d7965657b57d34b00d47785cef3c693784f7 (patch) | |
| tree | 59e7cc2dbe1d9823564237e7af58498c9724b4b5 /core/java/android/view/TextureView.java | |
| parent | 9e37d590a67fca54b29a187f2a177e86ef9085b6 (diff) | |
| parent | 53bacf5a91a760f6c0a966ed2f50a25e7fe12aeb (diff) | |
Merge "Handle Surface::lock errors in TextureView Bug #8689535"
Diffstat (limited to 'core/java/android/view/TextureView.java')
| -rw-r--r-- | core/java/android/view/TextureView.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 5c3934d82077..f0acba1b223e 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -648,13 +648,19 @@ public class TextureView extends View { * rectangle. Every pixel within that rectangle must be written; however * pixels outside the dirty rectangle will be preserved by the next call * to lockCanvas(). + * + * This method can return null if the underlying surface texture is not + * available (see {@link #isAvailable()} or if the surface texture is + * already connected to an image producer (for instance: the camera, + * OpenGL, a media player, etc.) * * @param dirty Area of the surface that will be modified. * @return A Canvas used to draw into the surface. * * @see #lockCanvas() - * @see #unlockCanvasAndPost(android.graphics.Canvas) + * @see #unlockCanvasAndPost(android.graphics.Canvas) + * @see #isAvailable() */ public Canvas lockCanvas(Rect dirty) { if (!isAvailable()) return null; @@ -664,7 +670,9 @@ public class TextureView extends View { } synchronized (mNativeWindowLock) { - nLockCanvas(mNativeWindow, mCanvas, dirty); + if (!nLockCanvas(mNativeWindow, mCanvas, dirty)) { + return null; + } } mSaveCount = mCanvas.save(); @@ -803,6 +811,6 @@ public class TextureView extends View { private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture, int width, int height); - private static native void nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); + private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty); private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas); } |
