Merge "Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ee5cedeca4
@@ -509,13 +509,8 @@ public class SurfaceControl {
|
||||
if (displayToken == null) {
|
||||
throw new IllegalArgumentException("displayToken must not be null");
|
||||
}
|
||||
if (surface == null) {
|
||||
throw new IllegalArgumentException("surface must not be null");
|
||||
}
|
||||
if (surface.mNativeObject == 0)
|
||||
throw new NullPointerException("Surface native object is null. Are you using a released surface?");
|
||||
|
||||
nativeSetDisplaySurface(displayToken, surface.mNativeObject);
|
||||
int nativeSurface = surface != null ? surface.mNativeObject : 0;
|
||||
nativeSetDisplaySurface(displayToken, nativeSurface);
|
||||
}
|
||||
|
||||
public static IBinder createDisplay(String name, boolean secure) {
|
||||
|
||||
@@ -388,7 +388,7 @@ int register_android_view_Surface(JNIEnv* env)
|
||||
env->GetFieldID(gSurfaceClassInfo.clazz, "mGenerationId", "I");
|
||||
gSurfaceClassInfo.mCanvas =
|
||||
env->GetFieldID(gSurfaceClassInfo.clazz, "mCanvas", "Landroid/graphics/Canvas;");
|
||||
gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "()V");
|
||||
gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V");
|
||||
|
||||
clazz = env->FindClass("android/graphics/Canvas");
|
||||
gCanvasClassInfo.mFinalizer = env->GetFieldID(clazz, "mFinalizer", "Landroid/graphics/Canvas$CanvasFinalizer;");
|
||||
|
||||
@@ -320,8 +320,11 @@ static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
|
||||
jobject tokenObj, jint nativeSurfaceObject) {
|
||||
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
|
||||
if (token == NULL) return;
|
||||
sp<IGraphicBufferProducer> bufferProducer;
|
||||
sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
|
||||
sp<IGraphicBufferProducer> bufferProducer(sur->getIGraphicBufferProducer());
|
||||
if (sur != NULL) {
|
||||
bufferProducer = sur->getIGraphicBufferProducer();
|
||||
}
|
||||
SurfaceComposerClient::setDisplaySurface(token, bufferProducer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user