Fail createVirtualDisplay with single-buffered Surface
Bug 30106031 Change-Id: I434df329eb3c162dd9ef01245ac5e0da97216e70
This commit is contained in:
@@ -96,6 +96,8 @@ public class Surface implements Parcelable {
|
|||||||
|
|
||||||
private HwuiContext mHwuiContext;
|
private HwuiContext mHwuiContext;
|
||||||
|
|
||||||
|
private boolean mIsSingleBuffered;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@IntDef({SCALING_MODE_FREEZE, SCALING_MODE_SCALE_TO_WINDOW,
|
@IntDef({SCALING_MODE_FREEZE, SCALING_MODE_SCALE_TO_WINDOW,
|
||||||
@@ -158,7 +160,7 @@ public class Surface implements Parcelable {
|
|||||||
if (surfaceTexture == null) {
|
if (surfaceTexture == null) {
|
||||||
throw new IllegalArgumentException("surfaceTexture must not be null");
|
throw new IllegalArgumentException("surfaceTexture must not be null");
|
||||||
}
|
}
|
||||||
|
mIsSingleBuffered = surfaceTexture.isSingleBuffered();
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mName = surfaceTexture.toString();
|
mName = surfaceTexture.toString();
|
||||||
setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture));
|
setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture));
|
||||||
@@ -458,6 +460,7 @@ public class Surface implements Parcelable {
|
|||||||
// the reference count on mNativeObject. Either way, it is
|
// the reference count on mNativeObject. Either way, it is
|
||||||
// not necessary to call nativeRelease() here.
|
// not necessary to call nativeRelease() here.
|
||||||
mName = source.readString();
|
mName = source.readString();
|
||||||
|
mIsSingleBuffered = source.readInt() != 0;
|
||||||
setNativeObjectLocked(nativeReadFromParcel(mNativeObject, source));
|
setNativeObjectLocked(nativeReadFromParcel(mNativeObject, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,6 +472,7 @@ public class Surface implements Parcelable {
|
|||||||
}
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
dest.writeString(mName);
|
dest.writeString(mName);
|
||||||
|
dest.writeInt(mIsSingleBuffered ? 1 : 0);
|
||||||
nativeWriteToParcel(mNativeObject, dest);
|
nativeWriteToParcel(mNativeObject, dest);
|
||||||
}
|
}
|
||||||
if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) {
|
if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) {
|
||||||
@@ -530,6 +534,14 @@ public class Surface implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not this Surface is backed by a single-buffered SurfaceTexture
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean isSingleBuffered() {
|
||||||
|
return mIsSingleBuffered;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or
|
* Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or
|
||||||
* when a SurfaceTexture could not successfully be allocated.
|
* when a SurfaceTexture could not successfully be allocated.
|
||||||
|
|||||||
@@ -371,7 +371,12 @@ static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
|
|||||||
if (sur != NULL) {
|
if (sur != NULL) {
|
||||||
bufferProducer = sur->getIGraphicBufferProducer();
|
bufferProducer = sur->getIGraphicBufferProducer();
|
||||||
}
|
}
|
||||||
SurfaceComposerClient::setDisplaySurface(token, bufferProducer);
|
status_t err = SurfaceComposerClient::setDisplaySurface(token,
|
||||||
|
bufferProducer);
|
||||||
|
if (err != NO_ERROR) {
|
||||||
|
doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this"
|
||||||
|
" Surface created with singleBufferMode?");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
|
static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public class SurfaceTexture {
|
|||||||
private long mProducer;
|
private long mProducer;
|
||||||
private long mFrameAvailableListener;
|
private long mFrameAvailableListener;
|
||||||
|
|
||||||
|
private boolean mIsSingleBuffered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface for being notified that a new stream frame is available.
|
* Callback interface for being notified that a new stream frame is available.
|
||||||
*/
|
*/
|
||||||
@@ -130,6 +132,7 @@ public class SurfaceTexture {
|
|||||||
*/
|
*/
|
||||||
public SurfaceTexture(int texName, boolean singleBufferMode) {
|
public SurfaceTexture(int texName, boolean singleBufferMode) {
|
||||||
mCreatorLooper = Looper.myLooper();
|
mCreatorLooper = Looper.myLooper();
|
||||||
|
mIsSingleBuffered = singleBufferMode;
|
||||||
nativeInit(false, texName, singleBufferMode, new WeakReference<SurfaceTexture>(this));
|
nativeInit(false, texName, singleBufferMode, new WeakReference<SurfaceTexture>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +160,7 @@ public class SurfaceTexture {
|
|||||||
*/
|
*/
|
||||||
public SurfaceTexture(boolean singleBufferMode) {
|
public SurfaceTexture(boolean singleBufferMode) {
|
||||||
mCreatorLooper = Looper.myLooper();
|
mCreatorLooper = Looper.myLooper();
|
||||||
|
mIsSingleBuffered = singleBufferMode;
|
||||||
nativeInit(true, 0, singleBufferMode, new WeakReference<SurfaceTexture>(this));
|
nativeInit(true, 0, singleBufferMode, new WeakReference<SurfaceTexture>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +382,14 @@ public class SurfaceTexture {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the SurfaceTexture is single-buffered
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean isSingleBuffered() {
|
||||||
|
return mIsSingleBuffered;
|
||||||
|
}
|
||||||
|
|
||||||
private native void nativeInit(boolean isDetached, int texName,
|
private native void nativeInit(boolean isDetached, int texName,
|
||||||
boolean singleBufferMode, WeakReference<SurfaceTexture> weakSelf)
|
boolean singleBufferMode, WeakReference<SurfaceTexture> weakSelf)
|
||||||
throws Surface.OutOfResourcesException;
|
throws Surface.OutOfResourcesException;
|
||||||
|
|||||||
@@ -1402,6 +1402,9 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
throw new IllegalArgumentException("width, height, and densityDpi must be "
|
throw new IllegalArgumentException("width, height, and densityDpi must be "
|
||||||
+ "greater than 0");
|
+ "greater than 0");
|
||||||
}
|
}
|
||||||
|
if (surface.isSingleBuffered()) {
|
||||||
|
throw new IllegalArgumentException("Surface can't be single-buffered");
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) {
|
if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) {
|
||||||
flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
|
flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user