Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
QtTextureView.java
Go to the documentation of this file.
1
// Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
2
// Copyright (C) 2016 The Qt Company Ltd.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5
package
org.qtproject.qt.android;
6
7
import
android.annotation.SuppressLint;
8
import
android.content.Context;
9
import
android.graphics.SurfaceTexture;
10
import
android.view.Surface;
11
import
android.view.TextureView;
12
13
@SuppressLint(
"ViewConstructor"
)
14
class QtTextureView extends TextureView implements TextureView.SurfaceTextureListener
15
{
16
private
final
QtSurfaceInterface
m_surfaceCallback;
17
private
boolean
m_staysOnTop;
18
private
Surface m_surface;
19
20
QtTextureView(
Context
context,
QtSurfaceInterface
surfaceCallback,
boolean
isOpaque)
21
{
22
super(context);
23
setFocusable(
false
);
24
setFocusableInTouchMode(
false
);
25
m_surfaceCallback = surfaceCallback;
26
setSurfaceTextureListener(
this
);
27
setOpaque(isOpaque);
28
setSurfaceTexture(
new
SurfaceTexture(
false
));
29
}
30
31
@
Override
32
public
void
onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
int
width
,
int
height
) {
33
if
(m_surface ==
null
) {
34
m_surface =
new
Surface(surfaceTexture);
35
m_surfaceCallback.onSurfaceCreated(m_surface);
36
}
37
}
38
39
@
Override
40
public
void
onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture,
int
width
,
int
height
) {
41
// A SurfaceTexture set in the constructor never gets onSurfaceTextureAvailable,
42
// so the first resize delivers the Surface.
43
if
(m_surface ==
null
) {
44
m_surface =
new
Surface(surfaceTexture);
45
m_surfaceCallback.onSurfaceCreated(m_surface);
46
return
;
47
}
48
// HWUI shows the old buffer at the new size until Qt draws, and offers
49
// nothing to wait on, so ask for a frame right away.
50
m_surfaceCallback.onSurfaceRedrawNeeded(() -> {});
51
}
52
53
@
Override
54
public
boolean
onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
55
final
Surface surface = m_surface;
56
m_surface =
null
;
57
m_surfaceCallback.onSurfaceDestroyed(() -> {
58
if
(surface !=
null
)
59
surface.release();
60
surfaceTexture.release();
61
});
62
return
false
;
63
}
64
65
@
Override
66
public
void
onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
67
}
68
}
Context
QPainter Context
Definition
container_qpainter.cpp:30
org.qtproject.qt.android.QtSurfaceInterface
Definition
QtSurfaceInterface.java:10
QtMocConstants::Override
@ Override
Definition
qtmocconstants.h:43
width
GLint GLsizei width
Definition
qopengles2ext.h:206
height
EGLint height
Definition
libhybriseglserverbufferintegration.h:28
qtbase
src
android
jar
src
org
qtproject
qt
android
QtTextureView.java
Generated on
for Qt by
1.18.0