Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-03-07 21:47:30 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-03-07 21:47:30 +0400
commit557b893dfd0fa2380ee159bb4fe7a28f09187036 (patch)
tree4ea73cdeefc2e0c1d1f54b42660c32d5abb21e91 /source/blender/compositor
parenta134d9ed517ef4173c1e8c19e77d652d52fe9258 (diff)
Border for compositor viewer node feature
This adds border option to compositor, which affects on a backdrop and viewer nodes, which is useful for faster previews and tweaks. Final compositing still happens for the whole frame, but if it'll be needed it's not so difficult to support it as well. To use border there's Ctrl-B shortcut in the compositor editor, which i used to define region you want to restrict compositing to. There's also "Viewer Border" option in the N-panel in case you'll want to disable border compositing. Some areas could be cleaned a bit, like ideally it shall not be viewer image clearing in viewer_border_update RNA callback, but currently it's not so much clear how to make it the same fast as simple memset and glue it somehow to compositor. Will think of nicer solution a bit later.
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp56
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h12
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp11
3 files changed, 62 insertions, 17 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index ffc36281874..0868fccceaa 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -60,6 +60,7 @@ ExecutionGroup::ExecutionGroup()
this->m_openCL = false;
this->m_singleThreaded = false;
this->m_chunksFinished = 0;
+ BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
}
CompositorPriority ExecutionGroup::getRenderPriotrity()
@@ -196,6 +197,7 @@ void ExecutionGroup::determineResolution(unsigned int resolution[2])
resolution[0] = operation->getWidth();
resolution[1] = operation->getHeight();
this->setResolution(resolution);
+ BLI_rcti_init(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height);
}
void ExecutionGroup::determineNumberOfChunks()
@@ -207,8 +209,10 @@ void ExecutionGroup::determineNumberOfChunks()
}
else {
const float chunkSizef = this->m_chunkSize;
- this->m_numberOfXChunks = ceil(this->m_width / chunkSizef);
- this->m_numberOfYChunks = ceil(this->m_height / chunkSizef);
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+ this->m_numberOfXChunks = ceil(border_width / chunkSizef);
+ this->m_numberOfYChunks = ceil(border_height / chunkSizef);
this->m_numberOfChunks = this->m_numberOfXChunks * this->m_numberOfYChunks;
}
}
@@ -245,6 +249,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
chunkorder = viewer->getChunkOrder();
}
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+
switch (chunkorder) {
case COM_TO_RANDOM:
for (index = 0; index < 2 * this->m_numberOfChunks; index++) {
@@ -258,14 +265,14 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
case COM_TO_CENTER_OUT:
{
ChunkOrderHotspot *hotspots[1];
- hotspots[0] = new ChunkOrderHotspot(this->m_width * centerX, this->m_height * centerY, 0.0f);
+ hotspots[0] = new ChunkOrderHotspot(border_width * centerX, border_height * centerY, 0.0f);
rcti rect;
ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
for (index = 0; index < this->m_numberOfChunks; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin);
- chunkOrders[index].setY(rect.ymin);
+ chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
+ chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
chunkOrders[index].determineDistance(hotspots, 1);
}
@@ -281,10 +288,10 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
case COM_TO_RULE_OF_THIRDS:
{
ChunkOrderHotspot *hotspots[9];
- unsigned int tx = this->m_width / 6;
- unsigned int ty = this->m_height / 6;
- unsigned int mx = this->m_width / 2;
- unsigned int my = this->m_height / 2;
+ unsigned int tx = border_width / 6;
+ unsigned int ty = border_height / 6;
+ unsigned int mx = border_width / 2;
+ unsigned int my = border_height / 2;
unsigned int bx = mx + 2 * tx;
unsigned int by = my + 2 * ty;
@@ -303,8 +310,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
for (index = 0; index < this->m_numberOfChunks; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin);
- chunkOrders[index].setY(rect.ymin);
+ chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
+ chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
chunkOrders[index].determineDistance(hotspots, 9);
}
@@ -431,13 +438,18 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo
inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const
{
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+
if (this->m_singleThreaded) {
- BLI_rcti_init(rect, 0, this->m_width, 0, this->m_height);
+ BLI_rcti_init(rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
}
else {
- const unsigned int minx = xChunk * this->m_chunkSize;
- const unsigned int miny = yChunk * this->m_chunkSize;
- BLI_rcti_init(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height));
+ const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
+ const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
+ const unsigned int width = min((unsigned int) this->m_viewerBorder.xmax, this->m_width);
+ const unsigned int height = min((unsigned int) this->m_viewerBorder.ymax, this->m_height);
+ BLI_rcti_init(rect, min(minx, this->m_width), min(minx + this->m_chunkSize, width), min(miny, this->m_height), min(miny + this->m_chunkSize, height));
}
}
@@ -472,9 +484,9 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
float chunkSizef = this->m_chunkSize;
int indexx, indexy;
- int minxchunk = floor(area->xmin / chunkSizef);
+ int minxchunk = floor((area->xmin - this->m_viewerBorder.xmin) / chunkSizef);
int maxxchunk = ceil((area->xmax - 1) / chunkSizef);
- int minychunk = floor(area->ymin / chunkSizef);
+ int minychunk = floor((area->ymin - this->m_viewerBorder.ymin) / chunkSizef);
int maxychunk = ceil((area->ymax - 1) / chunkSizef);
minxchunk = max(minxchunk, 0);
minychunk = max(minychunk, 0);
@@ -574,3 +586,13 @@ bool ExecutionGroup::isOpenCL()
{
return this->m_openCL;
}
+
+void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax)
+{
+ NodeOperation *operation = this->getOutputNodeOperation();
+
+ if (operation->isViewerOperation()) {
+ BLI_rcti_init(&this->m_viewerBorder, xmin * this->m_width, xmax * this->m_width,
+ ymin * this->m_height, ymax * this->m_height);
+ }
+}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 00104c24194..52f5bae4be9 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -161,6 +161,12 @@ private:
* @see openCL
*/
bool m_initialized;
+
+ /**
+ * @brief denotes boundary for border compositing
+ * @note measured in pixel space
+ */
+ rcti m_viewerBorder;
// methods
/**
@@ -395,6 +401,12 @@ public:
*/
CompositorPriority getRenderPriotrity();
+ /**
+ * @brief set border for viewer operation
+ * @note all the coordinates are assumed to be in normalized space
+ */
+ void setViewerBorder(float xmin, float xmax, float ymin, float ymax);
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 1ec4ac7699b..2b2af73d0c8 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -78,11 +78,22 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool re
this->groupOperations(); /* group operations in ExecutionGroups */
unsigned int index;
unsigned int resolution[2];
+
+ rctf *viewer_border = &editingtree->viewer_border;
+ bool use_viewer_border = (editingtree->flag & NTREE_VIEWER_BORDER) &&
+ viewer_border->xmin < viewer_border->xmax &&
+ viewer_border->ymin < viewer_border->ymax;
+
for (index = 0; index < this->m_groups.size(); index++) {
resolution[0] = 0;
resolution[1] = 0;
ExecutionGroup *executionGroup = this->m_groups[index];
executionGroup->determineResolution(resolution);
+
+ if (use_viewer_border) {
+ executionGroup->setViewerBorder(viewer_border->xmin, viewer_border->xmax,
+ viewer_border->ymin, viewer_border->ymax);
+ }
}
#ifdef COM_DEBUG