Loading core/java/android/view/Surface.java +8 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,9 @@ public class Surface implements Parcelable { private static native void nativeAllocateBuffers(long nativeObject); private static native int nativeGetWidth(long nativeObject); private static native int nativeGetHeight(long nativeObject); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @Override Loading Loading @@ -327,7 +330,9 @@ public class Surface implements Parcelable { if (mHwuiContext == null) { mHwuiContext = new HwuiContext(); } return mHwuiContext.lockCanvas(); return mHwuiContext.lockCanvas( nativeGetWidth(mNativeObject), nativeGetHeight(mNativeObject)); } } Loading Loading @@ -576,11 +581,11 @@ public class Surface implements Parcelable { mHwuiRenderer = nHwuiCreate(mRenderNode.mNativeRenderNode, mNativeObject); } Canvas lockCanvas() { Canvas lockCanvas(int width, int height) { if (mCanvas != null) { throw new IllegalStateException("Surface was already locked!"); } mCanvas = mRenderNode.start(0, 0); mCanvas = mRenderNode.start(width, height); return mCanvas; } Loading core/jni/android_view_Surface.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,22 @@ static void nativeWriteToParcel(JNIEnv* env, jclass clazz, parcel->writeStrongBinder( self != 0 ? self->getIGraphicBufferProducer()->asBinder() : NULL); } static jint nativeGetWidth(JNIEnv* env, jclass clazz, jlong nativeObject) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); ANativeWindow* anw = static_cast<ANativeWindow*>(surface); int value = 0; anw->query(anw, NATIVE_WINDOW_WIDTH, &value); return value; } static jint nativeGetHeight(JNIEnv* env, jclass clazz, jlong nativeObject) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); ANativeWindow* anw = static_cast<ANativeWindow*>(surface); int value = 0; anw->query(anw, NATIVE_WINDOW_HEIGHT, &value); return value; } namespace uirenderer { using namespace android::uirenderer::renderthread; Loading Loading @@ -426,6 +442,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeReadFromParcel }, {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, {"nativeGetWidth", "(J)I", (void*)nativeGetWidth }, {"nativeGetHeight", "(J)I", (void*)nativeGetHeight }, // HWUI context {"nHwuiCreate", "(JJ)J", (void*) hwui::create }, Loading Loading
core/java/android/view/Surface.java +8 −3 Original line number Diff line number Diff line Loading @@ -53,6 +53,9 @@ public class Surface implements Parcelable { private static native void nativeAllocateBuffers(long nativeObject); private static native int nativeGetWidth(long nativeObject); private static native int nativeGetHeight(long nativeObject); public static final Parcelable.Creator<Surface> CREATOR = new Parcelable.Creator<Surface>() { @Override Loading Loading @@ -327,7 +330,9 @@ public class Surface implements Parcelable { if (mHwuiContext == null) { mHwuiContext = new HwuiContext(); } return mHwuiContext.lockCanvas(); return mHwuiContext.lockCanvas( nativeGetWidth(mNativeObject), nativeGetHeight(mNativeObject)); } } Loading Loading @@ -576,11 +581,11 @@ public class Surface implements Parcelable { mHwuiRenderer = nHwuiCreate(mRenderNode.mNativeRenderNode, mNativeObject); } Canvas lockCanvas() { Canvas lockCanvas(int width, int height) { if (mCanvas != null) { throw new IllegalStateException("Surface was already locked!"); } mCanvas = mRenderNode.start(0, 0); mCanvas = mRenderNode.start(width, height); return mCanvas; } Loading
core/jni/android_view_Surface.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,22 @@ static void nativeWriteToParcel(JNIEnv* env, jclass clazz, parcel->writeStrongBinder( self != 0 ? self->getIGraphicBufferProducer()->asBinder() : NULL); } static jint nativeGetWidth(JNIEnv* env, jclass clazz, jlong nativeObject) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); ANativeWindow* anw = static_cast<ANativeWindow*>(surface); int value = 0; anw->query(anw, NATIVE_WINDOW_WIDTH, &value); return value; } static jint nativeGetHeight(JNIEnv* env, jclass clazz, jlong nativeObject) { Surface* surface = reinterpret_cast<Surface*>(nativeObject); ANativeWindow* anw = static_cast<ANativeWindow*>(surface); int value = 0; anw->query(anw, NATIVE_WINDOW_HEIGHT, &value); return value; } namespace uirenderer { using namespace android::uirenderer::renderthread; Loading Loading @@ -426,6 +442,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeReadFromParcel }, {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, {"nativeGetWidth", "(J)I", (void*)nativeGetWidth }, {"nativeGetHeight", "(J)I", (void*)nativeGetHeight }, // HWUI context {"nHwuiCreate", "(JJ)J", (void*) hwui::create }, Loading