Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Sun, 26 Nov 2017 19:29:56 +0000 (20:29 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Sun, 26 Nov 2017 19:29:56 +0000 (20:29 +0100)
Conflicts:
source/blender/editors/mask/mask_draw.c

1  2 
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/mask/mask_draw.c

index 6ed1c021c6c0928f493c168b35aeb78a71f9a445,407c19a3860b6d18fb17136127d6009dbc6a3bb0..c60b673ec692dd43a7018268cfabb6af69f4d297
@@@ -606,57 -652,16 +606,14 @@@ void ED_mask_draw(const bContext *C
                return;
  
        ED_mask_get_size(sa, &width, &height);
 -      ED_mask_get_aspect(sa, ar, &aspx, &aspy);
 -      UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
  
 -      draw_masklays(C, mask, draw_flag, draw_type, width, height, xscale * aspx, yscale * aspy);
 +      draw_masklays(C, mask, draw_flag, draw_type, width, height);
  }
  
- typedef struct ThreadedMaskRasterizeState {
-       MaskRasterHandle *handle;
-       float *buffer;
-       int width, height;
- } ThreadedMaskRasterizeState;
- typedef struct ThreadedMaskRasterizeData {
-       int start_scanline;
-       int num_scanlines;
- } ThreadedMaskRasterizeData;
- static void mask_rasterize_func(TaskPool * __restrict pool, void *taskdata, int UNUSED(threadid))
+ static float *mask_rasterize(Mask *mask, const int width, const int height)
  {
-       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;
-                       xy[0] = ((float)x * x_inv) + x_px_ofs;
-                       state->buffer[index] = BKE_maskrasterize_handle_sample(state->handle, xy);
-               }
-       }
- }
- static float *threaded_mask_rasterize(Mask *mask, const int width, const int height)
- {
-       TaskScheduler *task_scheduler = BLI_task_scheduler_get();
-       TaskPool *task_pool;
        MaskRasterHandle *handle;
-       ThreadedMaskRasterizeState state;
-       float *buffer;
-       int i, num_threads = BLI_task_scheduler_num_threads(task_scheduler), scanlines_per_thread;
-       buffer = MEM_mallocN(sizeof(float) * height * width, "rasterized mask buffer");
+       float *buffer = MEM_mallocN(sizeof(float) * height * width, "rasterized mask buffer");
  
        /* Initialize rasterization handle. */
        handle = BKE_maskrasterize_handle_new();
@@@ -754,26 -733,28 +685,26 @@@ void ED_mask_draw_region(Mask *mask, AR
        }
  
        if (draw_flag & MASK_DRAWFLAG_OVERLAY) {
-               float *buffer = threaded_mask_rasterize(mask, width, height);
 +              float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
 -              int format;
+               float *buffer = mask_rasterize(mask, width, height);
  
 -              if (overlay_mode == MASK_OVERLAY_ALPHACHANNEL) {
 -                      glColor3f(1.0f, 1.0f, 1.0f);
 -                      format = GL_LUMINANCE;
 -              }
 -              else {
 +              if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
                        /* More blending types could be supported in the future. */
                        glEnable(GL_BLEND);
 -                      glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
 -                      format = GL_ALPHA;
 +                      glBlendFunc(GL_DST_COLOR, GL_ZERO);
                }
  
 -              glPushMatrix();
 -              glTranslatef(x, y, 0);
 -              glScalef(zoomx, zoomy, 0);
 +              gpuPushMatrix();
 +              gpuTranslate2f(x, y);
 +              gpuScale2f(zoomx, zoomy);
                if (stabmat) {
 -                      glMultMatrixf(stabmat);
 +                      gpuMultMatrix(stabmat);
                }
 -              glaDrawPixelsTex(0.0f, 0.0f, width, height, format, GL_FLOAT, GL_NEAREST, buffer);
 -              glPopMatrix();
 +              IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
 +              GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
 +              immDrawPixelsTex(&state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL);
 +
 +              gpuPopMatrix();
  
                if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
                        glDisable(GL_BLEND);