Merge "Fix SurfaceControl.setDisplaySurface() such that it accepts a null Surface"

This commit is contained in:
Mathias Agopian
2013-02-26 00:46:00 +00:00
committed by Android (Google) Code Review
3 changed files with 7 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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;");

View File

@@ -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);
}