Removing OMP: BKE's mask_rasterize.c
Once again nothing much to say here, except that whole mask rendering process from VSE is about 25% quicker now. ;)
This commit is contained in:
parent
440a49a24c
commit
06e64058dd
|
@ -80,6 +80,7 @@
|
|||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_task.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_linklist.h"
|
||||
|
||||
|
@ -1423,6 +1424,37 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
typedef struct MaskRasterizeBufferData {
|
||||
MaskRasterHandle *mr_handle;
|
||||
float x_inv, y_inv;
|
||||
float x_px_ofs, y_px_ofs;
|
||||
uint width;
|
||||
|
||||
float *buffer;
|
||||
} MaskRasterizeBufferData;
|
||||
|
||||
static void maskrasterize_buffer_cb(void *userdata, int y)
|
||||
{
|
||||
MaskRasterizeBufferData *data = userdata;
|
||||
|
||||
MaskRasterHandle *mr_handle = data->mr_handle;
|
||||
float *buffer = data->buffer;
|
||||
|
||||
const uint width = data->width;
|
||||
const float x_inv = data->x_inv;
|
||||
const float x_px_ofs = data->x_px_ofs;
|
||||
|
||||
uint i = (uint)y * width;
|
||||
float xy[2];
|
||||
xy[1] = ((float)y * data->y_inv) + data->y_px_ofs;
|
||||
for (uint x = 0; x < width; x++, i++) {
|
||||
xy[0] = ((float)x * x_inv) + x_px_ofs;
|
||||
|
||||
buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Rasterize a buffer from a single mask
|
||||
*
|
||||
|
@ -1439,33 +1471,15 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
|
|||
{
|
||||
const float x_inv = 1.0f / (float)width;
|
||||
const float y_inv = 1.0f / (float)height;
|
||||
const float x_px_ofs = x_inv * 0.5f;
|
||||
const float y_px_ofs = y_inv * 0.5f;
|
||||
#ifdef _MSC_VER
|
||||
int y; /* msvc requires signed for some reason */
|
||||
|
||||
/* ignore sign mismatch */
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4018)
|
||||
#else
|
||||
unsigned int y;
|
||||
#endif
|
||||
|
||||
#pragma omp parallel for private(y)
|
||||
for (y = 0; y < height; y++) {
|
||||
unsigned int i = y * width;
|
||||
unsigned int x;
|
||||
float xy[2];
|
||||
xy[1] = ((float)y * y_inv) + y_px_ofs;
|
||||
for (x = 0; x < width; x++, i++) {
|
||||
xy[0] = ((float)x * x_inv) + x_px_ofs;
|
||||
|
||||
buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
MaskRasterizeBufferData data = {
|
||||
.mr_handle = mr_handle,
|
||||
.x_inv = x_inv,
|
||||
.y_inv = y_inv,
|
||||
.x_px_ofs = x_inv * 0.5f,
|
||||
.y_px_ofs = y_inv * 0.5f,
|
||||
.width = width,
|
||||
.buffer = buffer
|
||||
};
|
||||
BLI_task_parallel_range(0, (int)height, &data, maskrasterize_buffer_cb, height * width > 10000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue