Loading core/java/android/view/Surface.java +13 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ public class Surface implements Parcelable { private static native long nativeReadFromParcel(long nativeObject, Parcel source); private static native void nativeWriteToParcel(long nativeObject, Parcel dest); private static native void nativeAllocateBuffers(long nativeObject); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @Override Loading Loading @@ -419,6 +421,17 @@ public class Surface implements Parcelable { } } /** * Allocate buffers ahead of time to avoid allocation delays during rendering * @hide */ public void allocateBuffers() { synchronized (mLock) { checkNotReleasedLocked(); nativeAllocateBuffers(mNativeObject); } } /** * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or * when a SurfaceTexture could not successfully be allocated. Loading core/java/android/view/ThreadedRenderer.java +3 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,9 @@ public class ThreadedRenderer extends HardwareRenderer { boolean initialize(Surface surface) throws OutOfResourcesException { mInitialized = true; updateEnabledState(surface); return nInitialize(mNativeProxy, surface); boolean status = nInitialize(mNativeProxy, surface); surface.allocateBuffers(); return status; } @Override Loading core/jni/android_view_Surface.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,16 @@ static void nativeUnlockCanvasAndPost(JNIEnv* env, jclass clazz, } } static void nativeAllocateBuffers(JNIEnv* /* env */ , jclass /* clazz */, jlong nativeObject) { sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); if (!isSurfaceValid(surface)) { return; } surface->allocateBuffers(); } // ---------------------------------------------------------------------------- static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, Loading Loading @@ -357,6 +367,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeLockCanvas }, {"nativeUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V", (void*)nativeUnlockCanvasAndPost }, {"nativeAllocateBuffers", "(J)V", (void*)nativeAllocateBuffers }, {"nativeCreateFromSurfaceControl", "(J)J", (void*)nativeCreateFromSurfaceControl }, {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J", Loading Loading
core/java/android/view/Surface.java +13 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ public class Surface implements Parcelable { private static native long nativeReadFromParcel(long nativeObject, Parcel source); private static native void nativeWriteToParcel(long nativeObject, Parcel dest); private static native void nativeAllocateBuffers(long nativeObject); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @Override Loading Loading @@ -419,6 +421,17 @@ public class Surface implements Parcelable { } } /** * Allocate buffers ahead of time to avoid allocation delays during rendering * @hide */ public void allocateBuffers() { synchronized (mLock) { checkNotReleasedLocked(); nativeAllocateBuffers(mNativeObject); } } /** * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or * when a SurfaceTexture could not successfully be allocated. Loading
core/java/android/view/ThreadedRenderer.java +3 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,9 @@ public class ThreadedRenderer extends HardwareRenderer { boolean initialize(Surface surface) throws OutOfResourcesException { mInitialized = true; updateEnabledState(surface); return nInitialize(mNativeProxy, surface); boolean status = nInitialize(mNativeProxy, surface); surface.allocateBuffers(); return status; } @Override Loading
core/jni/android_view_Surface.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,16 @@ static void nativeUnlockCanvasAndPost(JNIEnv* env, jclass clazz, } } static void nativeAllocateBuffers(JNIEnv* /* env */ , jclass /* clazz */, jlong nativeObject) { sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); if (!isSurfaceValid(surface)) { return; } surface->allocateBuffers(); } // ---------------------------------------------------------------------------- static jlong nativeCreateFromSurfaceControl(JNIEnv* env, jclass clazz, Loading Loading @@ -357,6 +367,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeLockCanvas }, {"nativeUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)V", (void*)nativeUnlockCanvasAndPost }, {"nativeAllocateBuffers", "(J)V", (void*)nativeAllocateBuffers }, {"nativeCreateFromSurfaceControl", "(J)J", (void*)nativeCreateFromSurfaceControl }, {"nativeReadFromParcel", "(JLandroid/os/Parcel;)J", Loading