OpenGL: call glLineWidth less often

Each LINES draw call is now responsible for its own line width. No need
to set it back to its 1.0 default after every draw.

This eliminates half our calls to glLineWidth , similar to last week’s
work on glPointSize.
This commit is contained in:
Mike Erwin 2016-01-23 00:58:32 -05:00
parent 90293a8da3
commit e25ba162c0
25 changed files with 31 additions and 87 deletions

View File

@ -3697,7 +3697,6 @@ static void navmesh_drawColored(DerivedMesh *dm)
//UI_ThemeColor(TH_WIRE);
glLineWidth(2.0);
dm->drawEdges(dm, 0, 1);
glLineWidth(1.0);
#endif
/* if (GPU_buffer_legacy(dm) ) */ /* TODO - VBO draw code, not high priority - campbell */

View File

@ -3716,7 +3716,6 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
glLineWidth(2.0);
fdrawline((float)(offset), yminc,
(float)(v2d->cur.xmax), yminc);
glLineWidth(1.0);
}
}

View File

@ -123,9 +123,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
glVertex2f(x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
glVertex2f(x, v2d->cur.ymax);
glEnd();
glLineWidth(1.0);
/* Draw current frame number in a little box */
if (flag & DRAWCFRA_SHOW_NUMBOX) {
UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);

View File

@ -3430,8 +3430,6 @@ void REEB_draw()
}
}
glEnable(GL_DEPTH_TEST);
glLineWidth(1.0);
}
#endif

View File

@ -145,9 +145,6 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
glVertex2iv(&pt->x);
}
glEnd();
/* reset for predictable OpenGL context */
glLineWidth(1.0f);
if (G.debug & G_DEBUG) setlinestyle(0);
}
@ -1122,7 +1119,6 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
glDisable(GL_LINE_SMOOTH); // smooth lines
/* restore initial gl conditions */
glLineWidth(1.0);
glColor4f(0, 0, 0, 1);
}

View File

@ -528,8 +528,6 @@ static void histogram_draw_one(
glVertex2f(x2, y + (data[i] * h));
}
glEnd();
glLineWidth(1.0);
}
else {
/* under the curve */
@ -1631,7 +1629,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
glEnd();
glColor4ub(0, 0, 0, 150);
glLineWidth(1);
glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINE_LOOP);
for (int a = 0; a < 16; a++)

View File

@ -274,8 +274,6 @@ static void vicon_x_draw(int x, int y, int w, int h, float alpha)
glVertex2i(x + w, y);
glVertex2i(x, y + h);
glEnd();
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
}
@ -443,7 +441,6 @@ static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
glEnd();
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
}
@ -461,7 +458,6 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha)
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
glEnd();
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
}

View File

@ -452,8 +452,6 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
fdrawline(x1, y1, x2, y2);
fdrawline(x1, y2, x2, y1);
glLineWidth(1.0);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);

View File

@ -197,7 +197,6 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
glVertex2fv(point_pos);
glVertex2fv(handle_pos);
glEnd();
glLineWidth(1);
}
switch (handle_type) {
@ -213,6 +212,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
break;
}
glLineWidth(1);
glBegin(GL_LINES);
glVertex2fv(point_pos);
glVertex2fv(handle_pos);

View File

@ -1050,8 +1050,6 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glVertex3fv(kcd->prev.cage);
glVertex3fv(kcd->curr.cage);
glEnd();
glLineWidth(1.0);
}
if (kcd->prev.vert) {
@ -1080,8 +1078,6 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
glVertex3fv(kcd->curr.edge->v1->cageco);
glVertex3fv(kcd->curr.edge->v2->cageco);
glEnd();
glLineWidth(1.0);
}
else if (kcd->curr.vert) {
glColor3ubv(kcd->colors.point);
@ -1151,7 +1147,6 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
}
glEnd();
glLineWidth(1.0);
}
if (kcd->totkvert > 0) {

View File

@ -1045,11 +1045,11 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
glColor3ub(0x50, 0x50, 0x50);
glLineWidth((2.0f * U.pixelsize) - 1);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
glLineWidth(1.0f);
}
}
else {
glColor3ub(0, 0, 0);
glLineWidth(1);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
}
}

View File

@ -932,8 +932,6 @@ static void paint_draw_curve_cursor(Brush *brush)
draw_rect_point(&cp->bez.vec[0][0], 8.0, cp->bez.f1 || cp->bez.f2);
draw_rect_point(&cp->bez.vec[2][0], 8.0, cp->bez.f3 || cp->bez.f2);
glLineWidth(1.0);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glDisableClientState(GL_VERTEX_ARRAY);

View File

@ -727,7 +727,6 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
glLineWidth(2.0);
glColor4ub(255, 255, 255, 255);
sdrawline(x, y, pop->startmouse[0], pop->startmouse[1]);
glLineWidth(1.0);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);

View File

