diff options
Diffstat (limited to 'src/android/jar/src/org/qtproject/qt/android/QtTextureView.java')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt/android/QtTextureView.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtTextureView.java b/src/android/jar/src/org/qtproject/qt/android/QtTextureView.java new file mode 100644 index 0000000000..95370f3e4b --- /dev/null +++ b/src/android/jar/src/org/qtproject/qt/android/QtTextureView.java @@ -0,0 +1,51 @@ +// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +package org.qtproject.qt.android; + +import android.content.Context; +import android.graphics.SurfaceTexture; +import android.util.Log; +import android.view.Surface; +import android.view.TextureView; + +class QtTextureView extends TextureView implements TextureView.SurfaceTextureListener +{ + private final QtSurfaceInterface m_surfaceCallback; + private boolean m_staysOnTop; + private Surface m_surface; + + public QtTextureView(Context context, QtSurfaceInterface surfaceCallback, boolean isOpaque) + { + super(context); + setFocusable(false); + setFocusableInTouchMode(false); + m_surfaceCallback = surfaceCallback; + setSurfaceTextureListener(this); + setOpaque(isOpaque); + setSurfaceTexture(new SurfaceTexture(false)); + } + + @Override + public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { + m_surface = new Surface(surfaceTexture); + m_surfaceCallback.onSurfaceChanged(m_surface); + } + + @Override + public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) { + m_surface = new Surface(surfaceTexture); + m_surfaceCallback.onSurfaceChanged(m_surface); + } + + @Override + public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { + m_surfaceCallback.onSurfaceChanged(null); + return true; + } + + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { + } +} |