diff options
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 65 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 18 |
4 files changed, 23 insertions, 69 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 91d1985cd00..fccce0357a4 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1446,7 +1446,6 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) } if (sl) { - /* swap regions */ slold->regionbase = sa->regionbase; sa->regionbase = sl->regionbase; diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 13befeceee9..d356c3d8de3 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -531,7 +531,7 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, components = 4; else if (format == GL_RGB) components = 3; - else if (format == GL_LUMINANCE) + else if (ELEM(format, GL_LUMINANCE, GL_ALPHA)) components = 1; else { BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled"); @@ -1091,18 +1091,15 @@ void glaDrawImBuf_glsl(ImBuf *ibuf, float x, float y, int zoomfilter, if (ibuf->rect_float) { if (ibuf->float_colorspace) { ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, - ibuf->float_colorspace, - true, false); + ibuf->float_colorspace, true); } else { - ok = IMB_colormanagement_setup_glsl_draw(view_settings, display_settings, - true, false); + ok = IMB_colormanagement_setup_glsl_draw(view_settings, display_settings, true); } } else { ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, - ibuf->rect_colorspace, - false, false); + ibuf->rect_colorspace, false); } if (ok) { @@ -1160,57 +1157,3 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int glaDrawImBuf_glsl(ibuf, x, y, zoomfilter, view_settings, display_settings); } - -/* Transform buffer from role to scene linear space using GLSL OCIO conversion - * - * See IMB_colormanagement_setup_transform_from_role_glsl description for - * some more details - * - * NOTE: this only works for RGBA buffers! - */ -int glaBufferTransformFromRole_glsl(float *buffer, int width, int height, int role) -{ - GPUOffScreen *ofs; - char err_out[256]; - rcti display_rect; - - ofs = GPU_offscreen_create(width, height, err_out); - - if (!ofs) - return FALSE; - - GPU_offscreen_bind(ofs); - - if (!IMB_colormanagement_setup_transform_from_role_glsl(role, true)) { - GPU_offscreen_unbind(ofs); - GPU_offscreen_free(ofs); - return FALSE; - } - - BLI_rcti_init(&display_rect, 0, width, 0, height); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - glaDefine2DArea(&display_rect); - - glaDrawPixelsTex(0, 0, width, height, GL_RGBA, GL_FLOAT, - GL_NEAREST, buffer); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - GPU_offscreen_read_pixels(ofs, GL_FLOAT, buffer); - - IMB_colormanagement_finish_glsl_transform(); - - /* unbind */ - GPU_offscreen_unbind(ofs); - GPU_offscreen_free(ofs); - - return TRUE; -} diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 10c2ecd6fd9..356db174c2f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1009,8 +1009,6 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) win->screen->do_draw = TRUE; break; case NC_SCREEN: - if (note->data == ND_SUBWINACTIVE) - uiFreeActiveButtons(C, win->screen); if (note->action == NA_EDITED) win->screen->do_draw = win->screen->do_refresh = TRUE; break; @@ -1335,7 +1333,11 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) /* notifier invokes freeing the buttons... causing a bit too much redraws */ if (oldswin != scr->subwinactive) { region_cursor_set(win, scr->subwinactive, TRUE); - WM_event_add_notifier(C, NC_SCREEN | ND_SUBWINACTIVE, scr); + + /* this used to be a notifier, but needs to be done immediate + * because it can undo setting the right button as active due + * to delayed notifier handling */ + uiFreeActiveButtons(C, win->screen); } else region_cursor_set(win, scr->subwinactive, FALSE); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 584d4cef133..dbe1197436b 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -77,6 +77,18 @@ typedef struct ScreenshotData { ImageFormatData im_format; } ScreenshotData; +static void screenshot_read_pixels(int x, int y, int w, int h, unsigned char *rect) +{ + int i; + + glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glFinish(); + + /* clear alpha, it is not set to a meaningful value in opengl */ + for (i = 0, rect += 3; i < w * h; i++, rect += 4) + *rect = 255; +} + /* get shot from frontbuffer */ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) { @@ -93,8 +105,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); - glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); - glFinish(); + screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char*)dumprect); glReadBuffer(GL_BACK); } @@ -316,8 +327,7 @@ static void screenshot_updatejob(void *sjv) if (sj->dumprect == NULL) { dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); - glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); - glFinish(); + screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char *)dumprect); sj->dumprect = dumprect; } |