gl: add a function to check and update textures

This commit is contained in:
wang-bin
2014-04-30 18:46:45 +08:00
parent 2a6b5f70d4
commit fa950e7edc
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -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
+1
View File
@@ -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