diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2014-06-30 16:45:05 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2014-07-01 23:55:42 +0000 |
commit | 3c8fa3b356fa8f24b55d3dc42d4313297542e9f2 (patch) | |
tree | 9fa938e85c90b0e781aa3203905fb06b104f2805 /core/java/android/hardware | |
parent | d46eba18be4cb1247b3b99aaebd09aad5dea3948 (diff) | |
download | frameworks_base-3c8fa3b356fa8f24b55d3dc42d4313297542e9f2.zip frameworks_base-3c8fa3b356fa8f24b55d3dc42d4313297542e9f2.tar.gz frameworks_base-3c8fa3b356fa8f24b55d3dc42d4313297542e9f2.tar.bz2 |
camera2: Fix configured surface check in Legacy shim.
Bug: 15116722
- Switch to checking IBinder pointer when making sure
requested output surface has been configured (same as
the camera service).
- Needed to use TextureView in TestingCamera2.
Change-Id: If8831a9b2f9ec3e81cc8348e067a57cca2d46440
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r-- | core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java | 33 | ||||
-rw-r--r-- | core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java | 7 |
2 files changed, 36 insertions, 4 deletions
diff --git a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java index 4b39092..79f4403 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +++ b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java @@ -33,6 +33,7 @@ import android.util.Size; import android.view.Surface; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import static android.hardware.camera2.legacy.LegacyExceptionUtils.*; @@ -271,6 +272,9 @@ public class LegacyCameraDevice implements AutoCloseable { return BAD_VALUE; } + List<Long> surfaceIds = (mConfiguredSurfaces == null) ? new ArrayList<Long>() : + getSurfaceIds(mConfiguredSurfaces); + // Make sure that there all requests have at least 1 surface; all surfaces are non-null for (CaptureRequest request : requestList) { if (request.getTargets().isEmpty()) { @@ -287,7 +291,7 @@ public class LegacyCameraDevice implements AutoCloseable { Log.e(TAG, "submitRequestList - must configure " + " device with valid surfaces before submitting requests"); return INVALID_OPERATION; - } else if (!mConfiguredSurfaces.contains(surface)) { + } else if (!containsSurfaceId(surface, surfaceIds)) { Log.e(TAG, "submitRequestList - cannot use a surface that wasn't configured"); return BAD_VALUE; } @@ -430,6 +434,32 @@ public class LegacyCameraDevice implements AutoCloseable { LegacyExceptionUtils.throwOnError(nativeSetSurfaceDimens(surface, width, height)); } + static long getSurfaceId(Surface surface) { + checkNotNull(surface); + return nativeGetSurfaceId(surface); + } + + static List<Long> getSurfaceIds(Collection<Surface> surfaces) { + if (surfaces == null) { + throw new NullPointerException("Null argument surfaces"); + } + List<Long> surfaceIds = new ArrayList<>(); + for (Surface s : surfaces) { + long id = getSurfaceId(s); + if (id == 0) { + throw new IllegalStateException( + "Configured surface had null native GraphicBufferProducer pointer!"); + } + surfaceIds.add(id); + } + return surfaceIds; + } + + static boolean containsSurfaceId(Surface s, List<Long> ids) { + long id = getSurfaceId(s); + return ids.contains(id); + } + private static native int nativeDetectSurfaceType(Surface surface); private static native int nativeDetectSurfaceDimens(Surface surface, @@ -445,4 +475,5 @@ public class LegacyCameraDevice implements AutoCloseable { private static native int nativeSetSurfaceDimens(Surface surface, int width, int height); + private static native long nativeGetSurfaceId(Surface surface); } diff --git a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java index e38624a..9969fd2 100644 --- a/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java +++ b/core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java @@ -492,19 +492,20 @@ public class SurfaceTextureRenderer { && (mConversionSurfaces == null || mConversionSurfaces.size() == 0)) { return; } + checkGlError("before updateTexImage"); mSurfaceTexture.updateTexImage(); if (targetSurfaces == null) return; + List<Long> targetSurfaceIds = LegacyCameraDevice.getSurfaceIds(targetSurfaces); for (EGLSurfaceHolder holder : mSurfaces) { - if (targetSurfaces.contains(holder.surface)) { + if (LegacyCameraDevice.containsSurfaceId(holder.surface, targetSurfaceIds)) { makeCurrent(holder.eglSurface); drawFrame(mSurfaceTexture); swapBuffers(holder.eglSurface); } - } for (EGLSurfaceHolder holder : mConversionSurfaces) { - if (targetSurfaces.contains(holder.surface)) { + if (LegacyCameraDevice.containsSurfaceId(holder.surface, targetSurfaceIds)) { makeCurrent(holder.eglSurface); drawFrame(mSurfaceTexture); mPBufferPixels.clear(); |