diff options
author | 2018-07-02 11:12:27 -0400 | |
---|---|---|
committer | 2018-07-12 14:52:22 +0000 | |
commit | bb5b7588d67aa3ed24f1b44ded654215e1818b2f (patch) | |
tree | 28c8942666a21d5ee8897575a933a53eb913486a /platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java | |
parent | fe76395c4ddc1c50af8df4e7e393b479b76b52a9 (diff) |
Java-only version of SkAR: drawing on android Canvas
Bug: skia:
Change-Id: I3b85fac93a2854d1575f71554e2a7da66e8a6a6f
Reviewed-on: https://skia-review.googlesource.com/138920
Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java')
-rw-r--r-- | platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java b/platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java new file mode 100644 index 0000000000..eaa336cc9e --- /dev/null +++ b/platform_tools/android/apps/skar_java/src/main/java/com/google/ar/core/examples/java/helloskar/ARSurfaceView.java @@ -0,0 +1,45 @@ +package com.google.ar.core.examples.java.helloskar; + +import android.content.Context; +import android.graphics.Color; +import android.graphics.PixelFormat; +import android.util.AttributeSet; +import android.view.SurfaceHolder; +import android.view.SurfaceView; + +/** + * SurfaceView that is overlayed on top of a GLSurfaceView. All 2D drawings can be done on this + * surface. + */ +public class ARSurfaceView extends SurfaceView implements SurfaceHolder.Callback { + + boolean running; + + public ARSurfaceView(Context context, AttributeSet attrs) { + super(context, attrs); + + SurfaceHolder holder = getHolder(); + this.setBackgroundColor(Color.TRANSPARENT); + this.setZOrderOnTop(true); + holder.setFormat(PixelFormat.TRANSPARENT); + holder.addCallback(this); + } + + public boolean isRunning() { + return running; + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + running = true; + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + running = false; + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { + } +} |