[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48353] branches/soc-2012-swiss_cheese/ source: Color Readability: Start to make drawing color specification more consistent and readable.

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jun 28 03:13:53 CEST 2012


Revision: 48353
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48353
Author:   jwilkins
Date:     2012-06-28 01:13:34 +0000 (Thu, 28 Jun 2012)
Log Message:
-----------
Color Readability: Start to make drawing color specification more consistent and readable.

Changed gpuColorPack to gpuColor3x and gpuColor4x which take a hex color code.
Define common color codes as readable macros (e.g., #define CPACK_RED 0xFF0000)
Special gpuGrey function for shades of grey
Change most places that specify an alpha to use floats instead of bytes
Always format color components as 0.0f and alpha as 0.000f

There are still several places that specify compile time constants for colors and that use float or bytes instead of a single hex.  I'd like to unify all of these to use hex, and then put all the colors into GPU_colors.h (if it makes sense to).  Some files might do better with a local color dictionary.

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/pbvh.c
    branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_channels_defines.c
    branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_markers.c
    branches/soc-2012-swiss_cheese/source/blender/editors/animation/keyframes_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/armature/editarmature_sketch.c
    branches/soc-2012-swiss_cheese/source/blender/editors/armature/reeb.c
    branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/drawgpencil.c
    branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/gpencil_paint.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_icons.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_panel.c
    branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_widgets.c
    branches/soc-2012-swiss_cheese/source/blender/editors/mask/mask_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/mesh/editmesh_loopcut.c
    branches/soc-2012-swiss_cheese/source/blender/editors/mesh/editmesh_select.c
    branches/soc-2012-swiss_cheese/source/blender/editors/physics/particle_edit.c
    branches/soc-2012-swiss_cheese/source/blender/editors/screen/area.c
    branches/soc-2012-swiss_cheese/source/blender/editors/screen/glutil.c
    branches/soc-2012-swiss_cheese/source/blender/editors/screen/screen_edit.c
    branches/soc-2012-swiss_cheese/source/blender/editors/sculpt_paint/paint_cursor.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_action/action_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_clip/clip_dopesheet_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_clip/clip_graph_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_clip/clip_utils.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_file/file_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_graph/graph_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_image/image_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_info/textview.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_logic/logic_window.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_nla/nla_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_node/drawnode.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_node/node_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_outliner/outliner_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_sequencer/sequencer_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_text/text_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_time/space_time.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawarmature.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawmesh.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/drawvolume.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2012-swiss_cheese/source/blender/editors/space_view3d/view3d_fly.c
    branches/soc-2012-swiss_cheese/source/blender/editors/transform/transform.c
    branches/soc-2012-swiss_cheese/source/blender/editors/uvedit/uvedit_draw.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/CMakeLists.txt
    branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_compatibility.h
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.h
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_inline.h
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_dragdrop.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_gesture.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c
    branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Dome.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
    branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp

Modified: branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/subsurf_ccg.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/blenkernel/intern/subsurf_ccg.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -1613,7 +1613,7 @@
 	}
 
 	if (useAging && !(G.f & G_BACKBUFSEL)) {
-		gpuCurrentColor3ub(0, 0, 0);
+		gpuCurrentColor3x(CPACK_BLACK);
 	}
 
 	if (ccgdm->drawInteriorEdges) {

Modified: branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/pbvh.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/blenlib/intern/pbvh.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -1647,7 +1647,7 @@
 	}
 	gpuMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col);
 