@ -439,7 +439,6 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
for (i = a; i < b; i++)
glVertex2f(path[i][0], path[i][1]);
glEnd();
glLineWidth(1.0f);
}
UI_ThemeColor(TH_PATH_BEFORE);
@ -459,6 +458,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
UI_ThemeColor(TH_PATH_BEFORE);
glLineWidth(1);
glBegin(GL_LINE_STRIP);
for (i = a; i < b; i++) {
if (i == count + 1)
@ -515,7 +516,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
glVertex2f(pos[0], pos[1] + px[1] * 2);
glVertex2f(pos[0], pos[1] + px[1] * 8);
glEnd();
if (!tiny) glLineWidth(1.0f);
}
}
@ -543,9 +543,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
glEnd();
}
glPopMatrix();
if (!tiny)
glLineWidth(1.0f);
}
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
@ -886,9 +883,6 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
}
glPopMatrix();
if (outline)
glLineWidth(1.0f);
}
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@ -1192,9 +1186,6 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
if (stipple)
glDisable(GL_LINE_STIPPLE);
if (thick)
glLineWidth(1.0f);
}
/* Draw sliders. */
@ -1663,8 +1654,6 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
layer = layer->next;
}
glLineWidth(1.0f);
}
glPopMatrix();

View File

@ -115,8 +115,6 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
static void tracking_segment_end_cb(void *UNUSED(userdata), int UNUSED(coord))
{
glEnd();
glLineWidth(1.0f);
}
typedef struct TrackMotionCurveUserData {
@ -261,7 +259,6 @@ static void tracking_error_segment_end_cb(void *UNUSED(userdata), int coord)
{
if (coord == 1) {
glEnd();
glLineWidth(1.0f);
}
}

View File

@ -260,8 +260,6 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
glVertex2f(x, v2d->cur.ymax);
glEnd();
glLineWidth(1.0);
UI_view2d_view_orthoSpecial(ar, v2d, 1);
/* because the frame number text is subject to the same scaling as the contents of the view */

View File

@ -85,6 +85,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
/* draw two black lines showing the standard reference levels */
glColor3f(0.0f, 0.0f, 0.0f);
glLineWidth(1);
setlinestyle(5);
glBegin(GL_LINES);
@ -93,7 +94,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
glVertex2f(v2d->cur.xmin, env->midval + env->max);
glVertex2f(v2d->cur.xmax, env->midval + env->max);
glEnd(); /* GL_LINES */
glEnd();
setlinestyle(0);
/* set size of vertices (non-adjustable for now) */
@ -852,7 +853,6 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* cleanup line drawing */
setlinestyle(0);
glLineWidth(1.0f);
}
/* draw driver only if actually functional */
@ -946,7 +946,6 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
/* restore settings */
setlinestyle(0);
glLineWidth(1.0f);
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
@ -1036,7 +1035,6 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* restore settings */
setlinestyle(0);
glLineWidth(1.0);
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);

View File

@ -280,7 +280,6 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
glVertex2f(v2d->cur.xmax, y);
glEnd();
glLineWidth(1.0);
glDisable(GL_BLEND);
}
@ -299,7 +298,6 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
glVertex2f(x, v2d->cur.ymax);
glEnd();
glLineWidth(1.0);
glDisable(GL_BLEND);
}
else {

View File

@ -3506,9 +3506,6 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
}
glDisable(GL_LINE_SMOOTH);
/* restore previuos linewidth */
glLineWidth(1.0f);
}
}
@ -3588,9 +3585,6 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
}
glDisable(GL_LINE_SMOOTH);
/* restore previuos linewidth */
glLineWidth(1.0f);
}
#endif

View File

@ -651,7 +651,6 @@ static void node_circle_draw(float x, float y, float size, const float col[4], i
glEnd();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
glLineWidth(1.0f);
}
void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *sock, float size, int highlight)

View File

@ -1090,8 +1090,6 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
glBitmap(8, 8, 4, 4, 0, 0, bm_dot5);
}
glLineWidth(1.0);
glPopMatrix();
}

View File

