diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-06 12:48:07 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-06 12:49:09 +0300 |
commit | ef0c02cb4dbd5f74fd0cb7c7ef119e4ca1936249 (patch) | |
tree | 1000d42908297b93b1f767209438bc88ef3f5f18 /source/blender/imbuf/intern/rectop.c | |
parent | 204f55c189d7e7a7b7808b6730a285326e7ac38a (diff) |
Speedup of regular 2D painting
Yet another commit which makes painting aware of multi-threaded systems.
Diffstat (limited to 'source/blender/imbuf/intern/rectop.c')
-rw-r--r-- | source/blender/imbuf/intern/rectop.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index c7b347cb20c..3360fd7548e 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -693,6 +693,69 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask, } } +typedef struct RectBlendThreadData { + ImBuf *dbuf, *obuf, *sbuf; + unsigned short *dmask, *curvemask, *texmask; + float mask_max; + int destx, desty, origx, origy; + int srcx, srcy, width; + IMB_BlendMode mode; + bool accumulate; +} RectBlendThreadData; + +static void rectblend_thread_do(void *data_v, + int start_scanline, + int num_scanlines) +{ + RectBlendThreadData *data = (RectBlendThreadData *)data_v; + IMB_rectblend(data->dbuf, data->obuf, data->sbuf, + data->dmask, data->curvemask, data->texmask, + data->mask_max, + data->destx, + data->desty + start_scanline, + data->origx, + data->origy + start_scanline, + data->srcx, + data->srcy + start_scanline, + data->width, num_scanlines, + data->mode, data->accumulate); +} + +void IMB_rectblend_threaded(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, + unsigned short *dmask, unsigned short *curvemask, + unsigned short *texmask, float mask_max, + int destx, int desty, int origx, int origy, + int srcx, int srcy, int width, int height, + IMB_BlendMode mode, bool accumulate) +{ + if (((size_t)width) * height < 64 * 64) { + IMB_rectblend(dbuf, obuf, sbuf, dmask, curvemask, texmask, + mask_max, destx, desty, origx, origy, + srcx, srcy, width, height, mode, accumulate); + } + else { + RectBlendThreadData data; + data.dbuf = dbuf; + data.obuf = obuf; + data.sbuf = sbuf; + data.dmask = dmask; + data.curvemask = curvemask; + data.texmask = texmask; + data.mask_max = mask_max; + data.destx = destx; + data.desty = desty; + data.origx = origx; + data.origy = origy; + data.srcx = srcx; + data.srcy = srcy; + data.width = width; + data.mode = mode; + data.accumulate = accumulate; + IMB_processor_apply_threaded_scanlines( + height, rectblend_thread_do, &data); + } +} + /* fill */ void IMB_rectfill(ImBuf *drect, const float col[4]) |