[Bf-blender-cvs] [1d88773] master: OpenGL: cleanup
Mike Erwin
noreply at git.blender.org
Fri Jan 22 08:52:47 CET 2016
Commit: 1d88773b1f2e905773069a2d39617dd350683547
Author: Mike Erwin
Date: Fri Jan 22 02:44:33 2016 -0500
Branches: master
https://developer.blender.org/rB1d88773b1f2e905773069a2d39617dd350683547
OpenGL: cleanup
- LINE_STRIP to LINES when only drawing one
- group state changes for easier reading
- general cleanup
===================================================================
M source/blender/editors/animation/anim_draw.c
M source/blender/editors/interface/interface_draw.c
M source/blender/editors/space_clip/clip_draw.c
M source/blender/editors/space_clip/clip_utils.c
M source/blender/editors/space_graph/space_graph.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform_constraints.c
M source/blender/editors/transform/transform_generics.c
M source/blender/editors/util/ed_util.c
===================================================================
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index e8f59dd..76a448a 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -111,23 +111,17 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
{
Scene *scene = CTX_data_scene(C);
- float vec[2];
-
+
/* Draw a light green line to indicate current frame */
- vec[0] = (float)(scene->r.cfra * scene->r.framelen);
-
UI_ThemeColor(TH_CFRAME);
- if (flag & DRAWCFRA_WIDE)
- glLineWidth(3.0);
- else
- glLineWidth(2.0);
-
- glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin - 500.0f; /* XXX arbitrary... want it go to bottom */
- glVertex2fv(vec);
-
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
+
+ const float x = (float)(scene->r.cfra * scene->r.framelen);
+
+ glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
+
+ glBegin(GL_LINES);
+ glVertex2f(x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
+ glVertex2f(x, v2d->cur.ymax);
glEnd();
glLineWidth(1.0);
@@ -135,7 +129,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
/* Draw current frame number in a little box */
if (flag & DRAWCFRA_SHOW_NUMBOX) {
UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
- draw_cfra_number(scene, v2d, vec[0], (flag & DRAWCFRA_UNIT_SECONDS) != 0);
+ draw_cfra_number(scene, v2d, x, (flag & DRAWCFRA_UNIT_SECONDS) != 0);
}
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index b700486..f044c70 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -514,30 +514,25 @@ static void histogram_draw_one(
float r, float g, float b, float alpha,
float x, float y, float w, float h, const float *data, int res, const bool is_line)
{
- if (is_line) {
- glLineWidth(1.5);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glColor4f(r, g, b, alpha);
+ glEnable(GL_LINE_SMOOTH);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glColor4f(r, g, b, alpha);
+ if (is_line) {
/* curve outline */
+ glLineWidth(1.5);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
glVertex2f(x2, y + (data[i] * h));
}
glEnd();
- glDisable(GL_LINE_SMOOTH);
glLineWidth(1.0);
}
else {
/* under the curve */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glColor4f(r, g, b, alpha);
-
glShadeModel(GL_FLAT);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(x, y);
@@ -553,15 +548,15 @@ static void histogram_draw_one(
glColor4f(0.f, 0.f, 0.f, 0.25f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < res; i++) {
float x2 = x + i * (w / (float)res);
glVertex2f(x2, y + (data[i] * h));
}
glEnd();
- glDisable(GL_LINE_SMOOTH);
}
+
+ glDisable(GL_LINE_SMOOTH);
}
#define HISTOGRAM_TOT_GRID_LINES 4
@@ -1644,7 +1639,6 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
glEnd();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
- glLineWidth(1.0f);
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 77934bb..a4dc71d 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -481,6 +481,8 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
px[0] = 1.0f / width / sc->zoom;
px[1] = 1.0f / height / sc->zoom;
+ glLineWidth(tiny ? 1.0f : 3.0f);
+
if ((marker->flag & MARKER_DISABLED) == 0) {
float pos[2];
float p[2];
@@ -500,7 +502,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
glEnd();
}
else {
- if (!tiny) glLineWidth(3.0f);
glBegin(GL_LINES);
glVertex2f(pos[0] + px[0] * 2, pos[1]);
glVertex2f(pos[0] + px[0] * 8, pos[1]);
@@ -522,9 +523,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
glPushMatrix();
glTranslate2fv(marker_pos);
- if (!tiny)
- glLineWidth(3.0f);
-
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
glBegin(GL_LINE_LOOP);
glVertex2fv(marker->pattern_corners[0]);
@@ -795,7 +793,6 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
track_colors(track, act, col, scol);
if (outline) {
- glLineWidth(3.0f);
UI_ThemeColor(TH_MARKER_OUTLINE);
}
@@ -854,6 +851,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+ glLineWidth(outline ? 3.0f : 1.0f);
+
glEnable(GL_LINE_STIPPLE);
glLineStipple(3, 0xaaaa);
@@ -1149,17 +1148,18 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
draw_plane_marker_image(scene, plane_track, plane_marker);
}
- if (draw_outline) {
- if (!tiny) {
- glLineWidth(3.0f);
+ if (draw_plane_quad) {
+
+ const bool stipple = !draw_outline && tiny;
+ const bool thick = draw_outline && !tiny;
+
+ if (stipple) {
+ glLineStipple(3, 0xaaaa);
+ glEnable(GL_LINE_STIPPLE);
}
- }
- else if (tiny) {
- glLineStipple(3, 0xaaaa);
- glEnable(GL_LINE_STIPPLE);
- }
- if (draw_plane_quad) {
+ glLineWidth(thick ? 3.0f : 1.0f);
+
/* Draw rectangle itself. */
glBegin(GL_LINE_LOOP);
glVertex2fv(plane_marker->corners[0]);
@@ -1173,22 +1173,28 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
float end_point[2];
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);
+ glBegin(GL_LINES);
+
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
glColor3f(1.0, 0.0, 0.0f);
- glBegin(GL_LINES);
glVertex2fv(plane_marker->corners[0]);
glVertex2fv(end_point);
- glEnd();
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
glColor3f(0.0, 1.0, 0.0f);
- glBegin(GL_LINES);
glVertex2fv(plane_marker->corners[0]);
glVertex2fv(end_point);
+
glEnd();
glPopAttrib();
}
+
+ if (stipple)
+ glDisable(GL_LINE_STIPPLE);
+
+ if (thick)
+ glLineWidth(1.0f);
}
/* Draw sliders. */
@@ -1199,15 +1205,6 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
3.0f * px[0], 3.0f * px[1], draw_outline, px);
}
}
-
- if (draw_outline) {
- if (!tiny) {
- glLineWidth(1.0f);
- }
- }
- else if (tiny) {
- glDisable(GL_LINE_STIPPLE);
- }
}
static void draw_plane_marker_outline(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track,
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 48f8f58..034429f 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -247,20 +247,17 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
{
View2D *v2d = &ar->v2d;
float xscale, yscale;
- float vec[2];
/* Draw a light green line to indicate current frame */
- vec[0] = (float)(sc->user.framenr * scene->r.framelen);
-
UI_ThemeColor(TH_CFRAME);
- glLineWidth(2.0);
- glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin;
- glVertex2fv(vec);
+ float x = (float)(sc->user.framenr * scene->r.framelen);
+
+ glLineWidth(2.0);
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
+ glBegin(GL_LINES);
+ glVertex2f(x, v2d->cur.ymin);
+ glVertex2f(x, v2d->cur.ymax);
glEnd();
glLineWidth(1.0);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 9f3bfe6..6d04054 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -267,49 +267,40 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
/* horizontal component of value-cursor (value line before the current frame line) */
if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
- float vec[2];
+
+ float y = sipo->cursorVal;
/* Draw a green line to indicate the cursor value */
- vec[1] = sipo->cursorVal;
-
UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50);
- glLineWidth(2.0);
-
glEnable(GL_BLEND);
- glBegin(GL_LINE_STRIP);
- vec[0] = v2d->cur.xmin;
- glVertex2fv(vec);
-
- vec[0] = v2d->cur.xmax;
- glVertex2fv(vec);
- glEnd(); // GL_LINE_STRIP
- glDisable(GL_BLEND);
+ glLineWidth(2.0);
+
+ glBegin(GL_LINES);
+ glVertex2f(v2d->cur.xmin, y);
+ glVertex2f(v2d->cur.xmax, y);
+ glEnd();
glLineWidth(1.0);
+ glDisable(GL_BLEND);
}
/* current frame or vertical component of vertical component of the cursor */
if (sipo->mode == SIPO_MODE_DRIVERS) {
/* cursor x-value */
- float vec[2];
-
- vec[0] = sipo->cursorTime;
+ float x = sipo->cursorTime;
/* to help differentiate this from the current frame, draw slightly darker like the horizontal one */
UI_ThemeColorShadeAlpha(TH_CFRAME, -40, -50);
+ glEnable(GL_BLEND);
glLineWidth(2.0);
- glEnable(GL_BLEND);
- glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin;
- glVertex2fv(vec);
-
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
- glEnd(); // GL_LINE_STRIP
- glDisable(GL_BLEND);
+ glBegin(GL_LINES);
+ glVertex2f(x, v2d->cur.ymin);
+ glVertex2f(x, v2d->cur.ymax);
+ glEnd();
glLineWidth(1.0);
+ glDisable(GL_BLEND);
}
else {
/* current frame */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 79c065d..89313d3 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -275,10 +275,8 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3])
static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
- float divx, divy;
-
- divx
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list