mirror of
https://github.com/wang-bin/QtAV.git
synced 2026-10-28 19:16:48 +08:00
gl: add a function to check and update textures
This commit is contained in:
@@ -519,7 +519,7 @@ bool GLWidgetRendererPrivate::initTextures(const VideoFormat &fmt)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLWidgetRendererPrivate::upload(const QRect &roi)
|
||||
void GLWidgetRendererPrivate::updateTexturesIfNeeded()
|
||||
{
|
||||
const VideoFormat &fmt = video_frame.format();
|
||||
bool update_textures = false;
|
||||
@@ -555,7 +555,11 @@ void GLWidgetRendererPrivate::upload(const QRect &roi)
|
||||
if (update_textures) {
|
||||
initTextures(fmt);
|
||||
}
|
||||
}
|
||||
|
||||
void GLWidgetRendererPrivate::upload(const QRect &roi)
|
||||
{
|
||||
updateTexturesIfNeeded();
|
||||
for (int i = 0; i < video_frame.planeCount(); ++i) {
|
||||
uploadPlane(i, internal_format[i], data_format[i], roi);
|
||||
}
|
||||
@@ -712,7 +716,6 @@ void GLWidgetRenderer::drawFrame()
|
||||
DPTR_D(GLWidgetRenderer);
|
||||
QRect roi = realROI();
|
||||
d.upload(roi);
|
||||
|
||||
// shader program may not ready before upload
|
||||
if (d.hasGLSL) {
|
||||
#if NO_QGL_SHADER
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
bool prepareShaderProgram(const VideoFormat& fmt);
|
||||
bool initTexture(GLuint tex, GLint internal_format, GLenum format, GLenum dataType, int width, int height);
|
||||
bool initTextures(const VideoFormat& fmt);
|
||||
void updateTexturesIfNeeded();
|
||||
void upload(const QRect& roi);
|
||||
void uploadPlane(int p, GLint internal_format, GLenum format, const QRect& roi);
|
||||
//GL 4.x: GL_FRAGMENT_SHADER_DERIVATIVE_HINT,GL_TEXTURE_COMPRESSION_HINT
|
||||
|
||||
Reference in New Issue
Block a user