Loading core/java/android/view/Surface.java +6 −2 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ public class Surface implements Parcelable { throws OutOfResourcesException; private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject); private static native long nativeGetFromSurfaceControl(long surfaceControlNativeObject); private static native long nativeGetFromSurfaceControl(long surfaceObject, long surfaceControlNativeObject); private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty) throws OutOfResourcesException; Loading Loading @@ -519,9 +520,12 @@ public class Surface implements Parcelable { throw new NullPointerException( "null SurfaceControl native object. Are you using a released SurfaceControl?"); } long newNativeObject = nativeGetFromSurfaceControl(surfaceControlPtr); long newNativeObject = nativeGetFromSurfaceControl(mNativeObject, surfaceControlPtr); synchronized (mLock) { if (newNativeObject == mNativeObject) { return; } if (mNativeObject != 0) { nativeRelease(mNativeObject); } Loading core/jni/android_view_Surface.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -415,18 +415,23 @@ static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, } static jlong nativeGetFromSurfaceControl(JNIEnv* env, jclass clazz, jlong nativeObject, jlong surfaceControlNativeObj) { /* * This is used by the WindowManagerService just after constructing * a Surface and is necessary for returning the Surface reference to * the caller. At this point, we should only have a SurfaceControl. */ Surface* self(reinterpret_cast<Surface *>(nativeObject)); sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(surfaceControlNativeObj)); // If the underlying IGBP's are the same, we don't need to do anything. if (self != nullptr && IInterface::asBinder(self->getIGraphicBufferProducer()) == IInterface::asBinder(ctrl->getIGraphicBufferProducer())) { return nativeObject; } sp<Surface> surface(ctrl->getSurface()); if (surface != NULL) { surface->incStrong(&sRefBaseOwner); } return reinterpret_cast<jlong>(surface.get()); } Loading Loading @@ -614,7 +619,7 @@ static const JNINativeMethod gSurfaceMethods[] = { (void*)nativeAllocateBuffers }, {"nativeCreateFromSurfaceControl", "(J)J", (void*)nativeCreateFromSurfaceControl }, {"nativeGetFromSurfaceControl", "(J)J", {"nativeGetFromSurfaceControl", "(JJ)J", (void*)nativeGetFromSurfaceControl }, {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J", (void*)nativeReadFromParcel }, Loading Loading
core/java/android/view/Surface.java +6 −2 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ public class Surface implements Parcelable { throws OutOfResourcesException; private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject); private static native long nativeGetFromSurfaceControl(long surfaceControlNativeObject); private static native long nativeGetFromSurfaceControl(long surfaceObject, long surfaceControlNativeObject); private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty) throws OutOfResourcesException; Loading Loading @@ -519,9 +520,12 @@ public class Surface implements Parcelable { throw new NullPointerException( "null SurfaceControl native object. Are you using a released SurfaceControl?"); } long newNativeObject = nativeGetFromSurfaceControl(surfaceControlPtr); long newNativeObject = nativeGetFromSurfaceControl(mNativeObject, surfaceControlPtr); synchronized (mLock) { if (newNativeObject == mNativeObject) { return; } if (mNativeObject != 0) { nativeRelease(mNativeObject); } Loading
core/jni/android_view_Surface.cpp +12 −7 Original line number Diff line number Diff line Loading @@ -415,18 +415,23 @@ static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, } static jlong nativeGetFromSurfaceControl(JNIEnv* env, jclass clazz, jlong nativeObject, jlong surfaceControlNativeObj) { /* * This is used by the WindowManagerService just after constructing * a Surface and is necessary for returning the Surface reference to * the caller. At this point, we should only have a SurfaceControl. */ Surface* self(reinterpret_cast<Surface *>(nativeObject)); sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(surfaceControlNativeObj)); // If the underlying IGBP's are the same, we don't need to do anything. if (self != nullptr && IInterface::asBinder(self->getIGraphicBufferProducer()) == IInterface::asBinder(ctrl->getIGraphicBufferProducer())) { return nativeObject; } sp<Surface> surface(ctrl->getSurface()); if (surface != NULL) { surface->incStrong(&sRefBaseOwner); } return reinterpret_cast<jlong>(surface.get()); } Loading Loading @@ -614,7 +619,7 @@ static const JNINativeMethod gSurfaceMethods[] = { (void*)nativeAllocateBuffers }, {"nativeCreateFromSurfaceControl", "(J)J", (void*)nativeCreateFromSurfaceControl }, {"nativeGetFromSurfaceControl", "(J)J", {"nativeGetFromSurfaceControl", "(JJ)J", (void*)nativeGetFromSurfaceControl }, {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J", (void*)nativeReadFromParcel }, Loading