library / com.otaliastudios.zoom / ZoomSurfaceView

ZoomSurfaceView

open class ZoomSurfaceView : GLSurfaceView, ZoomApi, Renderer

Uses ZoomEngine to allow zooming and pan events onto a GL rendered surface.

Types

Callback

interface Callback

A Callback to be notified of the surface lifecycle. All methods are invoked on the ui thread for convenience.

Constructors

<init>

ZoomSurfaceView(context: Context, attrs: AttributeSet? = null)

Properties

engine

val engine: ZoomEngine

surface

var surface: Surface?

A Surface that can be consumed by some buffer provider. This will be non-null after Callback.onZoomSurfaceCreated and null again after Callback.onZoomSurfaceDestroyed.

surfaceTexture

var surfaceTexture: SurfaceTexture?

A SurfaceTexture that can be consumed by some buffer provider. This will be non-null after Callback.onZoomSurfaceCreated and null again after Callback.onZoomSurfaceDestroyed.

Functions

addCallback

fun addCallback(callback: Callback): Unit

Adds a new Callback to be notified of the surface state. Should be called as soon as possible.

onDetachedFromWindow

open fun onDetachedFromWindow(): Unit

onDraw

open fun onDraw(modelMatrix: FloatArray, textureTransformMatrix: FloatArray): Unit

Called on the renderer thread when the texture is being drawn. You can, if needed, perform extra transformation by editing the textureTransformMatrix or the modelMatrix using the android.opengl.Matrix utilities.

onDrawFrame

open fun onDrawFrame(gl: GL10): Unit

Performs the texture and background drawing.

onMeasure

open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit

onSurfaceChanged

open fun onSurfaceChanged(gl: GL10, width: Int, height: Int): Unit

onSurfaceCreated

open fun onSurfaceCreated(gl: GL10?, config: EGLConfig?): Unit

onTouchEvent

open fun onTouchEvent(ev: MotionEvent): Boolean

removeCallback

fun removeCallback(callback: Callback): Unit

Removes a Callback previously added with addCallback.

setBackgroundColor

open fun setBackgroundColor(color: Int): Unit

If non transparent, we will draw this background color using GL before drawing the actual texture.

setContentSize

fun setContentSize(width: Float, height: Float): Unit

Sets the size of the content. If this is not called, the size will be assumed to be that of the ZoomSurfaceView itself. In this case, make sure to measure ZoomSurfaceView correctly or the texture will be distorted.