Merging r49840 through r49854 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 18:39:05 +0000 (18:39 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 18:39:05 +0000 (18:39 +0000)
1  2 
source/blender/blenkernel/SConscript
source/blender/compositor/operations/COM_InpaintOperation.cpp

index 555d95acf881de2b8a468f7a75412def02a11ea0,68ca3170bd89e64f27c8a89067efe76c0a4932cb..d1a35b122e8daf552f6e543c1d835504969d9053
@@@ -3,10 -3,6 +3,10 @@@ Import ('env'
  import os
  
  sources = env.Glob('intern/*.c')
 +sources.remove('intern' + os.sep + 'mask_rasterize.c')
 +sources.remove('intern' + os.sep + 'mask.c')
 +
 +sources_mask = env.Glob('intern/mask*.c')
  
  incs = '. #/intern/guardedalloc #/intern/memutil'
  incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager'
@@@ -41,7 -37,8 +41,8 @@@ if env['WITH_BF_PYTHON']
          defs.append('DEBUG')
  
  if env['WITH_BF_ELTOPO']:
-     incs += ' ../../../extern/eltopo'
+     incs += ' #/extern/eltopo'
+     incs += ' #/extern/eltopo/eltopo3d'
      defs.append('WITH_ELTOPO')
          
  if env['WITH_BF_QUICKTIME']:
@@@ -121,10 -118,7 +122,10 @@@ if env['WITH_BF_INTERNATIONAL']
  if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
      incs += ' ' + env['BF_PTHREADS_INC']
  
 +
  if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
      env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') )
  else:
      env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] )
 +
 +env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] )
index eb732cc2b80f5f6b5b82d4743c0e25a57940c757,77bef54c4857857e595d7d36abe72ba4c4828689..b0e9c601e077ddd6c3ea29bfa79d3ccc65d4df5f
@@@ -57,7 -57,7 +57,7 @@@ void InpaintSimpleOperation::initExecut
        this->initMutex();
  }
  
- void InpaintSimpleOperation::clamp_xy(int & x, int & y) 
+ void InpaintSimpleOperation::clamp_xy(int &x, int &y)
  {
        int width = this->getWidth();
        int height = this->getHeight();
@@@ -97,7 -97,7 +97,7 @@@ int InpaintSimpleOperation::mdist(int x
        return this->m_manhatten_distance[y * width + x];
  }
  
- bool InpaintSimpleOperation::next_pixel(int & x, int & y, int & curr, int iters)
+ bool InpaintSimpleOperation::next_pixel(int &x, int &y, int & curr, int iters)
  {
        int width = this->getWidth();
  
        x = r % width;
        y = r / width;
  
-       if (mdist(x, y) > iters) {
+       if (this->mdist(x, y) > iters) {
                return false;
        }
        
@@@ -142,7 -142,7 +142,7 @@@ void InpaintSimpleOperation::calc_manha
        }
        
        for (int j = height - 1; j >= 0; j--) {
 -              for (int i = width; i >= 0; i--) {
 +              for (int i = width - 1; i >= 0; i--) {
                        int r = m[j * width + i];
                        
                        if (i + 1 < width) 
  
  void InpaintSimpleOperation::pix_step(int x, int y)
  {
-       int d = this->mdist(x, y);
-       float n = 0;
+       const int d = this->mdist(x, y);
        float pix[3] = {0.0f, 0.0f, 0.0f};
+       float pix_divider = 0.0f;
  
        for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
 -                      if (dx != 0 && dy != 0) {
 -
 +                      if (dx != 0 || dy != 0) {
                                int x_ofs = x + dx;
                                int y_ofs = y + dy;
  
                                        }
  
                                        madd_v3_v3fl(pix, this->get_pixel(x_ofs, y_ofs), weight);
-                                       n += weight;
+                                       pix_divider += weight;
                                }
                        }
                }
        }
  
-       mul_v3_v3fl(this->get_pixel(x, y), pix, 1.0f / n);
+       float *output = this->get_pixel(x, y);
+       if (pix_divider != 0.0f) {
+               mul_v3_fl(pix, 1.0f / pix_divider);
+               /* use existing pixels alpha to blend into */
+               interp_v3_v3v3(output, pix, output, output[3]);
+               output[3] = 1.0f;
+       }
 +
 +      this->get_pixel(x, y)[3] = 1.0f;
  }
  
  void *InpaintSimpleOperation::initializeTileData(rcti *rect)
                this->m_cached_buffer = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
                memcpy(this->m_cached_buffer, buf->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
  
-               calc_manhatten_distance();
+               this->calc_manhatten_distance();
  
                int curr = 0;
                int x, y;
  
        
-               while (next_pixel(x, y, curr, this->m_iterations)) {
-                       pix_step(x, y);
+               while (this->next_pixel(x, y, curr, this->m_iterations)) {
+                       this->pix_step(x, y);
                }
                this->m_cached_buffer_ready = true;
        }