svn merge ^/trunk/blender -r48674:48681
authorCampbell Barton <ideasman42@gmail.com>
Fri, 6 Jul 2012 14:25:49 +0000 (14:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 6 Jul 2012 14:25:49 +0000 (14:25 +0000)
1  2 
SConstruct
source/blender/editors/space_node/drawnode.c
source/blender/makesrna/intern/rna_space.c
source/blender/render/intern/source/external_engine.c

diff --combined SConstruct
index 93a209bac9a889c8766a51284f8a3a182d51fd09,993167acfe97af3f8307999465c60e8ca6fca43b..f0250808faf198c54183dd811b5c925200122e95
@@@ -609,27 -609,7 +609,27 @@@ if env['OURPLATFORM']!='darwin'
                      kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
                      cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
                      scriptinstall.append(env.Install(dir=dir,source=cubin_file))
 -    
 +
 +    if env['WITH_BF_OCIO']:
 +        colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
 +
 +        for dp, dn, df in os.walk(colormanagement):
 +            if '.svn' in dn:
 +                dn.remove('.svn')
 +            if '_svn' in dn:
 +                dn.remove('_svn')
 +
 +            dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
 +            dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
 +
 +            source = [os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
 +
 +            # To ensure empty dirs are created too
 +            if len(source) == 0:
 +                env.Execute(Mkdir(dir))
 +
 +            scriptinstall.append(env.Install(dir=dir,source=source))
 +
      if env['WITH_BF_INTERNATIONAL']:
          internationalpaths=['release' + os.sep + 'datafiles']
          
@@@ -762,9 -742,6 +762,9 @@@ if env['OURPLATFORM'] in ('win32-vc', '
      if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw':
          dllsources.append('${LCGDIR}/openimageio/bin/OpenImageIO.dll')
  
 +    if env['WITH_BF_OCIO'] and env['OURPLATFORM'] != 'win32-mingw':
 +        dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
 +
      dllsources.append('#source/icons/blender.exe.manifest')
  
      windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
@@@ -798,7 -775,7 +798,7 @@@ if env['OURPLATFORM'] == 'win64-mingw'
      dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
      dllsources.append('${LCGDIR}/binaries/libgcc_s_sjlj-1.dll')
      dllsources.append('${LCGDIR}/binaries/libwinpthread-1.dll')
-     dllsources.append('${LCGDIR}/binaries/libstdc++-6.dll)')
+     dllsources.append('${LCGDIR}/binaries/libstdc++-6.dll')
      dllsources.append('#source/icons/blender.exe.manifest')
  
      windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
index 8b0264da4fa9b41a0e9cbc5e6f5149220448075d,218d11f30359e75d974430988773dce874446fa5..625d2343dff49fd744c838b5200a734e8d8e0cdc
@@@ -52,7 -52,6 +52,7 @@@
  #include "BKE_library.h"
  #include "BKE_main.h"
  #include "BKE_node.h"
 +#include "BKE_tracking.h"
  
  #include "BLF_api.h"
  #include "BLF_translation.h"
@@@ -78,7 -77,6 +78,7 @@@
  #include "UI_interface.h"
  #include "UI_resources.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -2481,7 -2479,6 +2481,7 @@@ static void node_composit_buts_keying(u
        uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
 +      uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
  }
  
 +static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
 +{
 +      bNode *node= ptr->data;
 +
 +      uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
 +
 +      if (node->id) {
 +              MovieClip *clip = (MovieClip *) node->id;
 +              MovieTracking *tracking = &clip->tracking;
 +              MovieTrackingObject *object;
 +              uiLayout *col;
 +              PointerRNA tracking_ptr;
 +              NodeTrackPosData *data = node->storage;
 +
 +              RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
 +
 +              col = uiLayoutColumn(layout, 0);
 +              uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
 +
 +              object = BKE_tracking_object_get_named(tracking, data->tracking_object);
 +              if (object) {
 +                      PointerRNA object_ptr;
 +
 +                      RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
 +
 +                      uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
 +              }
 +              else {
 +                      uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
 +              }
 +
 +              uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
 +      }
 +}
 +
  /* only once called */
  static void node_composit_set_butfunc(bNodeType *ntype)
  {
                case CMP_NODE_KEYING:
                        ntype->uifunc = node_composit_buts_keying;
                        break;
 +              case CMP_NODE_TRACKPOS:
 +                      ntype->uifunc = node_composit_buts_trackpos;
 +                      break;
                default:
                        ntype->uifunc = NULL;
        }
@@@ -2956,7 -2915,7 +2956,7 @@@ void ED_init_node_butfuncs(void
  
  /* ************** Generic drawing ************** */
  
 -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
 +void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
  {
        
        if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
                void *lock;
                ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
                if (ibuf) {
 +                      SpaceNode *snode = CTX_wm_space_node(C);
 +                      wmWindow *win = CTX_wm_window(C);
 +                      const ColorManagedViewSettings *view_settings;
                        float x, y; 
 +                      unsigned char *display_buffer;
 +                      void *cache_handle;
                        
                        glMatrixMode(GL_PROJECTION);
                        glPushMatrix();
                        x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
                        y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
                        
 -                      if (!ibuf->rect) {
 -                              if (color_manage)
 -                                      ibuf->profile = IB_PROFILE_LINEAR_RGB;
 -                              else
 -                                      ibuf->profile = IB_PROFILE_NONE;
 -                              IMB_rect_from_float(ibuf);
 -                      }
  
 -                      if (ibuf->rect) {
 +                      view_settings = IMB_view_settings_get_effective(win, &snode->view_settings);
 +                      display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, &win->display_settings, &cache_handle);
 +
 +                      if (display_buffer) {
                                if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
                                        int ofs;
  
+ #ifdef __BIG_ENDIAN__
+                                       if      (snode->flag & SNODE_SHOW_R) ofs = 2;
+                                       else if (snode->flag & SNODE_SHOW_G) ofs = 1;
+                                       else                                 ofs = 0;
+ #else
                                        if      (snode->flag & SNODE_SHOW_R) ofs = 1;
                                        else if (snode->flag & SNODE_SHOW_G) ofs = 2;
                                        else                                 ofs = 3;
-                                       if (ENDIAN_ORDER == B_ENDIAN) {
-                                               ofs = 3 - ofs;
-                                       }
+ #endif
  
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
                                else if (snode->flag & SNODE_SHOW_ALPHA) {
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
-                                       if (ENDIAN_ORDER == B_ENDIAN)
-                                               glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
-                                       
+ #ifdef __BIG_ENDIAN__
+                                       glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
+ #endif
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
-                                       
+ #ifdef __BIG_ENDIAN__
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
+ #endif
                                        glPixelZoom(1.0f, 1.0f);
                                }
                                else if (snode->flag & SNODE_USE_ALPHA) {
                                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
                                        
                                        glPixelZoom(1.0f, 1.0f);
                                        glDisable(GL_BLEND);
                                else {
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
                                        
                                        glPixelZoom(1.0f, 1.0f);
                                }
                        }
  
 +                      IMB_display_buffer_release(cache_handle);
 +
                        /// @note draw selected info on backdrop
                        if (snode->edittree) {
                                bNode *node = snode->edittree->nodes.first;
index ff0e44922a57ddec182ab94374ddda410fc59ff9,d5bac7a8c26b284c1f1eb5ab79a10d9dc5344da9..51f4cec1540b84ab138c4ab2878069a47f69e3d8
@@@ -143,7 -143,6 +143,7 @@@ EnumPropertyItem viewport_shade_items[
  #include "ED_sequencer.h"
  #include "ED_clip.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf_types.h"
  
  static StructRNA *rna_Space_refine(struct PointerRNA *ptr)
@@@ -1878,7 -1877,7 +1878,7 @@@ static void rna_def_space_buttons(Blend
                {SB_TEXC_MAT_OR_LAMP, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
                {0, NULL, 0, NULL, NULL}
        };                             /*actually populated dynamically trough a function */
 -              
 +
        srna = RNA_def_struct(brna, "SpaceProperties", "Space");
        RNA_def_struct_sdna(srna, "SpaceButs");
        RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data");
@@@ -2027,11 -2026,6 +2027,11 @@@ static void rna_def_space_image(Blender
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Show UV Editor", "Show UV editing related properties");
  
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Sampled colors alongColor management settings used for displaying images on the display");
 +
        rna_def_space_image_uv(brna);
  }
  
@@@ -2858,9 -2852,10 +2858,10 @@@ static void rna_def_space_node(BlenderR
                {SNODE_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha",
                                  "Draw image with RGB colors and alpha transparency"},
                {SNODE_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"},
-               {SNODE_SHOW_R, "RED", 0, "Red", ""},
-               {SNODE_SHOW_G, "GREEN", 0, "Green", ""},
-               {SNODE_SHOW_B, "BLUE", 0, "Blue", ""},
+                                       /* XXX, we could use better icons here  */
+               {SNODE_SHOW_R, "RED",   ICON_COLOR, "Red", ""},
+               {SNODE_SHOW_G, "GREEN", ICON_COLOR, "Green", ""},
+               {SNODE_SHOW_B, "BLUE",  ICON_COLOR, "Blue", ""},
                {0, NULL, 0, NULL, NULL}
        };
  
        RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
  
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
 +
        prop = RNA_def_property(srna, "show_highlight", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_HIGHLIGHT);
        RNA_def_property_ui_text(prop, "Highlight", "Highlight nodes that are being calculated");
@@@ -3279,12 -3269,6 +3280,12 @@@ static void rna_def_space_clip(BlenderR
        RNA_def_property_enum_items(prop, pivot_items);
        RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 +
 +      /* color management view settings */
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
  }
  
  
index 52ac5b1325f39ad4109f2ea2c8b471e8cc0aa0bb,e3eab0c3b345a97f5b7ab5bfa02a3d7eae4e54c6..2b5ccae7df715415fb6be4d72a4d562acba6b112
@@@ -55,7 -55,6 +55,7 @@@
  #include "RE_engine.h"
  #include "RE_pipeline.h"
  
 +#include "initrender.h"
  #include "render_types.h"
  #include "render_result.h"
  
@@@ -150,7 -149,7 +150,7 @@@ void RE_engine_free(RenderEngine *engin
  
  /* Render Results */
  
 -RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h)
 +RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername)
  {
        Render *re = engine->re;
        RenderResult *result;
        disprect.ymin = y;
        disprect.ymax = y + h;
  
 -      result = render_result_new(re, &disprect, 0, RR_USE_MEM);
 +      result = render_result_new(re, &disprect, 0, RR_USE_MEM, layername);
 +
 +      /* todo: make this thread safe */
-       BLI_addtail(&engine->fullresult, result);
-       
-       result->tilerect.xmin += re->disprect.xmin;
-       result->tilerect.xmax += re->disprect.xmin;
-       result->tilerect.ymin += re->disprect.ymin;
-       result->tilerect.ymax += re->disprect.ymin;
+       /* can be NULL if we CLAMP the width or height to 0 */
+       if (result) {
+               BLI_addtail(&engine->fullresult, result);
+               result->tilerect.xmin += re->disprect.xmin;
+               result->tilerect.xmax += re->disprect.xmin;
+               result->tilerect.ymin += re->disprect.ymin;
+               result->tilerect.ymax += re->disprect.ymin;
+       }
  
        return result;
  }
@@@ -196,36 -197,21 +200,36 @@@ void RE_engine_update_result(RenderEngi
        }
  }
  
 -void RE_engine_end_result(RenderEngine *engine, RenderResult *result)
 +void RE_engine_end_result(RenderEngine *engine, RenderResult *result, int cancel)
  {
        Render *re = engine->re;
 +      RenderPart *pa;
  
        if (!result)
                return;
  
        /* merge. on break, don't merge in result for preview renders, looks nicer */
 -      if (!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS)))
 -              render_result_merge(re->result, result);
 +      if (!cancel) {
 +              /* for exr tile render, detect tiles that are done */
 +              for (pa = re->parts.first; pa; pa = pa->next) {
 +                      if (result->tilerect.xmin == pa->disprect.xmin &&
 +                         result->tilerect.ymin == pa->disprect.ymin &&
 +                         result->tilerect.xmax == pa->disprect.xmax &&
 +                         result->tilerect.ymax == pa->disprect.ymax) {
 +                              pa->ready = 1;
 +                      }
 +              }
  
 -      /* draw */
 -      if (!re->test_break(re->tbh)) {
 -              result->renlay = result->layers.first; // weak, draws first layer always
 -              re->display_draw(re->ddh, result, NULL);
 +              if (re->result->do_exr_tile)
 +                      render_result_exr_file_merge(re->result, result);
 +              else if (!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS)))
 +                      render_result_merge(re->result, result);
 +
 +              /* draw */
 +              if (!re->test_break(re->tbh)) {
 +                      result->renlay = result->layers.first; // weak, draws first layer always
 +                      re->display_draw(re->ddh, result, NULL);
 +              }
        }
  
        /* free */
@@@ -308,16 -294,12 +312,16 @@@ int RE_engine_render(Render *re, int do
        /* create render result */
        BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
        if (re->result == NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
 +              int savebuffers;
 +
                if (re->result)
                        render_result_free(re->result);
 -              re->result = render_result_new(re, &re->disprect, 0, 0);
 +
 +              savebuffers = (re->r.scemode & R_EXR_TILE_FILE) ? RR_USE_EXR : RR_USE_MEM;
 +              re->result = render_result_new(re, &re->disprect, 0, savebuffers, RR_ALL_LAYERS);
        }
        BLI_rw_mutex_unlock(&re->resultmutex);
 -      
 +
        if (re->result == NULL)
                return 1;
  
        if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_PREVIEWBUTS)) == 0)
                BKE_scene_update_for_newframe(re->main, re->scene, re->lay);
  
 +      initparts(re, FALSE);
 +      engine->tile_x = re->partx;
 +      engine->tile_y = re->party;
 +
 +      if (re->result->do_exr_tile)
 +              render_result_exr_file_begin(re);
 +
        if (type->update)
                type->update(engine, re->main, re->scene);
 +      
        if (type->render)
                type->render(engine, re->scene);
  
 +      if (re->result->do_exr_tile) {
 +              BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
 +              render_result_exr_file_end(re);
 +              BLI_rw_mutex_unlock(&re->resultmutex);
 +      }
 +
 +      engine->tile_x = 0;
 +      engine->tile_y = 0;
 +      freeparts(re);
 +
        render_result_free_list(&engine->fullresult, engine->fullresult.first);
  
        RE_engine_free(engine);