droid_wrap::android::graphics

Struct SurfaceTexture

Source
pub struct SurfaceTexture { /* private fields */ }
Expand description

将图像流中的帧捕获为 OpenGL ES 纹理。图像流可能来自相机预览或视频解码。从 SurfaceTexture 创建的 Surface 可用作 android.hardware.camera2、android.media.MediaCodec、android.media.MediaPlayer 和 android.renderscript.Allocation API 的输出目标。 调用 updateTexImage 时,创建 SurfaceTexture 时指定的纹理对象的内容将更新为包含图像流中的最新图像。这可能会导致跳过流的某些帧。 在指定较旧的 android.hardware.Camera API 的输出目标时,还可以使用 SurfaceTexture 代替 SurfaceHolder。这样做会导致图像流中的所有帧都被发送到 SurfaceTexture 对象,而不是设备的显示器。 一种典型的模式是使用 SurfaceTexture 将帧渲染到 TextureView;但是,使用纹理对象不需要 TextureView。纹理对象可以用作 OpenGL ES 着色器的一部分。 从纹理采样时,首先应使用通过 getTransformMatrix(float[]) 查询的矩阵转换纹理坐标。每次调用 updateTexImage 时,转换矩阵可能会发生变化,因此每次更新纹理图像时都应重新查询。 此矩阵将传统的 2D OpenGL ES 纹理坐标列向量(形式为 (s, t, 0, 1),其中 s 和 t 位于包含区间 [0, 1] 上)转换为流式纹理中的正确采样位置。此转换可补偿图像流源的任何属性,这些属性会导致它看起来与传统的 OpenGL ES 纹理不同。 例如,可以通过使用查询的矩阵转换列向量 (0, 0, 0, 1) 来完成从图像左下角的采样,而通过转换 (1, 1, 0, 1) 来完成从图像右上角的采样。纹理对象使用 GL_TEXTURE_EXTERNAL_OES 纹理目标,该目标由 GL_OES_EGL_image_external OpenGL ES 扩展定义。 这限制了纹理的使用方式。每次绑定纹理时,它都必须绑定到 GL_TEXTURE_EXTERNAL_OES 目标,而不是 GL_TEXTURE_2D 目标。此外,任何从纹理采样的 OpenGL ES 2.0 着色器都必须声明其对此扩展的使用,例如使用“#extension GL_OES_EGL_image_external : require”指令。 此类着色器还必须使用 samplerExternalOES GLSL 采样器类型访问纹理。 SurfaceTexture 对象可以在任何线程上创建。updateTexImage 只能在具有包含纹理对象的 OpenGL ES 上下文的线程上调用。帧可用回调在任意线程上调用,因此除非特别小心,否则不应直接从回调中调用 updateTexImage。

Methods from Deref<Target = GlobalRef>§

Source

pub fn as_obj(&self) -> &JObject<'static>

Get the object from the global ref

This borrows the ref and prevents it from being dropped as long as the JObject sticks around.

Methods from Deref<Target = JObject<'static>>§

Source

pub fn as_raw(&self) -> *mut _jobject

Returns the raw JNI pointer.

Trait Implementations§

Source§

impl Debug for SurfaceTexture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SurfaceTexture

Source§

type Target = GlobalRef

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<&GlobalRef> for SurfaceTexture

Source§

fn from(obj: &GlobalRef) -> Self

Converts to this type from the input type.
Source§

impl Into<GlobalRef> for &SurfaceTexture

Source§

fn into(self) -> GlobalRef

Converts this type into the (usually inferred) input type.
Source§

impl JObjNew for SurfaceTexture

Source§

type Fields = ()

字段类型
Source§

fn _new(this: &GlobalRef, fields: Self::Fields) -> Self

从java对象创建本地对象。 this java对象引用。
Source§

fn null() -> Self
where Self: Sized, Self::Fields: Default,

创建空对象。
Source§

impl JObjRef for SurfaceTexture

Source§

fn java_ref(&self) -> GlobalRef

获取java对象引用。
Source§

impl JType for SurfaceTexture

Source§

const CLASS: &'static str = "android/graphics/SurfaceTexture"

java类的名称。
Source§

const OBJECT_SIG: &'static str = "Landroid/graphics/SurfaceTexture;"

对象的签名描述。
Source§

type Error = Error

错误类型。
Source§

const DIM: u8 = 0u8

数组维度,0表示不是数组
Source§

impl PartialEq for SurfaceTexture

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for SurfaceTexture

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.