changed allignmen and filters

pull/527/head
Suneet Agrawal 6 years ago
parent fb77c2d9d9
commit 34f1a49ed2
  1. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/filters/Filter.java
  2. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/picture/SnapshotGlPictureRecorder.java
  3. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/preview/GlCameraPreview.java
  4. 12
      demo/src/main/res/layout/activity_camera.xml

@ -25,7 +25,7 @@ public abstract class Filter {
* This wil be used by GL to apply any effect. * This wil be used by GL to apply any effect.
*/ */
protected String mVertexShader = String mVertexShader =
"uniform mat4 uMVPMatrix;\n" + "uniform mat4 uMVPMatrix;\n" +
"uniform mat4 uTexMatrix;\n" + "uniform mat4 uTexMatrix;\n" +
"attribute vec4 aPosition;\n" + "attribute vec4 aPosition;\n" +
@ -41,7 +41,7 @@ public abstract class Filter {
* Fragment shader code written in Shader Language (C) and stored as String. * Fragment shader code written in Shader Language (C) and stored as String.
* This wil be used by GL to apply any effect. * This wil be used by GL to apply any effect.
*/ */
protected String mFragmentShader = String mFragmentShader =
"#extension GL_OES_EGL_image_external : require\n" "#extension GL_OES_EGL_image_external : require\n"
+ "precision mediump float;\n" + "precision mediump float;\n"
+ "varying vec2 vTextureCoord;\n" + "varying vec2 vTextureCoord;\n"
@ -54,10 +54,10 @@ public abstract class Filter {
* Width and height of previewing GlSurfaceview. * Width and height of previewing GlSurfaceview.
* This will be used by a few effects. * This will be used by a few effects.
*/ */
protected int mPreviewingViewWidth = 0; int mPreviewingViewWidth = 0;
protected int mPreviewingViewHeight = 0; int mPreviewingViewHeight = 0;
public void setPreviewingViewWidthAndHeight(int width, int height){ public void setPreviewingViewSize(int width, int height){
mPreviewingViewWidth = width; mPreviewingViewWidth = width;
mPreviewingViewHeight = height; mPreviewingViewHeight = height;
} }

@ -149,8 +149,8 @@ public class SnapshotGlPictureRecorder extends PictureRecorder {
*/ */
@RendererThread @RendererThread
@TargetApi(Build.VERSION_CODES.KITKAT) @TargetApi(Build.VERSION_CODES.KITKAT)
private void onRendererFrame(final @NonNull SurfaceTexture surfaceTexture, final float scaleX, final float scaleY, @NonNull BaseShaderEffect effect) { private void onRendererFrame(final @NonNull SurfaceTexture surfaceTexture, final float scaleX, final float scaleY, @NonNull Filter filter) {
mViewport.changeShaderEffect(effect); mViewport.changeShaderEffect(filter);
// Get egl context from the RendererThread, which is the one in which we have created // Get egl context from the RendererThread, which is the one in which we have created
// the textureId and the overlayTextureId, managed by the GlSurfaceView. // the textureId and the overlayTextureId, managed by the GlSurfaceView.
// Next operations can then be performed on different threads using this handle. // Next operations can then be performed on different threads using this handle.

@ -318,7 +318,7 @@ public class GlCameraPreview extends CameraPreview<GLSurfaceView, SurfaceTexture
public void setShaderEffect(Filter shaderEffect){ public void setShaderEffect(Filter shaderEffect){
mCurrentShaderEffect = shaderEffect; mCurrentShaderEffect = shaderEffect;
shaderEffect.setPreviewingViewWidthAndHeight(getView().getWidth(), getView().getHeight()); shaderEffect.setPreviewingViewSize(getView().getWidth(), getView().getHeight());
mOutputViewport.changeShaderEffect(shaderEffect); mOutputViewport.changeShaderEffect(shaderEffect);
} }

@ -48,26 +48,26 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginBottom="96dp"
android:layout_gravity="top|end"> android:layout_gravity="bottom|start">
<ImageButton <ImageButton
android:id="@+id/toggleCamera" android:id="@+id/changeFilter"
android:layout_width="56dp" android:layout_width="56dp"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:background="@drawable/background" android:background="@drawable/background"
android:elevation="3dp" android:elevation="3dp"
app:srcCompat="@drawable/ic_switch" /> app:srcCompat="@drawable/ic_filters" />
<ImageButton <ImageButton
android:id="@+id/changeFilter" android:id="@+id/toggleCamera"
android:layout_width="56dp" android:layout_width="56dp"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:background="@drawable/background" android:background="@drawable/background"
android:elevation="3dp" android:elevation="3dp"
app:srcCompat="@drawable/ic_filters" /> app:srcCompat="@drawable/ic_switch" />
</LinearLayout> </LinearLayout>
<!-- Controls --> <!-- Controls -->

Loading…
Cancel
Save