diff options
| author | 2014-11-13 16:15:08 -0800 | |
|---|---|---|
| committer | 2014-11-24 17:59:38 +0000 | |
| commit | 2b36a86b8ee4e8c0952494dd17b5e96ded22f2ee (patch) | |
| tree | a1b5803012f2939c29c6542eb662e965ed349989 | |
| parent | 3d110b239153a6c7423a99f02ef859201205eee2 (diff) | |
Wire up surface width/height to lockHardwareCanvas DO NOT MERGE
Bug: 18338026
Change-Id: I6c37774ef1312278ae81280561060662fef923fb
(cherry picked from commit b35c9602cf5c628c621e4fe102a461505f302bfe)
| -rw-r--r-- | core/java/android/view/Surface.java | 11 | ||||
| -rw-r--r-- | core/jni/android_view_Surface.cpp | 18 |
2 files changed, 26 insertions, 3 deletions
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index da684e88c945..828e082f02d6 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -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 @@ -324,7 +327,9 @@ public class Surface implements Parcelable { if (mHwuiContext == null) { mHwuiContext = new HwuiContext(); } - return mHwuiContext.lockCanvas(); + return mHwuiContext.lockCanvas( + nativeGetWidth(mNativeObject), + nativeGetHeight(mNativeObject)); } } @@ -573,11 +578,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; } diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index b3d9890a2199..871426ea3fb8 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -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; @@ -425,6 +441,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 }, |