Reapply "Revert orientation tracking on the camera image"
This reverts commit c0bab85d63.
This commit is contained in:
parent
dd4471c7d2
commit
b0691adfa3
7 changed files with 55 additions and 171 deletions
|
|
@ -20,15 +20,6 @@ import kotlin.math.sin
|
|||
*/
|
||||
class TiltShiftShader(private val context: Context) {
|
||||
|
||||
private companion object {
|
||||
val IDENTITY_MATRIX = floatArrayOf(
|
||||
1f, 0f, 0f, 0f,
|
||||
0f, 1f, 0f, 0f,
|
||||
0f, 0f, 1f, 0f,
|
||||
0f, 0f, 0f, 1f
|
||||
)
|
||||
}
|
||||
|
||||
// --- Passthrough program (camera → FBO) ---
|
||||
|
||||
private var passthroughProgramId: Int = 0
|
||||
|
|
@ -38,8 +29,6 @@ class TiltShiftShader(private val context: Context) {
|
|||
var passthroughTexCoordLoc: Int = 0
|
||||
private set
|
||||
private var passthroughTextureLoc: Int = 0
|
||||
private var passthroughTexMatrixLoc: Int = 0
|
||||
private var passthroughMirrorLoc: Int = 0
|
||||
|
||||
// --- Blur program (FBO → FBO/screen) ---
|
||||
|
||||
|
|
@ -50,8 +39,6 @@ class TiltShiftShader(private val context: Context) {
|
|||
var blurTexCoordLoc: Int = 0
|
||||
private set
|
||||
private var blurTextureLoc: Int = 0
|
||||
private var blurTexMatrixLoc: Int = 0
|
||||
private var blurMirrorLoc: Int = 0
|
||||
private var blurModeLoc: Int = 0
|
||||
private var blurPositionXLoc: Int = 0
|
||||
private var blurPositionYLoc: Int = 0
|
||||
|
|
@ -81,8 +68,6 @@ class TiltShiftShader(private val context: Context) {
|
|||
passthroughPositionLoc = GLES20.glGetAttribLocation(passthroughProgramId, "aPosition")
|
||||
passthroughTexCoordLoc = GLES20.glGetAttribLocation(passthroughProgramId, "aTexCoord")
|
||||
passthroughTextureLoc = GLES20.glGetUniformLocation(passthroughProgramId, "uTexture")
|
||||
passthroughTexMatrixLoc = GLES20.glGetUniformLocation(passthroughProgramId, "uTexMatrix")
|
||||
passthroughMirrorLoc = GLES20.glGetUniformLocation(passthroughProgramId, "uMirrorX")
|
||||
|
||||
// Blur program
|
||||
val blurFragSource = loadShaderSource(R.raw.tiltshift_fragment)
|
||||
|
|
@ -93,8 +78,6 @@ class TiltShiftShader(private val context: Context) {
|
|||
blurPositionLoc = GLES20.glGetAttribLocation(blurProgramId, "aPosition")
|
||||
blurTexCoordLoc = GLES20.glGetAttribLocation(blurProgramId, "aTexCoord")
|
||||
blurTextureLoc = GLES20.glGetUniformLocation(blurProgramId, "uTexture")
|
||||
blurTexMatrixLoc = GLES20.glGetUniformLocation(blurProgramId, "uTexMatrix")
|
||||
blurMirrorLoc = GLES20.glGetUniformLocation(blurProgramId, "uMirrorX")
|
||||
blurModeLoc = GLES20.glGetUniformLocation(blurProgramId, "uMode")
|
||||
blurPositionXLoc = GLES20.glGetUniformLocation(blurProgramId, "uPositionX")
|
||||
blurPositionYLoc = GLES20.glGetUniformLocation(blurProgramId, "uPositionY")
|
||||
|
|
@ -113,19 +96,12 @@ class TiltShiftShader(private val context: Context) {
|
|||
|
||||
/**
|
||||
* Activates the passthrough program and binds the camera texture.
|
||||
*
|
||||
* @param cameraTextureId The OES texture receiving camera frames.
|
||||
* @param texMatrix 4x4 transform from SurfaceTexture.getTransformMatrix() —
|
||||
* encodes sensor-to-display rotation and Y-flip.
|
||||
* @param mirrorX true to horizontally mirror (front camera selfie view).
|
||||
*/
|
||||
fun usePassthrough(cameraTextureId: Int, texMatrix: FloatArray, mirrorX: Boolean) {
|
||||
fun usePassthrough(cameraTextureId: Int) {
|
||||
GLES20.glUseProgram(passthroughProgramId)
|
||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0)
|
||||
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTextureId)
|
||||
GLES20.glUniform1i(passthroughTextureLoc, 0)
|
||||
GLES20.glUniformMatrix4fv(passthroughTexMatrixLoc, 1, false, texMatrix, 0)
|
||||
GLES20.glUniform1f(passthroughMirrorLoc, if (mirrorX) 1f else 0f)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,10 +128,6 @@ class TiltShiftShader(private val context: Context) {
|
|||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, fboTextureId)
|
||||
GLES20.glUniform1i(blurTextureLoc, 0)
|
||||
|
||||
// FBO content is already in display orientation — pass identity matrix and no mirror.
|
||||
GLES20.glUniformMatrix4fv(blurTexMatrixLoc, 1, false, IDENTITY_MATRIX, 0)
|
||||
GLES20.glUniform1f(blurMirrorLoc, 0f)
|
||||
|
||||
GLES20.glUniform1i(blurModeLoc, if (params.mode == BlurMode.RADIAL) 1 else 0)
|
||||
GLES20.glUniform1f(blurPositionXLoc, params.positionX)
|
||||
GLES20.glUniform1f(blurPositionYLoc, params.positionY)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue