border render with cycles had 1 pixel offset on the top-right edge of the image, issue was caused by wmSubWindowScissorSet adding 1 to the ar->drawrct, now only add the padding when drawing the entire area

This commit is contained in:
Campbell Barton 2013-08-05 04:52:27 +00:00
parent 37ff3a0e8a
commit 0395b8eee8
4 changed files with 22 additions and 10 deletions

@ -387,7 +387,7 @@ void ED_region_set(const bContext *C, ARegion *ar)
ar->drawrct = ar->winrct; ar->drawrct = ar->winrct;
/* note; this sets state, so we can use wmOrtho and friends */ /* note; this sets state, so we can use wmOrtho and friends */
wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, true);
UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
@ -401,21 +401,25 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
wmWindow *win = CTX_wm_window(C); wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegionType *at = ar->type; ARegionType *at = ar->type;
bool scissor_pad;
/* see BKE_spacedata_draw_locks() */ /* see BKE_spacedata_draw_locks() */
if (at->do_lock) if (at->do_lock)
return; return;
/* if no partial draw rect set, full rect */ /* if no partial draw rect set, full rect */
if (ar->drawrct.xmin == ar->drawrct.xmax) if (ar->drawrct.xmin == ar->drawrct.xmax) {
ar->drawrct = ar->winrct; ar->drawrct = ar->winrct;
scissor_pad = true;
}
else { else {
/* extra clip for safety */ /* extra clip for safety */
BLI_rcti_isect(&ar->winrct, &ar->drawrct, &ar->drawrct); BLI_rcti_isect(&ar->winrct, &ar->drawrct, &ar->drawrct);
scissor_pad = false;
} }
/* note; this sets state, so we can use wmOrtho and friends */ /* note; this sets state, so we can use wmOrtho and friends */
wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, scissor_pad);
UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);

@ -342,7 +342,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
/* Set a subwindow active in pixelspace view, with optional scissor subset */ /* Set a subwindow active in pixelspace view, with optional scissor subset */
void wmSubWindowSet (struct wmWindow *win, int swinid); void wmSubWindowSet (struct wmWindow *win, int swinid);
void wmSubWindowScissorSet (struct wmWindow *win, int swinid, struct rcti *srct); void wmSubWindowScissorSet (struct wmWindow *win, int swinid, const struct rcti *srct, bool srct_pad);
/* OpenGL utilities with safety check + working in modelview matrix mode */ /* OpenGL utilities with safety check + working in modelview matrix mode */
void wmFrustum (float x1, float x2, float y1, float y2, float n, float f); void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);

@ -569,7 +569,7 @@ static void wm_draw_region_blend(wmWindow *win, ARegion *ar)
/* region blend always is 1, except when blend timer is running */ /* region blend always is 1, except when blend timer is running */
if (fac < 1.0f) { if (fac < 1.0f) {
wmSubWindowScissorSet(win, win->screen->mainwin, &ar->winrct); wmSubWindowScissorSet(win, win->screen->mainwin, &ar->winrct, true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
wm_triple_draw_textures(win, win->drawdata, 1.0f - fac); wm_triple_draw_textures(win, win->drawdata, 1.0f - fac);

@ -239,7 +239,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
static wmWindow *_curwindow = NULL; static wmWindow *_curwindow = NULL;
static wmSubWindow *_curswin = NULL; static wmSubWindow *_curswin = NULL;
void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool srct_pad)
{ {
int width, height; int width, height;
_curswin = swin_from_swinid(win, swinid); _curswin = swin_from_swinid(win, swinid);
@ -257,8 +257,16 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) { if (srct) {
int scissor_width = BLI_rcti_size_x(srct) + 1; /* only here */ int scissor_width = BLI_rcti_size_x(srct);
int scissor_height = BLI_rcti_size_y(srct) + 1; int scissor_height = BLI_rcti_size_y(srct);
/* typically a single pixel doesn't matter,
* but one pixel offset is noticable with viewport border render */
if (srct_pad) {
scissor_width += 1;
scissor_height += 1;
}
glScissor(srct->xmin, srct->ymin, scissor_width, scissor_height); glScissor(srct->xmin, srct->ymin, scissor_width, scissor_height);
} }
else else
@ -273,7 +281,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
/* enable the WM versions of opengl calls */ /* enable the WM versions of opengl calls */
void wmSubWindowSet(wmWindow *win, int swinid) void wmSubWindowSet(wmWindow *win, int swinid)
{ {
wmSubWindowScissorSet(win, swinid, NULL); wmSubWindowScissorSet(win, swinid, NULL, true);
} }
void wmFrustum(float x1, float x2, float y1, float y2, float n, float f) void wmFrustum(float x1, float x2, float y1, float y2, float n, float f)