summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src/org/qtproject/qt/android/QtTextureView.java
blob: 828838a9f019be1bdfcd6463b895f71357c9233a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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.PixelFormat;
import android.graphics.SurfaceTexture;
import android.util.Log;
import android.view.Surface;
import android.view.TextureView;

public class QtTextureView extends TextureView implements TextureView.SurfaceTextureListener
{
    private 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) {
    }
}