diff options
| author | tedbo <tedbo@google.com> | 2011-06-06 16:02:47 -0700 |
|---|---|---|
| committer | tedbo <tedbo@google.com> | 2011-06-09 11:59:23 -0700 |
| commit | 050316184b01c0d1a01c46afae7429b89a27c31b (patch) | |
| tree | b21b202cd5345f3989b512b74b227f3fc910383a /graphics/java | |
| parent | 890e013c05ed62bea9781168f3f65efebcbac4d5 (diff) | |
| download | frameworks_base-050316184b01c0d1a01c46afae7429b89a27c31b.zip frameworks_base-050316184b01c0d1a01c46afae7429b89a27c31b.tar.gz frameworks_base-050316184b01c0d1a01c46afae7429b89a27c31b.tar.bz2 | |
Add ParcelSurfaceTexture Java class to enable ISurfaceTexture sharing via Binder.
This adds a new ParcelSurfaceTexture.java class that can be instantiated with
a SurfaceTexture and used to send the corresponding ISurfaceTexture interface
to another process via Binder. The ParcelSurfaceTexture java object can then
be used to create an ANativeWindow based on the SurfaceTextureClient interface.
Change-Id: Ie38ea948b866e52f36a6d0f6cde19b54a8546817
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(); /* |
