Loading core/java/android/app/ActivityManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class ActivityManager { public final static boolean ENABLE_TASK_SNAPSHOTS; static { ENABLE_TASK_SNAPSHOTS = SystemProperties.getBoolean("persist.enable_task_snapshots", false); ENABLE_TASK_SNAPSHOTS = SystemProperties.getBoolean("persist.enable_task_snapshots", true); } static final class UidObserver extends IUidObserver.Stub { Loading core/java/android/view/Surface.java +17 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.view; import android.annotation.IntDef; import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.GraphicBuffer; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.SurfaceTexture; Loading Loading @@ -72,6 +73,7 @@ public class Surface implements Parcelable { private static native int nativeSetScalingMode(long nativeObject, int scalingMode); private static native void nativeSetBuffersTransform(long nativeObject, long transform); private static native int nativeForceScopedDisconnect(long nativeObject); private static native int nativeAttachAndQueueBuffer(long nativeObject, GraphicBuffer buffer); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { Loading Loading @@ -561,6 +563,21 @@ public class Surface implements Parcelable { } } /** * Transfer ownership of buffer and present it on the Surface. * @hide */ public void attachAndQueueBuffer(GraphicBuffer buffer) { synchronized (mLock) { checkNotReleasedLocked(); int err = nativeAttachAndQueueBuffer(mNativeObject, buffer); if (err != 0) { throw new RuntimeException( "Failed to attach and queue buffer to Surface (bad object?)"); } } } /** * Returns whether or not this Surface is backed by a single-buffered SurfaceTexture * @hide Loading core/jni/android_view_Surface.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "jni.h" #include "JNIHelp.h" #include "android_os_Parcel.h" #include "android/graphics/GraphicBuffer.h" #include "android/graphics/GraphicsJNI.h" #include "core_jni_helpers.h" Loading Loading @@ -496,6 +497,30 @@ static jint nativeForceScopedDisconnect(JNIEnv *env, jclass clazz, jlong nativeO return surface->disconnect(-1, IGraphicBufferProducer::DisconnectMode::AllLocal); } static jint nativeAttachAndQueueBuffer(JNIEnv *env, jclass clazz, jlong nativeObject, jobject graphicBuffer) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); sp<GraphicBuffer> bp = graphicBufferForJavaObject(env, graphicBuffer); if (bp == nullptr) { return BAD_VALUE; } int err = ((ANativeWindow*)surface)->perform(surface, NATIVE_WINDOW_API_CONNECT, NATIVE_WINDOW_API_CPU); if (err != OK) { return err; } err = surface->attachBuffer(bp->getNativeBuffer()); if (err != OK) { return err; } err = ((ANativeWindow*)surface)->queueBuffer(surface, bp->getNativeBuffer(), -1); if (err != OK) { return err; } err = surface->disconnect(NATIVE_WINDOW_API_CPU); return err; } namespace uirenderer { using namespace android::uirenderer::renderthread; Loading Loading @@ -574,6 +599,7 @@ static const JNINativeMethod gSurfaceMethods[] = { {"nativeGetNextFrameNumber", "(J)J", (void*)nativeGetNextFrameNumber }, {"nativeSetScalingMode", "(JI)I", (void*)nativeSetScalingMode }, {"nativeForceScopedDisconnect", "(J)I", (void*)nativeForceScopedDisconnect}, {"nativeAttachAndQueueBuffer", "(JLandroid/graphics/GraphicBuffer;)I", (void*)nativeAttachAndQueueBuffer}, // HWUI context {"nHwuiCreate", "(JJ)J", (void*) hwui::create }, Loading services/core/java/com/android/server/wm/TaskSnapshotSurface.java +1 −15 Original line number Diff line number Diff line Loading @@ -151,21 +151,7 @@ class TaskSnapshotSurface implements StartingSurface { } private void drawSnapshot(GraphicBuffer snapshot) { // TODO: Just wrap the buffer here without any copying. final Canvas c = mSurface.lockHardwareCanvas(); final Bitmap b = Bitmap.createHardwareBitmap(snapshot); fillEmptyBackground(c, b); c.drawBitmap(b, 0, 0, null); mSurface.unlockCanvasAndPost(c); final boolean reportNextDraw; synchronized (mService.mWindowMap) { mHasDrawn = true; reportNextDraw = mReportNextDraw; } if (reportNextDraw) { reportDrawn(); } mSurface.attachAndQueueBuffer(snapshot); mSurface.release(); } Loading Loading
core/java/android/app/ActivityManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class ActivityManager { public final static boolean ENABLE_TASK_SNAPSHOTS; static { ENABLE_TASK_SNAPSHOTS = SystemProperties.getBoolean("persist.enable_task_snapshots", false); ENABLE_TASK_SNAPSHOTS = SystemProperties.getBoolean("persist.enable_task_snapshots", true); } static final class UidObserver extends IUidObserver.Stub { Loading
core/java/android/view/Surface.java +17 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.view; import android.annotation.IntDef; import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.GraphicBuffer; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.SurfaceTexture; Loading Loading @@ -72,6 +73,7 @@ public class Surface implements Parcelable { private static native int nativeSetScalingMode(long nativeObject, int scalingMode); private static native void nativeSetBuffersTransform(long nativeObject, long transform); private static native int nativeForceScopedDisconnect(long nativeObject); private static native int nativeAttachAndQueueBuffer(long nativeObject, GraphicBuffer buffer); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { Loading Loading @@ -561,6 +563,21 @@ public class Surface implements Parcelable { } } /** * Transfer ownership of buffer and present it on the Surface. * @hide */ public void attachAndQueueBuffer(GraphicBuffer buffer) { synchronized (mLock) { checkNotReleasedLocked(); int err = nativeAttachAndQueueBuffer(mNativeObject, buffer); if (err != 0) { throw new RuntimeException( "Failed to attach and queue buffer to Surface (bad object?)"); } } } /** * Returns whether or not this Surface is backed by a single-buffered SurfaceTexture * @hide Loading
core/jni/android_view_Surface.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "jni.h" #include "JNIHelp.h" #include "android_os_Parcel.h" #include "android/graphics/GraphicBuffer.h" #include "android/graphics/GraphicsJNI.h" #include "core_jni_helpers.h" Loading Loading @@ -496,6 +497,30 @@ static jint nativeForceScopedDisconnect(JNIEnv *env, jclass clazz, jlong nativeO return surface->disconnect(-1, IGraphicBufferProducer::DisconnectMode::AllLocal); } static jint nativeAttachAndQueueBuffer(JNIEnv *env, jclass clazz, jlong nativeObject, jobject graphicBuffer) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); sp<GraphicBuffer> bp = graphicBufferForJavaObject(env, graphicBuffer); if (bp == nullptr) { return BAD_VALUE; } int err = ((ANativeWindow*)surface)->perform(surface, NATIVE_WINDOW_API_CONNECT, NATIVE_WINDOW_API_CPU); if (err != OK) { return err; } err = surface->attachBuffer(bp->getNativeBuffer()); if (err != OK) { return err; } err = ((ANativeWindow*)surface)->queueBuffer(surface, bp->getNativeBuffer(), -1); if (err != OK) { return err; } err = surface->disconnect(NATIVE_WINDOW_API_CPU); return err; } namespace uirenderer { using namespace android::uirenderer::renderthread; Loading Loading @@ -574,6 +599,7 @@ static const JNINativeMethod gSurfaceMethods[] = { {"nativeGetNextFrameNumber", "(J)J", (void*)nativeGetNextFrameNumber }, {"nativeSetScalingMode", "(JI)I", (void*)nativeSetScalingMode }, {"nativeForceScopedDisconnect", "(J)I", (void*)nativeForceScopedDisconnect}, {"nativeAttachAndQueueBuffer", "(JLandroid/graphics/GraphicBuffer;)I", (void*)nativeAttachAndQueueBuffer}, // HWUI context {"nHwuiCreate", "(JJ)J", (void*) hwui::create }, Loading
services/core/java/com/android/server/wm/TaskSnapshotSurface.java +1 −15 Original line number Diff line number Diff line Loading @@ -151,21 +151,7 @@ class TaskSnapshotSurface implements StartingSurface { } private void drawSnapshot(GraphicBuffer snapshot) { // TODO: Just wrap the buffer here without any copying. final Canvas c = mSurface.lockHardwareCanvas(); final Bitmap b = Bitmap.createHardwareBitmap(snapshot); fillEmptyBackground(c, b); c.drawBitmap(b, 0, 0, null); mSurface.unlockCanvasAndPost(c); final boolean reportNextDraw; synchronized (mService.mWindowMap) { mHasDrawn = true; reportNextDraw = mReportNextDraw; } if (reportNextDraw) { reportDrawn(); } mSurface.attachAndQueueBuffer(snapshot); mSurface.release(); } Loading