-	gpuCurrentColor3f(1, 0, 0);
+	gpuCurrentColor3x(CPACK_RED);
 #endif
 
 	if (!(node->flag & PBVH_FullyHidden))

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_channels_defines.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_channels_defines.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -3028,7 +3028,7 @@
 		/* draw red underline if channel is disabled */
 		if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) {
 			// FIXME: replace hardcoded color here, and check on extents!
-			gpuCurrentColor3f(1, 0, 0);
+			gpuCurrentColor3x(CPACK_RED);
 			glLineWidth(2.0);
 			gpuSingleLinef(offset, yminc, v2d->cur.xmax, yminc); // DOODLE: single thick colored line
 			glLineWidth(1.0);

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_draw.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_draw.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -263,7 +263,7 @@
 	/* only draw this if preview range is set */
 	if (PRVRANGEON) {
 		glEnable(GL_BLEND);
-		gpuCurrentColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+		gpuCurrentColor4x(CPACK_BLACK, 0.4f);
 		
 		/* only draw two separate 'curtains' if there's no overlap between them */
 		if (PSFRA < PEFRA) {

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_markers.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_markers.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/animation/anim_markers.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -372,12 +372,9 @@
 	{
 		setlinestyle(3);
 
-		if (marker->flag & SELECT) {
-			gpuCurrentColor4ub(255, 255, 255, 96);
-		}
-		else {
-			gpuCurrentColor4ub(0, 0, 0, 96);
-		}
+		gpuCurrentColor4x(
+			(marker->flag & SELECT) ? CPACK_WHITE : CPACK_BLACK,
+			0.376f);
 
 		// DOODLE single 2D line, stippled
 		gpuSingleLinef(

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/animation/keyframes_draw.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/animation/keyframes_draw.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -633,7 +633,7 @@
 	
 	if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) {
 		/* exterior - black frame */
-		gpuCurrentColor4f(0.0f, 0.0f, 0.0f, alpha);
+		gpuCurrentColor4x(CPACK_BLACK, alpha);
 		
 		glCallList(displist1);
 	}

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/armature/editarmature_sketch.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/armature/editarmature_sketch.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/armature/editarmature_sketch.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -499,7 +499,7 @@
 
 	glRotatef(angle * (float)(180.0 / M_PI), axis[0], axis[1], axis[2]);
 
-	gpuCurrentColor3f(0, 1, 1);
+	gpuCurrentColor3x(CPACK_CYAN);
 
 	gpuDrawCylinder(prim, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height));
 	//GLU gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
@@ -542,13 +542,13 @@
 			glPushMatrix();
 
 			if (pt->type == PT_EXACT) {
-				gpuCurrentColor3f(0, 0, 0);
+				gpuCurrentColor3x(CPACK_BLACK);
 				sk_drawPoint(&prim, pt, 0.15);
 				sk_drawNormal(&prim, pt, 0.05, 0.9);
 			}
 
 			if (i >= start && i <= end) {
-				gpuCurrentColor3f(0.3, 0.3, 0.3);
+				gpuCurrentGrey3f(0.300f);
 			}
 			else {
 				gpuCurrentColor3fv(rgb);
@@ -588,7 +588,7 @@
 
 		glPushMatrix();
 
-		gpuCurrentColor3f(0, 1, 0);
+		gpuCurrentColor3x(CPACK_GREEN);
 		sk_drawPoint(&prim, pt, 0.15);
 
 		sk_drawNormal(&prim, pt, 0.05, 0.9);
@@ -2076,10 +2076,10 @@
 
 				switch (sketch->next_point.mode) {
 					case PT_SNAP:
-						gpuCurrentColor3f(0, 1, 0);
+						gpuCurrentColor3x(CPACK_GREEN);
 						break;
 					case PT_PROJECT:
-						gpuCurrentColor3f(0, 0, 0);
+						gpuCurrentColor3x(CPACK_BLACK);
 						break;
 				}
 

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/armature/reeb.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/armature/reeb.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/armature/reeb.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -3378,7 +3378,7 @@
 		char *s = text;
 
 		glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2);
-		gpuCurrentColor3f(0, 0, 0);
+		gpuCurrentColor3x(CPACK_BLACK);
 
 		gpuImmediateFormat_V3(); // DOODLE: REEB (commented out)
 
@@ -3401,7 +3401,7 @@
 
 		if (arc->symmetry_level == 1)
 		{
-			gpuCurrentColor3f(1, 0, 0);
+			gpuCurrentColor3f(CPACK_RED);
 		}
 		else if (arc->symmetry_flag == SYM_SIDE_POSITIVE || arc->symmetry_flag == SYM_SIDE_NEGATIVE)
 		{
@@ -3412,7 +3412,7 @@
 			gpuCurrentColor3f(0.5f, 1, 0);
 		}
 		else {
-			gpuCurrentColor3f(1, 1, 0);
+			gpuCurrentColor3f(CPACK_YELLOW);
 		}
 		gpuBegin(GL_LINE_STRIP);
 		gpuVertex3fv(arc->head->p);
@@ -3431,7 +3431,7 @@
 
 		if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED)
 		{
-			gpuCurrentColor3f(1, 1, 1);				
+			gpuCurrentColor3x(CPACK_WHITE);
 			gpuBegin(GL_POINTS);
 			gpuVertex3fv(arc->head->p);
 			gpuVertex3fv(arc->tail->p);
@@ -3465,7 +3465,7 @@
 				s += sprintf(s, "l:%0.3f", arc->length);
 			}
 
-			gpuCurrentColor3f(0, 1, 0);
+			gpuCurrentColor3f(CPACK_GREEN);
 			glRasterPos3fv(vec);
 			BMF_DrawString(G.fonts, text);
 		}

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/drawgpencil.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/drawgpencil.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -645,7 +645,6 @@
 	/* restore initial gl conditions */
 	glLineWidth(1.0);
 	glPointSize(1.0);
-	gpuCurrentColor4f(0, 0, 0, 1);
 
 	gpuImmediateUnformat();
 }

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/gpencil_paint.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/gpencil/gpencil_paint.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -1280,7 +1280,7 @@
 	tGPsdata *p = (tGPsdata *)p_ptr;
 	
 	if (p->paintmode == GP_PAINTMODE_ERASER) {
-		gpuCurrentColor4ub(255, 255, 255, 128);
+		gpuCurrentColor4x(CPACK_WHITE, 0.500f);
 		
 		glEnable(GL_LINE_SMOOTH);
 		glEnable(GL_BLEND);

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -512,11 +512,11 @@
 	rect.ymax = (line->to->y1 + line->to->y2) / 2.0f;
 	
 	if (line->flag & UI_SELECT)
-		gpuCurrentColor3ub(100, 100, 100);
+		gpuCurrentGrey3f(0.392f);
 	else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
 		UI_ThemeColor(TH_TEXT_HI);
 	else 
-		gpuCurrentColor3ub(0, 0, 0);
+		gpuCurrentColor3x(CPACK_BLACK);
 
 	ui_draw_link_bezier(&rect);
 }

