Merging r44227 through r45619 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_clip / clip_draw.c
index bf8976035a8a8d217dd959e971536c800e1c17e0..a553566ca6951cca716547e42023ac047aef1706 100644 (file)
@@ -229,9 +229,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);
 
@@ -242,8 +239,35 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
        else {
                verify_buffer_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.0f);
+                               glScalef(zoomx, zoomy, 1.0f);
+
+                               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 */
@@ -255,9 +279,9 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
                glLogicOp(GL_NOR);
 
                glPushMatrix();
-               glTranslatef(x, y, 0);
+               glTranslatef(x, y, 0.0f);
 
-               glScalef(zoomx, zoomy, 0);
+               glScalef(zoomx, zoomy, 1.0f);
                glMultMatrixf(sc->stabmat);
 
                glBegin(GL_LINE_LOOP);
@@ -272,10 +296,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)