Merging r43952 through r43994 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_clip / clip_draw.c
index 49fa7837de654c36a15b9fba721522382918d3e0..afc0d84ed9a3403480cd729590c049e4f8306134 100644 (file)
@@ -216,9 +216,6 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
        int x, y;
        MovieClip *clip= ED_space_clip(sc);
 
-       /* set zoom */
-       glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y);
-
        /* find window pixel coordinates of origin */
        UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
 
@@ -230,8 +227,36 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
                        IMB_rect_from_float(ibuf);
                }
 
-               if(ibuf->rect)
-                       glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+               if(ibuf->rect) {
+                       if(sc->flag & SC_TEXTURE_BUFFER) {
+                               ED_space_clip_load_movieclip_buffer(sc, ibuf);
+
+                               glPushMatrix();
+                               glTranslatef(x, y, 0);
+                               glScalef(zoomx, zoomy, 1.0f);
+                               glMultMatrixf(sc->stabmat);
+
+                               glBegin(GL_QUADS);
+                                       glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f,  0.0f);
+                                       glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);
+                                       glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height);
+                                       glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f,  height);
+                               glEnd();
+
+                               glPopMatrix();
+
+                               ED_space_clip_unload_movieclip_buffer(sc);
+                       }
+                       else {
+                               /* set zoom */
+                               glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y);
+
+                               glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+
+                               /* reset zoom */
+                               glPixelZoom(1.0f, 1.0f);
+                       }
+               }
        }
 
        /* draw boundary border for frame if stabilization is enabled */
@@ -260,10 +285,6 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
                glDisable(GL_COLOR_LOGIC_OP);
                glDisable(GL_LINE_STIPPLE);
        }
-
-
-       /* reset zoom */
-       glPixelZoom(1.0f, 1.0f);
 }
 
 static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackingTrack *track)