Feature + Fix:

- while sampling color in image window, you now get the sampled color as a line
drawn in the node editor Curve nodes, allowing quicker view of what values you
actually change.

- reverted temporary the patch [#6779] by Matthew Plough
  He replaced image drawing of backdrop-node-editor with our Texture drawing
  function. That call is extremely slow, and should be by definition slower
  than glDrawPixels (unless you don't upload the image each time to gfx mem).

  Drawing large frames (2k, 4k) in node editor became unacceptable slow, even 
  with the neatest hardware around. (tested nvidia, ati) 

  Probably (Campbell thinks) this is a bypass for Linux ATI cards? 
  Anyhoo, this should be investigated further before applying. It better then
  becomes a user pref, or even much better: part of the OpenGL profiler we need.
This commit is contained in:
Ton Roosendaal
2008-01-14 19:03:27 +00:00
parent cdcba166f6
commit 28667a314e
5 changed files with 113 additions and 15 deletions

View File

@@ -103,6 +103,9 @@ void node_rename_but(char *s);
void init_node_butfuncs(void);
void node_curvemap_sample(float *col);
/* exported to CMP and SHD nodes */
//void node_ID_title_cb(void *node_v, void *unused_v);
//void node_but_title_cb(void *node_v, void *but_v);

View File

@@ -69,13 +69,16 @@ typedef struct CurveMapping {
CurveMap cm[4]; /* max 4 builtin curves per mapping struct now */
float black[3], white[3]; /* black/white point (black[0] abused for current frame) */
float bwmul[3], padf; /* black/white point multiply value, for speed */
float bwmul[3]; /* black/white point multiply value, for speed */
float sample[3]; /* sample values, if flag set it draws line and intersection */
} CurveMapping;
/* cumapping->flag */
#define CUMA_DO_CLIP 1
#define CUMA_PREMULLED 2
#define CUMA_DRAW_CFRA 4
#define CUMA_DRAW_SAMPLE 8
#endif

View File

@@ -348,7 +348,7 @@ static int node_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *b
if(cumap) cumap->flag |= CUMA_DRAW_CFRA;
if(node->custom1<node->custom2)
cumap->black[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
uiBlockBeginAlign(block);
uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Sta:",
@@ -380,9 +380,23 @@ static int node_buts_curvevec(uiBlock *block, bNodeTree *ntree, bNode *node, rct
return (int)(node->width-NODE_DY);
}
static float *_sample_col= NULL; // bad bad, 2.5 will do better?
void node_curvemap_sample(float *col)
{
_sample_col= col;
}
static int node_buts_curvecol(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
CurveMapping *cumap= node->storage;
if(_sample_col) {
cumap->flag |= CUMA_DRAW_SAMPLE;
VECCOPY(cumap->sample, _sample_col);
}
else
cumap->flag &= ~CUMA_DRAW_SAMPLE;
curvemap_buttons(block, node->storage, 'c', B_NODE_EXEC+node->nr, B_REDR, butr);
}
return (int)(node->width-NODE_DY);
@@ -2112,7 +2126,40 @@ static void draw_nodespace_grid(SpaceNode *snode)
glEnd();
}
static void draw_nodespace_back(ScrArea *sa, SpaceNode *snode)
static void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode)
{
draw_nodespace_grid(snode);
if(snode->flag & SNODE_BACKDRAW) {
Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
if(ibuf) {
int x, y;
/* somehow the offset has to be calculated inverse */
glaDefine2DArea(&sa->winrct);
/* ortho at pixel level curarea */
myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
x = (sa->winx-ibuf->x)/2 + snode->xof;
y = (sa->winx-ibuf->y)/2 + snode->yof;
if(ibuf->rect)
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
else if(ibuf->channels==4)
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float);
/* sort this out, this should not be needed */
myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax);
bwin_clear_viewmat(sa->win); /* clear buttons view */
glLoadIdentity();
}
}
}
/* note: needs to be userpref or opengl profile option */
static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
{
draw_nodespace_grid(snode);
@@ -3062,7 +3109,7 @@ void drawnodespace(ScrArea *sa, void *spacedata)
snode->curfont= uiSetCurFont_ext(snode->aspect);
/* backdrop */
draw_nodespace_back(sa, snode);
draw_nodespace_back_pix(sa, snode);
/* nodes */
snode_set_context(snode);

View File

@@ -97,6 +97,7 @@
#include "BSE_drawipo.h"
#include "BSE_edit.h"
#include "BSE_filesel.h"
#include "BSE_node.h"
#include "BSE_trans_types.h"
#include "BDR_editobject.h"
@@ -1889,6 +1890,7 @@ void sima_sample_color(void)
if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
float *fp= NULL, *zpf= NULL;
float vec[3];
int *zp= NULL;
char *cp= NULL;
@@ -1907,14 +1909,14 @@ void sima_sample_color(void)
if(ibuf->rect_float)
fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
if(fp==NULL) {
fp= vec;
vec[0]= (float)cp[0]/255.0f;
vec[1]= (float)cp[1]/255.0f;
vec[2]= (float)cp[2]/255.0f;
}
if(G.sima->cumap) {
float vec[3];
if(fp==NULL) {
fp= vec;
vec[0]= (float)cp[0]/255.0f;
vec[1]= (float)cp[1]/255.0f;
vec[2]= (float)cp[2]/255.0f;
}
if(ibuf->channels==4) {
if(G.qual & LR_CTRLKEY) {
@@ -1928,18 +1930,36 @@ void sima_sample_color(void)
}
}
{
ScrArea *sa, *cur= curarea;
node_curvemap_sample(fp); /* sends global to node editor */
for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
if(sa->spacetype==SPACE_NODE) {
areawinset(sa->win);
scrarea_do_windraw(sa);
}
}
node_curvemap_sample(NULL); /* clears global in node editor */
curarea= cur;
}
areawinset(curarea->win);
scrarea_do_windraw(curarea);
myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375);
glLoadIdentity();
sima_show_info(ibuf->channels, x, y, cp, fp, zp, zpf);
sima_show_info(ibuf->channels, x, y, cp, (ibuf->rect_float)?fp:NULL, zp, zpf);
screen_swapbuffers();
}
}
BIF_wait_for_statechange();
}
scrarea_queue_winredraw(curarea);
}
/* Image functions */

View File

@@ -2234,10 +2234,35 @@ static void ui_draw_but_CURVE(uiBut *but)
if(cumap->flag & CUMA_DRAW_CFRA) {
glColor3ub(0x60, 0xc0, 0x40);
glBegin(GL_LINES);
glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y1);
glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y2);
glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y1);
glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y2);
glEnd();
}
/* sample option */
if(cumap->flag & CUMA_DRAW_SAMPLE) {
if(cumap->cur==3) {
float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f;
glColor3ub(240, 240, 240);
glBegin(GL_LINES);
glVertex2f(but->x1 + zoomx*(lum-offsx), but->y1);
glVertex2f(but->x1 + zoomx*(lum-offsx), but->y2);
glEnd();
}
else {
if(cumap->cur==0)
glColor3ub(240, 100, 100);
else if(cumap->cur==1)
glColor3ub(100, 240, 100);
else
glColor3ub(100, 100, 240);
glBegin(GL_LINES);
glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y1);
glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y2);
glEnd();
}
}
/* the curve */
BIF_ThemeColorBlend(TH_TEXT, TH_BUT_NEUTRAL, 0.35);