diff options
author | Jamie Gennis <jgennis@google.com> | 2011-06-10 10:05:04 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-10 10:05:04 -0700 |
commit | 4532c5e49cc0d029c53a3aee3e0b1fdf8ffd2ec4 (patch) | |
tree | 306c63d43fe52f5ea151b57ea5edf06b2c94505f /graphics/java | |
parent | be674b18644cda56ba56a78ac7147711861e8dc8 (diff) | |
parent | 050316184b01c0d1a01c46afae7429b89a27c31b (diff) | |
download | frameworks_base-4532c5e49cc0d029c53a3aee3e0b1fdf8ffd2ec4.zip frameworks_base-4532c5e49cc0d029c53a3aee3e0b1fdf8ffd2ec4.tar.gz frameworks_base-4532c5e49cc0d029c53a3aee3e0b1fdf8ffd2ec4.tar.bz2 |
Merge "Add ParcelSurfaceTexture Java class to enable ISurfaceTexture sharing via Binder."
Diffstat (limited to 'graphics/java')
3 files changed, 132 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/ParcelSurfaceTexture.aidl b/graphics/java/android/graphics/ParcelSurfaceTexture.aidl new file mode 100644 index 0000000..35ff285 --- /dev/null +++ b/graphics/java/android/graphics/ParcelSurfaceTexture.aidl @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2011, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics; + +parcelable ParcelSurfaceTexture; diff --git a/graphics/java/android/graphics/ParcelSurfaceTexture.java b/graphics/java/android/graphics/ParcelSurfaceTexture.java new file mode 100644 index 0000000..5272cc6 --- /dev/null +++ b/graphics/java/android/graphics/ParcelSurfaceTexture.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics; + +import android.graphics.SurfaceTexture; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * + * @hide Pending review by API council. + */ +public final class ParcelSurfaceTexture implements Parcelable { + /** + * This field is used by native code, do not access or modify. + * + * @hide + */ + @SuppressWarnings({"UnusedDeclaration"}) + private int mISurfaceTexture; + + /** + * Create a new ParcelSurfaceTexture from a SurfaceTexture + * + * @param surfaceTexture The SurfaceTexture to transport. + * + * @return Returns a new ParcelSurfaceTexture for the given SurfaceTexture. + */ + public static ParcelSurfaceTexture fromSurfaceTexture(SurfaceTexture surfaceTexture) { + return new ParcelSurfaceTexture(surfaceTexture); + } + + /** + * @see android.os.Parcelable#describeContents() + */ + @Override + public int describeContents() { + return 0; + } + + /** + * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int) + */ + @Override + public void writeToParcel(Parcel dest, int flags) { + nativeWriteToParcel(dest, flags); + } + + public static final Parcelable.Creator<ParcelSurfaceTexture> CREATOR = + new Parcelable.Creator<ParcelSurfaceTexture>() { + @Override + public ParcelSurfaceTexture createFromParcel(Parcel in) { + return new ParcelSurfaceTexture(in); + } + @Override + public ParcelSurfaceTexture[] newArray(int size) { + return new ParcelSurfaceTexture[size]; + } + }; + + private ParcelSurfaceTexture(Parcel in) { + nativeReadFromParcel(in); + } + private ParcelSurfaceTexture(SurfaceTexture surfaceTexture) { + nativeInit(surfaceTexture); + } + + @Override + protected void finalize() throws Throwable { + try { + nativeFinalize(); + } finally { + super.finalize(); + } + } + + private native void nativeInit(SurfaceTexture surfaceTexture); + private native void nativeFinalize(); + private native void nativeWriteToParcel(Parcel dest, int flags); + private native void nativeReadFromParcel(Parcel in); + + /* + * We use a class initializer to allow the native code to cache some + * field offsets. + */ + private static native void nativeClassInit(); + static { nativeClassInit(); } +} diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 3c43a39..0ffd201 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -118,6 +118,16 @@ public class SurfaceTexture { } /** + * Set the size of buffers returned by requestBuffers when a width and height + * of zero is requested. + * + * @hide Pending approval by API council. + */ + public void setDefaultBufferSize(int width, int height) { + nativeSetDefaultBufferSize(width, height); + } + + /** * Update the texture image to the most recent frame from the image stream. This may only be * called while the OpenGL ES context that owns the texture is bound to the thread. It will * implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target. @@ -206,6 +216,7 @@ public class SurfaceTexture { private native void nativeFinalize(); private native void nativeGetTransformMatrix(float[] mtx); private native long nativeGetTimestamp(); + private native void nativeSetDefaultBufferSize(int width, int height); private native void nativeUpdateTexImage(); /* |