Rename setPreviewingViewSize

pull/535/head
Mattia Iavarone 6 years ago
parent 20485100da
commit ba1846bbcb
  1. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/filters/Filter.java
  2. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/internal/egl/EglViewport.java
  3. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/preview/FilterCameraPreview.java
  4. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/preview/GlCameraPreview.java

@ -60,7 +60,7 @@ public abstract class Filter {
int mPreviewingViewWidth = 0; int mPreviewingViewWidth = 0;
int mPreviewingViewHeight = 0; int mPreviewingViewHeight = 0;
public void setPreviewingViewSize(int width, int height) { public void setOutputSize(int width, int height) {
mPreviewingViewWidth = width; mPreviewingViewWidth = width;
mPreviewingViewHeight = height; mPreviewingViewHeight = height;
} }

@ -112,27 +112,12 @@ public class EglViewport extends EglElement {
mFilterChanged = true; mFilterChanged = true;
} }
public void drawFrame(int textureId, float[] textureMatrix) { public void drawFrame(int textureId, float[] textureMatrix) {
drawFrame(textureId, textureMatrix, drawFrame(textureId, textureMatrix,
mVertexCoordinatesArray, mVertexCoordinatesArray,
mTextureCoordinatesArray); mTextureCoordinatesArray);
} }
/**
* The issue with the CIRCLE shader is that if the textureMatrix has a scale value,
* it fails miserably, not taking the scale into account.
* So what we can do here is
*
* - read textureMatrix scaleX and scaleY values. This is pretty much impossible to do from the matrix itself
* without making risky assumptions over the order of operations.
* https://www.opengl.org/discussion_boards/showthread.php/159215-Is-it-possible-to-extract-rotation-translation-scale-given-a-matrix
* So we prefer passing scaleX and scaleY here to the draw function.
* - pass these values to the vertex shader
* - pass them to the fragment shader
* - in the fragment shader, take this scale value into account
*/
private void drawFrame(int textureId, float[] textureMatrix, private void drawFrame(int textureId, float[] textureMatrix,
FloatBuffer vertexBuffer, FloatBuffer vertexBuffer,
FloatBuffer texBuffer) { FloatBuffer texBuffer) {

@ -13,7 +13,7 @@ import com.otaliastudios.cameraview.filters.Filter;
/** /**
* A preview that support GL filters defined through the {@link Filter} interface. * A preview that support GL filters defined through the {@link Filter} interface.
* *
* The preview has the responsibility of calling {@link Filter#setPreviewingViewSize(int, int)} * The preview has the responsibility of calling {@link Filter#setOutputSize(int, int)}
* whenever the preview size changes and as soon as the filter is applied. * whenever the preview size changes and as soon as the filter is applied.
*/ */
public abstract class FilterCameraPreview<T extends View, Output> extends CameraPreview<T, Output> { public abstract class FilterCameraPreview<T extends View, Output> extends CameraPreview<T, Output> {

@ -171,7 +171,7 @@ public class GlCameraPreview extends FilterCameraPreview<GLSurfaceView, SurfaceT
@Override @Override
public void onSurfaceChanged(GL10 gl, final int width, final int height) { public void onSurfaceChanged(GL10 gl, final int width, final int height) {
gl.glViewport(0, 0, width, height); gl.glViewport(0, 0, width, height);
mCurrentFilter.setPreviewingViewSize(width, height); mCurrentFilter.setOutputSize(width, height);
if (!mDispatched) { if (!mDispatched) {
dispatchOnSurfaceAvailable(width, height); dispatchOnSurfaceAvailable(width, height);
mDispatched = true; mDispatched = true;
@ -327,7 +327,7 @@ public class GlCameraPreview extends FilterCameraPreview<GLSurfaceView, SurfaceT
@Override @Override
public void setFilter(@NonNull Filter filter) { public void setFilter(@NonNull Filter filter) {
if (hasSurface()) { if (hasSurface()) {
filter.setPreviewingViewSize(mOutputSurfaceWidth, mOutputSurfaceHeight); filter.setOutputSize(mOutputSurfaceWidth, mOutputSurfaceHeight);
} }
mCurrentFilter = filter; mCurrentFilter = filter;
if (mOutputViewport != null) { if (mOutputViewport != null) {

Loading…
Cancel
Save