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:
authorCampbell Barton <ideasman42@gmail.com>2014-04-16 17:25:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-16 17:25:10 +0400
commitd1b1d194dc9cc741d87dc63e701402de0776c694 (patch)
tree344bde4783c61c65412fa1fd2435e705ead26965 /source/blender/editors/mask/mask_draw.c
parentb3972aeea05bc6c60d7b7da4e6b59a64b822448a (diff)
Fix for half pixel offset rasterizing masks
Diffstat (limited to 'source/blender/editors/mask/mask_draw.c')
-rw-r--r--source/blender/editors/mask/mask_draw.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index e84bdf12067..08896b39682 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -643,15 +643,21 @@ static void mask_rasterize_func(TaskPool *pool, void *taskdata, int UNUSED(threa
ThreadedMaskRasterizeState *state = (ThreadedMaskRasterizeState *) BLI_task_pool_userdata(pool);
ThreadedMaskRasterizeData *data = (ThreadedMaskRasterizeData *) taskdata;
int scanline;
+ const float x_inv = 1.0f / (float)state->width;
+ const float y_inv = 1.0f / (float)state->height;
+ const float x_px_ofs = x_inv * 0.5f;
+ const float y_px_ofs = y_inv * 0.5f;
for (scanline = 0; scanline < data->num_scanlines; scanline++) {
+ float xy[2];
int x, y = data->start_scanline + scanline;
+
+ xy[1] = ((float)y * y_inv) + y_px_ofs;
+
for (x = 0; x < state->width; x++) {
int index = y * state->width + x;
- float xy[2];
- xy[0] = (float) x / state->width;
- xy[1] = (float) y / state->height;
+ xy[0] = ((float)x * x_inv) + x_px_ofs;
state->buffer[index] = BKE_maskrasterize_handle_sample(state->handle, xy);
}