Commit: a84309e894c787ecfc36003f93167270cc1680ad
Author: Jeroen Bakker
Date:   Tue Jul 1 18:27:24 2014 +0200
https://developer.blender.org/rBa84309e894c787ecfc36003f93167270cc1680ad

Merge remote-tracking branch 'blender-upstream/master' into blender-tiles

Conflicts:
        source/blender/compositor/intern/COM_MemoryBuffer.cpp
        source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
        source/blender/compositor/operations/COM_KeyingClipOperation.cpp
        source/blender/compositor/operations/COM_RenderLayersProg.cpp

===================================================================



===================================================================

diff --cc source/blender/compositor/intern/COM_MemoryBuffer.cpp
index ff20d4c,c1916f4..a4ebfa2
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@@ -92,62 -46,33 +92,62 @@@ MemoryBuffer::MemoryBuffer(MemoryProxy 
        BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, 
rect->ymax);
        this->m_memoryProxy = memoryProxy;
        this->m_chunkNumber = chunkNumber;
-       this->m_buffer = (float *)MEM_mallocN(sizeof(float) * 
determineBufferSize() * no_channels, "COM_MemoryBuffer");
 -      this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * 
determineBufferSize() * COM_NUMBER_OF_CHANNELS, 16, "COM_MemoryBuffer");
++      this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * 
determineBufferSize() * no_channels, 16, "COM_MemoryBuffer");
        this->m_state = COM_MB_ALLOCATED;
 -      this->m_datatype = COM_DT_COLOR;
        this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin;
 +      this->m_no_channels = no_channels;
  }
  
 -MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
 +MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect, unsigned int 
no_channels)
  {
        BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, 
rect->ymax);
        this->m_memoryProxy = memoryProxy;
        this->m_chunkNumber = -1;
-       this->m_buffer = (float *)MEM_mallocN(sizeof(float) * 
determineBufferSize() * no_channels, "COM_MemoryBuffer");
 -      this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * 
determineBufferSize() * COM_NUMBER_OF_CHANNELS, 16, "COM_MemoryBuffer");
++      this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * 
determineBufferSize() * no_channels, 16, "COM_MemoryBuffer");
        this->m_state = COM_MB_TEMPORARILY;
 -      this->m_datatype = COM_DT_COLOR;
        this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin;
 +      this->m_no_channels = no_channels;
  }
 -MemoryBuffer *MemoryBuffer::duplicate()
 -{
 -      MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, 
&this->m_rect);
 -      memcpy(result->m_buffer, this->m_buffer, this->determineBufferSize() * 
COM_NUMBER_OF_CHANNELS * sizeof(float));
 -      return result;
 +
 +MemoryBuffer::MemoryBuffer(DataType datatype, rcti *rect, unsigned int 
no_channels) {
 +      BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, 
rect->ymax);
 +      this->m_memoryProxy = NULL;
 +      this->m_chunkNumber = -1;
