Merging r50160 through r50161 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_sequencer / sequencer_draw.c
index d6a2b0a001e206ed14771626a723ff4104454bbb..991ae873c5967d59ba84eb3a9a82f07d98130e82 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "BKE_sound.h"
 
+#include "IMB_colormanagement.h"
 #include "IMB_imbuf.h"
 
 #include "BIF_gl.h"
@@ -68,6 +69,9 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 /* own include */
 #include "sequencer_intern.h"
 
@@ -859,6 +863,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        float col[3];
        GLuint texid;
        GLuint last_texid;
+       unsigned char *display_buffer;
+       void *cache_handle = NULL;
 
        render_size = sseq->render_size;
        if (render_size == 0) {
@@ -932,12 +938,17 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        if (scope) {
                IMB_freeImBuf(ibuf);
                ibuf = scope;
-       }
 
-       if (ibuf->rect_float && ibuf->rect == NULL) {
-               IMB_rect_from_float(ibuf);      
+               if (ibuf->rect_float && ibuf->rect == NULL) {
+                       IMB_rect_from_float(ibuf);
+               }
+
+               display_buffer = (unsigned char *)ibuf->rect;
        }
-       
+       else {
+               display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+       }
+
        /* setting up the view - actual drawing starts here */
        UI_view2d_view_ortho(v2d);
 
@@ -950,7 +961,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
-       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
+       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
        glBegin(GL_QUADS);
 
        if (draw_overlay) {
@@ -1063,6 +1074,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
                }
        }
 
+       if (cache_handle)
+               IMB_display_buffer_release(cache_handle);
 }
 
 #if 0