Surface Class

Definition

Handle onto a raw buffer that is being managed by the screen compositor.

[Android.Runtime.Register("android/view/Surface", DoNotGenerateAcw=true)]
public class Surface : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/view/Surface", DoNotGenerateAcw=true)>]
type Surface = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Surface
Attributes
Implements

Remarks

Handle onto a raw buffer that is being managed by the screen compositor.

A Surface is generally created by or from a consumer of image buffers (such as a android.graphics.SurfaceTexture, android.media.MediaRecorder, or android.renderscript.Allocation), and is handed to some kind of producer (such as android.opengl.EGL14#eglCreateWindowSurface(android.opengl.EGLDisplay,android.opengl.EGLConfig,java.lang.Object,int[],int) OpenGL, android.media.MediaPlayer#setSurface MediaPlayer, or android.hardware.camera2.CameraDevice#createCaptureSession CameraDevice) to draw into.

<strong>Note:</strong> A Surface acts like a java.lang.ref.WeakReference weak reference to the consumer it is associated with. By itself it will not keep its parent consumer from being reclaimed.

Java documentation for android.view.Surface.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
Surface(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Surface(SurfaceControl)

Create a Surface associated with a given SurfaceControl.

Surface(SurfaceTexture)

Create Surface from a SurfaceTexture.

Fields

Name Description
ChangeFrameRateAlways
Obsolete.

Change the frame rate even if the transition is going to be non-seamless, i.

ChangeFrameRateOnlyIfSeamless
Obsolete.

Change the frame rate only if the transition is going to be seamless.

FrameRateCompatibilityAtLeast
Obsolete.

The surface requests a frame rate that is at least the specified frame rate.

FrameRateCompatibilityDefault
Obsolete.

There are no inherent restrictions on the frame rate of this surface.

FrameRateCompatibilityFixedSource
Obsolete.

This surface is being used to display content with an inherently fixed frame rate, e.

Gpu

Indicates the GPU surface-creation flag.

Hardware

Indicates the hardware surface-creation flag.

Hidden

Indicates the hidden surface-creation flag.

NonPremultiplied

Indicates the non-premultiplied surface-creation flag.

PushBuffers

Indicates the push buffers surface-creation flag.

Secure

Indicates the secure surface-creation flag.

SuraceFrozen

Indicates the surface frozen surface-creation flag.

SurfaceBlurFreeze

Indicates the surface blur freeze surface-creation flag.

SurfaceDither

Indicates the surface dithering surface-creation flag.

SurfaceFrozen

Indicates the surface frozen surface-creation flag.

SurfaceHidden

Indicates the surface hidden surface-creation flag.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator

Gets the parcelable creator for Surface instances.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsValid

Returns true if this object holds a valid surface.

JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniPeerMembers

Gets the JNI peer metadata used by the .NET for Android binding runtime.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

Gets the JNI class handle used by the .NET for Android binding runtime.

ThresholdType

Gets the managed type used by the .NET for Android binding runtime.

Methods

Name Description
ClearFrameRate()

Clears the frame rate which was set for this surface. This is equivalent to calling setFrameRate(float, int, int) using 0 for frameRate . Note that this only has an effect for surfaces presented on the display. If this surface is consumed by something other than the system compositor, e.g. a media codec, this call has no effect.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Freeze()

Invokes this Surface's corresponding legacy state operation.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Hide()

Invokes this Surface's corresponding legacy state operation.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LockCanvas(Rect)

Gets a Canvas for drawing into this surface.

LockHardwareCanvas()

Gets a Canvas for drawing into this surface.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ReadFromParcel(Parcel)

Restores this surface from a parcel.

Release()

Release the local reference to the server-side surface.

SetAlpha(Single)

Sets the alpha value applied when this surface is composited.

SetFlags(Int32, Int32)

Updates this surface's flags by applying the supplied mask.

SetFrameRate(Single, Int32, Int32)

Sets the intended frame rate for this surface.

SetFrameRate(Single, Int32)

Sets the intended frame rate for this surface.

SetFreezeTint(Int32)

Sets the color tint applied when this surface's content is frozen.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLayer(Int32)

Sets this surface's Z-order layer within its parent.

SetMatrix(Single, Single, Single, Single)

Applies the supplied two-by-two transform matrix to this surface's buffer.

SetOrientation(Int32, SurfaceOrientation)

Sets the orientation for the supplied display.

SetPosition(Int32, Int32)

Sets this surface's position in its parent coordinate space.

SetSize(Int32, Int32)

Sets this surface's buffer width and height.

SetTransparentRegionHint(Region)

Supplies the compositor with a hint describing this surface's transparent region.

Show()

Invokes this Surface's corresponding legacy state operation.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Unfreeze()

Invokes this Surface's corresponding legacy state operation.

UnlockCanvas(Canvas)
Obsolete.

Posts drawing to the surface and releases the canvas.

UnlockCanvasAndPost(Canvas)

Posts the new contents of the Canvas to the surface and releases the Canvas.

UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed()

Notifies the interop runtime that this managed peer has been disposed.

(Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced()

Releases this Java peer unless it is retained by another managed reference.

(Inherited from Object)
IJavaPeerable.Finalized()

Notifies the interop runtime that this managed peer has been finalized.

(Inherited from Object)
IJavaPeerable.JniManagedPeerState

Gets the state that describes the relationship between this managed peer and its JNI reference.

(Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Sets the interop identity hash code for this Java peer.

(Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Sets the managed and JNI peer state for this Java peer.

(Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

Sets the JNI object reference used by this managed peer.

(Inherited from Object)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to