Merging r50160 through r50161 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 23 Aug 2012 16:15:37 +0000 (16:15 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 23 Aug 2012 16:15:37 +0000 (16:15 +0000)
1  2 
source/blender/editors/space_sequencer/sequencer_draw.c

index 50fffeac09d58e90fba4180a7a2a18c8395346d9,d6a2b0a001e206ed14771626a723ff4104454bbb..991ae873c5967d59ba84eb3a9a82f07d98130e82
@@@ -52,7 -52,6 +52,7 @@@
  
  #include "BKE_sound.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  
  #include "BIF_gl.h"
@@@ -69,9 -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"
  
@@@ -815,6 -811,41 +815,41 @@@ static void UNUSED_FUNCTION(set_special
        else special_seq_update = NULL;
  }
  
+ ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs)
+ {
+       SeqRenderData context;
+       ImBuf *ibuf;
+       int rectx, recty;
+       float render_size = 0.0;
+       float proxy_size = 100.0;
+       render_size = sseq->render_size;
+       if (render_size == 0) {
+               render_size = scene->r.size;
+       }
+       else {
+               proxy_size = render_size;
+       }
+       if (render_size < 0) {
+               return NULL;
+       }
+       rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f;
+       recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
+       context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size);
+       if (special_seq_update)
+               ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update);
+       else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
+               ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown);
+       else
+               ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown);
+       return ibuf;
+ }
  void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
  {
        struct Main *bmain = CTX_data_main(C);
        float col[3];
        GLuint texid;
        GLuint last_texid;
-       SeqRenderData context;
 +      unsigned char *display_buffer;
 +      void *cache_handle = NULL;
  
        render_size = sseq->render_size;
        if (render_size == 0) {
        if (G.is_rendering)
                return;
  
-       context = BKE_sequencer_new_render_data(bmain, scene, rectx, recty, proxy_size);
-       if (special_seq_update)
-               ibuf = BKE_sequencer_give_ibuf_direct(context, cfra + frame_ofs, special_seq_update);
-       else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) {
-               ibuf = BKE_sequencer_give_ibuf(context, cfra + frame_ofs, sseq->chanshown);
-       else
-               ibuf = BKE_sequencer_give_ibuf_threaded(context, cfra + frame_ofs, sseq->chanshown);
+       ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs);
        
        if (ibuf == NULL)
                return;
        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);
  
        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) {
                }
        }
  
 +      if (cache_handle)
 +              IMB_display_buffer_release(cache_handle);
  }
  
  #if 0