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>2016-06-08 22:02:52 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-06-08 22:17:43 +0300
commitd01499a45c104c1286451e6623446eab1b21fc0c (patch)
tree09f076dd855463bfd060c2274547d6644df51e64 /source/blender/windowmanager/intern/wm_gesture.c
parent69bf7a44aac3e9a66b69fa1a93f7a5a04f360e5c (diff)
GPU: avoid disabling basic-shader for lasso
Replace glDrawPixels w/ glaDrawPixelsTex
Diffstat (limited to 'source/blender/windowmanager/intern/wm_gesture.c')
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index db933ad2d76..1357729e898 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -233,19 +233,15 @@ static void wm_gesture_draw_circle(wmGesture *gt)
}
struct LassoFillData {
- unsigned int *px;
+ unsigned char *px;
int width;
};
static void draw_filled_lasso_px_cb(int x, int x_end, int y, void *user_data)
{
struct LassoFillData *data = user_data;
- unsigned char *col = (unsigned char *)&(data->px[(y * data->width) + x]);
- do {
- col[0] = col[1] = col[2] = 0xff;
- col[3] = 0x10;
- col += 4;
- } while (++x != x_end);
+ unsigned char *col = &(data->px[(y * data->width) + x]);
+ memset(col, 0x10, x_end - x);
}
static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
@@ -273,7 +269,7 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
if (BLI_rcti_is_empty(&rect) == false) {
const int w = BLI_rcti_size_x(&rect);
const int h = BLI_rcti_size_y(&rect);
- unsigned int *pixel_buf = MEM_callocN(sizeof(*pixel_buf) * w * h, __func__);
+ unsigned char *pixel_buf = MEM_callocN(sizeof(*pixel_buf) * w * h, __func__);
struct LassoFillData lasso_fill_data = {pixel_buf, w};
fill_poly_v2i_n(
@@ -281,19 +277,27 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
(const int (*)[2])moves, tot,
draw_filled_lasso_px_cb, &lasso_fill_data);
- int bound_options;
- GPU_BASIC_SHADER_DISABLE_AND_STORE(bound_options);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glColor4f(1, 1, 1, 1);
+ glPixelTransferf(GL_RED_BIAS, 1);
+ glPixelTransferf(GL_GREEN_BIAS, 1);
+ glPixelTransferf(GL_BLUE_BIAS, 1);
+
+ GPU_basic_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
glEnable(GL_BLEND);
- // glColor4f(1.0, 1.0, 1.0, 0.05);
+ glaDrawPixelsTex(rect.xmin, rect.ymin, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf);
+ glDisable(GL_BLEND);
- glRasterPos2f(rect.xmin, rect.ymin);
+ GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
- glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixel_buf);
+ glPixelTransferf(GL_RED_BIAS, 0);
+ glPixelTransferf(GL_GREEN_BIAS, 0);
+ glPixelTransferf(GL_BLUE_BIAS, 0);
- GPU_BASIC_SHADER_ENABLE_AND_RESTORE(bound_options);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glDisable(GL_BLEND);
MEM_freeN(pixel_buf);
}