-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessor.cpp
28 lines (22 loc) · 864 Bytes
/
Processor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "Processor.h"
// callback for ThreadSuite's multithreading function
void Processor::multiThreadProcessing(unsigned int threadId, unsigned int nThreads, void *arg)
{
Processor *proc = (Processor *)arg;
// slice the y range into the number of threads it has
unsigned int dy = proc->window.y2 - proc->window.y1;
unsigned int y1 = proc->window.y1 + threadId * dy / nThreads;
unsigned int y2 = proc->window.y1 + Minimum((threadId + 1) * dy / nThreads, dy);
OfxRectI win = proc->window;
win.y1 = y1; win.y2 = y2;
// and render that thread on each
proc->doProcessing(win);
}
// function to kick off rendering across multiple CPUs
void
Processor::process(OfxMultiThreadSuiteV1 *pThreadSuite)
{
unsigned int nThreads = 1;
// pThreadSuite->multiThreadNumCPUs(&nThreads);
pThreadSuite->multiThread(multiThreadProcessing, nThreads, (void *) this);
}