@ -492,7 +492,9 @@ void drawaxes(float size, char drawtype)
float v1[3] = {0.0, 0.0, 0.0};
float v2[3] = {0.0, 0.0, 0.0};
float v3[3] = {0.0, 0.0, 0.0};
glLineWidth(1);
switch (drawtype) {
case OB_PLAINAXES:
@ -749,6 +751,7 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3],
glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL);
/* 2. draw outline */
glLineWidth(1);
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL);
@ -1203,6 +1206,8 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
glColor4ubv(curcol);
}
glLineWidth(1);
if (lampsize > 0.0f) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
@ -1661,7 +1666,6 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
draw_bundle_sphere();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1.0f);
}
if ((dflag & DRAW_CONSTCOLOR) == 0) {
@ -1717,8 +1721,6 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
glVertex3fv(camera->mat[3]);
}
glEnd();
glLineWidth(1.0f);
}
}
}
@ -2062,6 +2064,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
asp, shift, &drawsize, vec);
glDisable(GL_CULL_FACE);
glLineWidth(1);
/* camera frame */
if (!is_stereo3d_cameras) {
@ -2163,6 +2166,7 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
float vec[3];
glEnable(GL_BLEND);
glLineWidth(1);
for (int j = 0; j < 3; j++) {
vec[2] = 0.25f * j - 0.125f;
@ -2317,7 +2321,8 @@ static void drawlattice(View3D *v3d, Object *ob)
glShadeModel(GL_SMOOTH);
}
}
glLineWidth(1);
glBegin(GL_LINES);
for (w = 0; w < lt->pntsw; w++) {
int wxt = (w == 0 || w == lt->pntsw - 1);
@ -3041,7 +3046,6 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
if (data.cd_layer_offset != -1) {
glLineWidth(3.0);
dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, &data);
glLineWidth(1.0);
}
}
@ -3101,7 +3105,6 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
if (data.cd_layer_offset != -1) {
glLineWidth(3.0);
dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, &data);
glLineWidth(1.0);
}
}
}
@ -3657,6 +3660,8 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
BMVert *eve_act = NULL;
bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE);
glLineWidth(1);
if (em->bm->selected.last) {
BMEditSelection *ese = em->bm->selected.last;
/* face is handled above */
@ -3809,7 +3814,6 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
draw_dm_edges_seams(em, cageDM);
glColor3ub(0, 0, 0);
glLineWidth(1);
}
if (me->drawflag & ME_DRAWSHARP) {
@ -3819,7 +3823,6 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
draw_dm_edges_sharp(em, cageDM);
glColor3ub(0, 0, 0);
glLineWidth(1);
}
#ifdef WITH_FREESTYLE
@ -3830,7 +3833,6 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
draw_dm_edges_freestyle(em, cageDM);
glColor3ub(0, 0, 0);
glLineWidth(1);
}
#endif
@ -3841,6 +3843,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
draw_dm_bweights(em, scene, cageDM);
}
glLineWidth(1);
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
}
@ -3910,7 +3913,6 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
dm->drawEdges(dm, 0, 1);
}
glLineWidth(1.0);
glDepthMask(1);
}
}
@ -5541,8 +5543,6 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
cdata2 = NULL;
}
glLineWidth(1.0f);
if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
cache = psys->pathcache;
@ -5820,7 +5820,6 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
glDisableClientState(GL_VERTEX_ARRAY);
glShadeModel(GL_FLAT);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
glLineWidth(1.0f);
}
static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, float ith, float drw_size)
@ -6072,7 +6071,6 @@ static void drawhandlesN_active(Nurb *nu)
glEnd();
glColor3ub(0, 0, 0);
glLineWidth(1);
}
static void drawvertsN(Nurb *nu, const char sel, const bool hide_handles, const void *vert)
@ -6155,7 +6153,6 @@ static void editnurb_draw_active_poly(Nurb *nu)
}
glColor3ub(0, 0, 0);
glLineWidth(1);
}
static void editnurb_draw_active_nurbs(Nurb *nu)
@ -6197,7 +6194,6 @@ static void editnurb_draw_active_nurbs(Nurb *nu)
glEnd();
glColor3ub(0, 0, 0);
glLineWidth(1);
}
static void draw_editnurb_splines(Object *ob, Nurb *nurb, const bool sel)
@ -7178,7 +7174,6 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
draw_armature(scene, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
}
glLineWidth(1.0);
glDepthMask(1);
}
@ -7195,6 +7190,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, const
ED_view3d_polygon_offset(rv3d, 1.0);
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
glLineWidth(1);
if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
@ -7274,7 +7270,7 @@ static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
view3d_cached_text_draw_add(v, axis_str[axis], 2, 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
}
}
glLineWidth(1.0f);
setlinestyle(0);
}

View File

@ -490,6 +490,8 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool wr
UI_GetThemeColor3ubv(TH_GRID, col_grid);
glLineWidth(1);
/* draw the Y axis and/or grid lines */
if (v3d->gridflag & V3D_SHOW_FLOOR) {
const int sublines = v3d->gridsubdiv;
@ -569,6 +571,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
const float f10 = 0.5f * U.widget_unit;
const float f20 = U.widget_unit;
glLineWidth(1);
setlinestyle(0);
cpack(0xFF);
circ((float)co[0], (float)co[1], f10);
@ -636,9 +639,6 @@ static void draw_view_axis(RegionView3D *rv3d, rcti *rect)
glEnable(GL_BLEND);
}
/* restore line-width */
glLineWidth(1.0);
glDisable(GL_BLEND);
}

View File

@ -1711,6 +1711,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
UI_ThemeColor(TH_VIEW_OVERLAY);
setlinestyle(3);
glLineWidth(1);
glBegin(GL_LINES);
glVertex2iv(t->mval);
glVertex2fv(cent);
@ -1752,6 +1753,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
UI_ThemeColor(TH_VIEW_OVERLAY);
setlinestyle(3);
glLineWidth(1);
glBegin(GL_LINES);
glVertex2iv(t->mval);
glVertex2fv(cent);
@ -1804,7 +1806,6 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
}
glPopMatrix();
glLineWidth(1.0);
}
}

View File

@ -738,7 +738,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glLineWidth(1);
switch (sima->dt_uv) {
case SI_UVDT_DASH:
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {