Merging r50049 through r50076 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_sequencer / sequencer_draw.c
index 25514b3168b2bfe2c848a43a6e6b63ee00ce5136..19da6e9124768c3b619a8b71ae1140484a6874f8 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"
 
@@ -825,6 +829,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        GLuint texid;
        GLuint last_texid;
        SeqRenderData context;
+       unsigned char *display_buffer;
+       void *cache_handle = NULL;
 
        render_size = sseq->render_size;
        if (render_size == 0) {
@@ -905,12 +911,23 @@ 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);
+               }
+
+               display_buffer = (unsigned char *)ibuf->rect;
        }
+       else {
+               const ColorManagedViewSettings *view_settings;
+               wmWindow *win = CTX_wm_window(C);
+
+               ibuf->colormanagement_flags |= IMB_COLORMANAGEMENT_SRGB_SOURCE;
 
-       if (ibuf->rect_float && ibuf->rect == NULL) {
-               IMB_rect_from_float(ibuf);      
+               view_settings = IMB_view_settings_get_effective(win, &sseq->view_settings);
+               display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, &win->display_settings, &cache_handle);
        }
-       
+
        /* setting up the view - actual drawing starts here */
        UI_view2d_view_ortho(v2d);
 
@@ -923,7 +940,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) {
@@ -1036,6 +1053,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