Modified: branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c	2012-06-28 00:00:09 UTC (rev 48352)
+++ branches/soc-2012-swiss_cheese/source/blender/editors/interface/interface_draw.c	2012-06-28 01:13:34 UTC (rev 48353)
@@ -401,26 +401,14 @@
 	gpuBegin(GL_LINES);
 
 	/* below */
-	if (sel) {
-		gpuColor3ub(200, 200, 200);
-	}
-	else {
-		gpuColor3ub(50, 50, 50);
-	}
-
+	gpuCurrentGrey3f(sel ? 0.784f : 0.196f);
 	gpuAppendLinef(x1, y1, x2, y1);
 
 	/* right */
 	gpuAppendLinef(x2, y1, x2, y2);
 	
 	/* top */
-	if (sel) {
-		gpuColor3ub(50, 50, 50);
-	}
-	else {
-		gpuColor3ub(200, 200, 200);
-	}
-
+	gpuCurrentGrey3f(!sel ? 0.784f : 0.196f);
 	gpuAppendLinef(x1, y2, x2, y2);
 
 	/* left */
@@ -446,7 +434,7 @@
 	
 	/* scissor doesn't seem to be doing the right thing...? */
 #if 0
-	//gpuCurrentColor4f(1.0, 0.f, 0.f, 1.f);
+	//gpuCurrentColor3x(CPACK_RED);
 	//gpuSingleWireRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
 
 	w = (rect->xmax - rect->xmin);
@@ -457,7 +445,7 @@
 #endif
 	
 	glEnable(GL_BLEND);
-	gpuCurrentColor4f(0.0, 0.0, 0.0, 0.0);
+	gpuCurrentColor4x(CPACK_BLACK, 0.000f);
 	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list