-       this->m_buffer = (float *)MEM_mallocN(sizeof(float) * 
determineBufferSize() * no_channels, "COM_MemoryBuffer");
++      this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * 
determineBufferSize() * no_channels, 16, "COM_MemoryBuffer");
 +      this->m_state = COM_MB_TEMPORARILY;
 +      this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin;
 +      this->m_no_channels = no_channels;
  }
 +
  void MemoryBuffer::clear()
  {
 -      memset(this->m_buffer, 0, this->determineBufferSize() * 
COM_NUMBER_OF_CHANNELS * sizeof(float));
 +      memset(this->m_buffer, 0, this->determineBufferSize() * 
this->m_no_channels * sizeof(float));
 +}
 +
 +void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
 +{
 +      if (!otherBuffer) {
 +              BLI_assert(0);
 +              return;
 +      }
 +      unsigned int otherY;
 +      unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin);
 +      unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax);
 +      unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin);
 +      unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax);
 +      int offset;
 +      int otherOffset;
 +
 +
 +      for (otherY = minY; otherY < maxY; otherY++) {
 +              otherOffset = ((otherY - otherBuffer->m_rect.ymin) * 
otherBuffer->m_chunkWidth + minX - otherBuffer->m_rect.xmin) * 
this->m_no_channels;
 +              offset = ((otherY - this->m_rect.ymin) * this->m_chunkWidth + 
minX - this->m_rect.xmin) * this->m_no_channels;
 +              memcpy(&this->m_buffer[offset], 
&otherBuffer->m_buffer[otherOffset], (maxX - minX) * this->m_no_channels * 
sizeof(float));
 +      }
  }
  
 +
 +// TODO: this method needs to be checked! At Mind 2014
  float *MemoryBuffer::convertToValueBuffer()
  {
        const unsigned int size = this->determineBufferSize();
diff --cc source/blender/compositor/intern/COM_Tile.h
index b7e8f84,0000000..d66b911
mode 100644,000000..100644
--- a/source/blender/compositor/intern/COM_Tile.h
+++ b/source/blender/compositor/intern/COM_Tile.h
@@@ -1,127 -1,0 +1,137 @@@
 +/*
 + * Copyright 2011, Blender Foundation.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * Contributor: 
 + *            Jeroen Bakker 
 + *            Monique Dewanchand
 + */
 +
 +class Tile;
 +
 +#ifndef _COM_Tile_h_
 +#define _COM_Tile_h_
 +class ExecutionGroup;
 +#include "COM_ExecutionGroup.h"
 +class WorkScheduler;
 +#include <vector>
 +
 +typedef std::vector<Tile*> Tiles;
 +
 +typedef enum TileExecutionState{
 +      CREATED = 0,
 +      SCHEDULED = 1,
 +      FINISHED = 2
 +} TileExecutionState;
 +
 +/**
 + * @brief A tile is the work that can be scheduled.
 + *
 + * @see WorkScheduler
 + */
 +class Tile {
 +private:
 +      /**
 +       * @brief executionGroup with the operations-setup to be evaluated
 +       */
 +      ExecutionGroup *m_executionGroup;
 +
 +      /**
 +       * @brief rcti that this tile calculates from an ExecutionGroup
 +       */
 +      rcti *m_rect;
 +
 +      /**
 +       * @brief a list of tiles that needs to be calculated, before this tile 
can be scheduled
 +       */
 +      Tiles m_depends_on;
 +
 +      /**
 +       * @brief Number of unfinished tiles in the m_depends_on.
 +       */
 +      int m_no_unfinished_tiles;
 +
 +      /**
 +       * @brief a list of tiles that are waiting for me to be finished
 +       */
 +      Tiles m_dependents;
 +
 +      /**
 +       * @brief m_state execution state of this tile.
 +       */
 +      TileExecutionState m_state;
 +
++      /**
++       * @brief m_tile_number this is the tile number/chunk number of the old 
scheduling system.
++       * It is used during coding and will be removed when the new planning 
system will be activated.
++       *
++       * @deprecated
++       */
 +      unsigned int m_tile_number;
 +public:
 +      /**
 +       * constructor
 +       */
 +      Tile(ExecutionGroup *group, rcti *rect, unsigned int tile_number);
 +      ~Tile();
 +      /**
 +       * @brief get the ExecutionGroup
 +       */
 +      ExecutionGroup *getExecutionGroup() const { return 
this->m_executionGroup; }
 +
 +      /**
 +       * @brief schedule Schedule this tile for execution into the scheduler.
 +       */
 +      void schedule();
 +
 +      /**
 +       * @brief add_dependent adds a tile to the list of tiles that depends 
on this tile
 +       * @param tile
 +       */
 +      void add_dependent(Tile* tile);
 +
 +      /**
 +       * @brief add_depends_on adds a tile to the list of tiles that this 
tile depends on
 +       * @param tile
 +       */
 +      void add_depends_on(Tile* tile);
 +
 +      /**
 +       * @brief get_rect get the rectangle of this tile
 +       * @return reference to the rcti
 +       */
 +      rcti* get_rect() { return this->m_rect; }
 +
++      /**
++       * @brief get_tile_number
++       * @return return the chunk number of this tile
++       */
 +      unsigned int get_tile_number() { return this->m_tile_number; }
 +
 +private:
 +      /**
 +       * @brief execute function called from the workscheduler to execute 
this tile.
 +       */
 +      void execute();
 +
 +      friend class ExecutionGroup;
 +      friend class WorkScheduler;
 +#ifdef WITH_CXX_GUARDEDALLOC
 +      MEM_CXX_CLASS_ALLOC_FUNCS("COM:Tile")
 +#endif
 +};
 +
 +#endif
diff --cc source/blender/compositor/operations/COM_KeyingClipOperation.cpp
index 148b75a,d9eb7b5..0e62224
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
@@@ -62,28 -62,35 +62,35 @@@ void KeyingClipOperation::executePixel(
        int bufferWidth = inputBuffer->getWidth();
        int bufferHeight = inputBuffer->getHeight();
  
-       int i, j, count = 0, totalCount = 0;
- 
-     float value = buffer[(y * bufferWidth + x)];
 -      float value = buffer[(y * bufferWidth + x) * 4];
++      float value = buffer[(y * bufferWidth + x)];
  
        bool ok = false;
+       int start_x = max_ff(0, x - delta + 1),
+           start_y = max_ff(0, y - delta + 1),
+           end_x = min_ff(x + delta - 1, bufferWidth - 1),
+           end_y = min_ff(y + delta - 1, bufferHeight - 1);
+ 
+       int count = 0, totalCount = (end_x - start_x + 1) * (end_y - start_y + 
1) - 1;
+       int thresholdCount = ceil((float) totalCount * 0.9f);
  
-       for (i = -delta + 1; i < delta; i++) {
-               for (j = -delta + 1; j < delta; j++) {
-                       int cx = x + j, cy = y + i;
+       if (delta == 0) {
+               ok = true;
+       }
  
-                       if (i == 0 && j == 0)
+       for (int cx = start_x; ok == false && cx <= end_x; ++cx) {
+               for (int cy = start_y; ok == false && cy <= end_y; ++cy) {
+                       if (UNLIKELY(cx == x && cy == y)) {
                                continue;
+                       }
  
-                       if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < 
bufferHeight) {
-                 int bufferIndex = (cy * bufferWidth + cx);
-                               float currentValue = buffer[bufferIndex];
 -                      int bufferIndex = (cy * bufferWidth + cx) * 4;
++                      int bufferIndex = (cy * bufferWidth + cx);
+                       float currentValue = buffer[bufferIndex];
  
-                               if (fabsf(currentValue - value) < tolerance) {
-                                       count++;
+                       if (fabsf(currentValue - value) < tolerance) {
+                               count++;
+                               if (count >= thresholdCount) {
+                                       ok = true;
                                }
- 
-                               totalCount++;
                        }
                }
        }
diff --cc source/blender/compositor/operations/COM_RenderLayersProg.cpp
index 0eec027,7141dd7..a037997
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@@ -135,21 -145,10 +135,18 @@@ void RenderLayersBaseProg::executePixel
  #endif
  
        if (this->m_inputBuffer == NULL) {
 -              zero_v4(output);
 +              int elemsize = this->m_elementsize;
 +              if (elemsize == 1) {
 +      

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to