]> git.sesse.net Git - vlc/commitdiff
opengl: Do subtexture uploads only for the visible area
authorMartin Storsjö <martin@martin.st>
Fri, 29 Mar 2013 23:56:52 +0000 (01:56 +0200)
committerMartin Storsjö <martin@martin.st>
Mon, 1 Apr 2013 08:10:26 +0000 (11:10 +0300)
This avoids doing the intermediate copy in some cases.

Signed-off-by: Martin Storsjö <martin@martin.st>
modules/video_output/opengl.c

index 0801faa638dac88b40464604a6b4863e8141c77f..2db2272a3fec570eb03b169d1622769e5d9af0ee 100644 (file)
@@ -714,10 +714,10 @@ static void Upload(vout_display_opengl_t *vgl, int in_width, int in_height,
     // This unpack alignment is the default, but setting it just in case.
     glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 #ifndef GL_UNPACK_ROW_LENGTH
-    if ( pitch != ALIGN(full_width * pixel_pitch, 4) )
+    int dst_width = full_upload ? full_width : width;
+    int dst_pitch = ALIGN(dst_width * pixel_pitch, 4);
+    if ( pitch != dst_pitch )
     {
-        int dst_width = full_upload ? full_width : width;
-        int dst_pitch = ALIGN(dst_width * pixel_pitch, 4);
         int buf_size = dst_pitch * full_height * pixel_pitch;
         const uint8_t *source = pixels;
         uint8_t *destination;
@@ -759,7 +759,7 @@ static void Upload(vout_display_opengl_t *vgl, int in_width, int in_height,
         else
             glTexSubImage2D(tex_target, 0,
                             0, 0,
-                            full_width, full_height,
+                            width, height,
                             tex_format, tex_type, pixels);
     }
 }