summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java8
-rw-r--r--tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java10
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java11
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java9
-rw-r--r--tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java12
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml9
-rw-r--r--tests/HwAccelerationTest/res/layout/projection.xml36
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java110
8 files changed, 197 insertions, 8 deletions
diff --git a/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java b/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java
index daec845..8189fa9 100644
--- a/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java
+++ b/tests/AccessoryDisplay/sink/src/com/android/accessorydisplay/sink/DisplaySinkService.java
@@ -30,6 +30,7 @@ import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import java.io.IOException;
import java.nio.ByteBuffer;
public class DisplaySinkService extends Service implements SurfaceHolder.Callback {
@@ -150,7 +151,12 @@ public class DisplaySinkService extends Service implements SurfaceHolder.Callbac
if (mSurface != null) {
MediaFormat format = MediaFormat.createVideoFormat(
"video/avc", mSurfaceWidth, mSurfaceHeight);
- mCodec = MediaCodec.createDecoderByType("video/avc");
+ try {
+ mCodec = MediaCodec.createDecoderByType("video/avc");
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "failed to create video/avc decoder", e);
+ }
mCodec.configure(format, mSurface, null, 0);
mCodec.start();
mCodecBufferInfo = new BufferInfo();
diff --git a/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java b/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java
index 256f900..a4faca5 100644
--- a/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java
+++ b/tests/AccessoryDisplay/source/src/com/android/accessorydisplay/source/DisplaySourceService.java
@@ -32,6 +32,7 @@ import android.os.Message;
import android.view.Display;
import android.view.Surface;
+import java.io.IOException;
import java.nio.ByteBuffer;
public class DisplaySourceService extends Service {
@@ -191,8 +192,13 @@ public class DisplaySourceService extends Service {
format.setInteger(MediaFormat.KEY_BIT_RATE, BIT_RATE);
format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL);
-
- MediaCodec codec = MediaCodec.createEncoderByType("video/avc");
+ MediaCodec codec;
+ try {
+ codec = MediaCodec.createEncoderByType("video/avc");
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "failed to create video/avc encoder", e);
+ }
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Surface surface = codec.createInputSurface();
codec.start();
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java
index 0219fd7..3b3de9f 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/AudioTrackDecoder.java
@@ -59,8 +59,15 @@ public class AudioTrackDecoder extends TrackDecoder {
@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
- MediaCodec mediaCodec = MediaCodec.createDecoderByType(
- format.getString(MediaFormat.KEY_MIME));
+ MediaCodec mediaCodec;
+ try {
+ mediaCodec = MediaCodec.createDecoderByType(
+ format.getString(MediaFormat.KEY_MIME));
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "failed to create decoder for "
+ + format.getString(MediaFormat.KEY_MIME), e);
+ }
mediaCodec.configure(format, null, null, 0);
return mediaCodec;
}
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java
index 96f3059..a624010 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/CpuVideoTrackDecoder.java
@@ -29,6 +29,7 @@ import androidx.media.filterfw.Frame;
import androidx.media.filterfw.FrameImage2D;
import androidx.media.filterfw.PixelUtils;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashSet;
@@ -214,7 +215,13 @@ public class CpuVideoTrackDecoder extends VideoTrackDecoder {
return null;
} else {
String bestCodec = candidateCodecs.firstEntry().getValue();
- return MediaCodec.createByCodecName(bestCodec);
+ try {
+ return MediaCodec.createByCodecName(bestCodec);
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "failed to create codec for "
+ + bestCodec, e);
+ }
}
}
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java
index bbba9d8..f5eb513 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/GpuVideoTrackDecoder.java
@@ -28,6 +28,7 @@ import androidx.media.filterfw.FrameImage2D;
import androidx.media.filterfw.ImageShader;
import androidx.media.filterfw.TextureSource;
+import java.io.IOException;
import java.nio.ByteBuffer;
/**
@@ -86,9 +87,16 @@ public class GpuVideoTrackDecoder extends VideoTrackDecoder {
@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
+ MediaCodec mediaCodec;
+ try {
+ mediaCodec = MediaCodec.createDecoderByType(
+ format.getString(MediaFormat.KEY_MIME));
+ } catch (IOException e) {
+ throw new RuntimeException(
+ "failed to create decoder for "
+ + format.getString(MediaFormat.KEY_MIME), e);
+ }
Surface surface = new Surface(mSurfaceTexture);
- MediaCodec mediaCodec = MediaCodec.createDecoderByType(
- format.getString(MediaFormat.KEY_MIME));
mediaCodec.configure(format, surface, null, 0);
surface.release();
return mediaCodec;
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 6f774f8..0ad3456 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -858,5 +858,14 @@
</intent-filter>
</activity>
+ <activity
+ android:name="ProjectionActivity"
+ android:label="Reordering/Projection">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.android.test.hwui.TEST" />
+ </intent-filter>
+ </activity>
+
</application>
</manifest>
diff --git a/tests/HwAccelerationTest/res/layout/projection.xml b/tests/HwAccelerationTest/res/layout/projection.xml
new file mode 100644
index 0000000..564201a
--- /dev/null
+++ b/tests/HwAccelerationTest/res/layout/projection.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<view class="com.android.test.hwui.ProjectionActivity$ProjecteeLayout"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context="com.example.projection.ProjectionActivity"
+ tools:ignore="MergeRootFrame">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:textSize="50sp"
+ android:text="TextView"/>
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:clipChildren="false">
+ <view class="com.android.test.hwui.ProjectionActivity$ProjectedView"
+ android:id="@+id/projection"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:textSize="50sp"
+ android:text="TextView"/>
+ </FrameLayout>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:textSize="50sp"
+ android:text="TextView"/>
+</view> \ No newline at end of file
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java
new file mode 100644
index 0000000..51a6803
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java
@@ -0,0 +1,110 @@
+package com.android.test.hwui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.os.Bundle;
+
+import android.app.Activity;
+import android.util.AttributeSet;
+import android.view.DisplayList;
+import android.view.View;
+import android.widget.LinearLayout;
+
+public class ProjectionActivity extends Activity {
+ /**
+ * The content from this view should be projected in between the background of the
+ * ProjecteeLayout and its children, unclipped.
+ *
+ * This view doesn't clip to its bounds (because its parent has clipChildren=false) so that
+ * when it is projected onto the ProjecteeLayout, it draws outside its view bounds.
+ */
+ public static class ProjectedView extends View {
+ private final Paint mPaint = new Paint();
+ private final RectF mRectF = new RectF();
+
+ public ProjectedView(Context context) {
+ this(context, null);
+ }
+
+ public ProjectedView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ProjectedView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+
+ setOnClickListener(new OnClickListener() {
+ boolean toggle = false;
+ @Override
+ public void onClick(View v) {
+ toggle = !toggle;
+ setProject(toggle);
+ }
+ });
+ }
+
+ private void setProject(boolean value) {
+ DisplayList displayList = getDisplayList();
+ if (displayList != null) {
+ displayList.setProjectToContainedVolume(value);
+ }
+ // NOTE: we can't invalidate ProjectedView for the redraw because:
+ // 1) the view won't preserve displayList properties that it doesn't know about
+ // 2) the damage rect won't be big enough
+
+ // instead, twiddle properties on the container, so that enough area of the screen is
+ // redrawn without rerecording any DisplayLists.
+ container.setTranslationX(100f);
+ container.setTranslationX(0.0f);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ // TODO: set projection flag
+ final int w = getWidth();
+ final int h = getHeight();
+ mRectF.set(0, -h, w, 2 * h);
+ mPaint.setAntiAlias(true);
+ mPaint.setColor(0x5f00ff00);
+ canvas.drawOval(mRectF, mPaint);
+ }
+ }
+
+ public static class ProjecteeLayout extends LinearLayout {
+ private final Paint mPaint = new Paint();
+ private final RectF mRectF = new RectF();
+
+ public ProjecteeLayout(Context context) {
+ this(context, null);
+ }
+
+ public ProjecteeLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ProjecteeLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ canvas.save(0x20); // secret save flag
+ mRectF.set(0, 0, getWidth(), getHeight());
+ mPaint.setColor(0x5f000000);
+ canvas.drawOval(mRectF, mPaint);
+ canvas.restore();
+ super.dispatchDraw(canvas);
+ }
+ }
+
+ static View container;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.projection);
+ container = findViewById(R.id.container);
+ }
+}