[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (9bad11053dbc145b468fb11d1a605112b40b719a)



The branch, master has been updated
       via  9bad11053dbc145b468fb11d1a605112b40b719a (commit)
       via  c53998333ce3542e1029f5a2c1c216e227be339b (commit)
       via  5e8e118c05be8585dceda8a30987065b99ce530f (commit)
      from  e199787705a37b9704eb8f6458b25907e7123e4c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/hid/gtk/gtkhid-gl.c |   68 ++++++++++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 27 deletions(-)


=================
 Commit Messages
=================

commit 9bad11053dbc145b468fb11d1a605112b40b719a
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Add facility to set an alpha multiplier for the current rendering

:100644 100644 2a50cd1... a93c607... M	src/hid/gtk/gtkhid-gl.c

commit c53998333ce3542e1029f5a2c1c216e227be339b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Refactor alpha handling
    
    Replace "alpha_mult" in set_gl_color_for_gc () with just explicitly calling
    this the "a" (alpha) value of the colour in question.

:100644 100644 cfd41ff... 2a50cd1... M	src/hid/gtk/gtkhid-gl.c

commit 5e8e118c05be8585dceda8a30987065b99ce530f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Refactor GL colour setup handling

:100644 100644 95e0f11... cfd41ff... M	src/hid/gtk/gtkhid-gl.c

=========
 Changes
=========

commit 9bad11053dbc145b468fb11d1a605112b40b719a
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Add facility to set an alpha multiplier for the current rendering

diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 2a50cd1..a93c607 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -46,6 +46,7 @@ typedef struct render_priv {
   bool in_context;
   int subcomposite_stencil_bit;
   char *current_colorname;
+  double current_alpha_mult;
 } render_priv;
 
 
@@ -54,6 +55,7 @@ typedef struct hid_gc_struct
   HID *me_pointer;
 
   const char *colorname;
+  double alpha_mult;
   gint width;
   gint cap, join;
   gchar xor;
@@ -172,6 +174,7 @@ ghid_make_gc (void)
   rv = g_new0 (hid_gc_struct, 1);
   rv->me_pointer = &ghid_hid;
   rv->colorname = Settings.BackgroundColor;
+  rv->alpha_mult = 1.0;
   return rv;
 }
 
@@ -356,11 +359,13 @@ set_gl_color_for_gc (hidGC gc)
   double r, g, b, a;
 
   if (priv->current_colorname != NULL &&
-      strcmp (priv->current_colorname, gc->colorname) == 0)
+      strcmp (priv->current_colorname, gc->colorname) == 0 &&
+      priv->current_alpha_mult == gc->alpha_mult)
     return;
 
   free (priv->current_colorname);
   priv->current_colorname = strdup (gc->colorname);
+  priv->current_alpha_mult = gc->alpha_mult;
 
   if (gport->colormap == NULL)
     gport->colormap = gtk_widget_get_colormap (gport->top_window);
@@ -422,6 +427,7 @@ set_gl_color_for_gc (hidGC gc)
     }
   if (1) {
     double maxi, mult;
+    a *= gc->alpha_mult;
     if (!priv->trans_lines)
       a = 1.0;
     maxi = r;
@@ -450,6 +456,13 @@ ghid_set_color (hidGC gc, const char *name)
 }
 
 void
+ghid_set_alpha_mult (hidGC gc, double alpha_mult)
+{
+  gc->alpha_mult = alpha_mult;
+  set_gl_color_for_gc (gc);
+}
+
+void
 ghid_set_line_cap (hidGC gc, EndCapStyle style)
 {
   gc->cap = style;

commit c53998333ce3542e1029f5a2c1c216e227be339b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Refactor alpha handling
    
    Replace "alpha_mult" in set_gl_color_for_gc () with just explicitly calling
    this the "a" (alpha) value of the colour in question.

diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index cfd41ff..2a50cd1 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -353,9 +353,7 @@ set_gl_color_for_gc (hidGC gc)
   static void *cache = NULL;
   hidval cval;
   ColorCache *cc;
-  double alpha_mult = 1.0;
   double r, g, b, a;
-  a = 1.0;
 
   if (priv->current_colorname != NULL &&
       strcmp (priv->current_colorname, gc->colorname) == 0)
@@ -371,17 +369,17 @@ set_gl_color_for_gc (hidGC gc)
       r = gport->bg_color.red   / 65535.;
       g = gport->bg_color.green / 65535.;
       b = gport->bg_color.blue  / 65535.;
+      a = 1.0;
     }
   else if (strcmp (gc->colorname, "drill") == 0)
     {
-      alpha_mult = 0.85;
       r = gport->offlimits_color.red   / 65535.;
       g = gport->offlimits_color.green / 65535.;
       b = gport->offlimits_color.blue  / 65535.;
+      a = 0.85;
     }
   else
     {
-      alpha_mult = 0.7;
       if (hid_cache_color (0, gc->colorname, &cval, &cache))
         cc = (ColorCache *) cval.ptr;
       else
@@ -420,15 +418,16 @@ set_gl_color_for_gc (hidGC gc)
       r = cc->red;
       g = cc->green;
       b = cc->blue;
+      a = 0.7;
     }
   if (1) {
     double maxi, mult;
-    if (priv->trans_lines)
-      a = a * alpha_mult;
+    if (!priv->trans_lines)
+      a = 1.0;
     maxi = r;
     if (g > maxi) maxi = g;
     if (b > maxi) maxi = b;
-    mult = MIN (1 / alpha_mult, 1 / maxi);
+    mult = MIN (1 / a, 1 / maxi);
 #if 1
     r = r * mult;
     g = g * mult;

commit 5e8e118c05be8585dceda8a30987065b99ce530f
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    GTK/GL: Refactor GL colour setup handling

diff --git a/src/hid/gtk/gtkhid-gl.c b/src/hid/gtk/gtkhid-gl.c
index 95e0f11..cfd41ff 100644
--- a/src/hid/gtk/gtkhid-gl.c
+++ b/src/hid/gtk/gtkhid-gl.c
@@ -45,6 +45,7 @@ typedef struct render_priv {
   bool trans_lines;
   bool in_context;
   int subcomposite_stencil_bit;
+  char *current_colorname;
 } render_priv;
 
 
@@ -52,7 +53,7 @@ typedef struct hid_gc_struct
 {
   HID *me_pointer;
 
-  gchar *colorname;
+  const char *colorname;
   gint width;
   gint cap, join;
   gchar xor;
@@ -345,39 +346,33 @@ typedef struct
   double blue;
 } ColorCache;
 
-void
-ghid_set_color (hidGC gc, const char *name)
+static void
+set_gl_color_for_gc (hidGC gc)
 {
   render_priv *priv = gport->render_priv;
   static void *cache = NULL;
-  static char *old_name = NULL;
   hidval cval;
   ColorCache *cc;
   double alpha_mult = 1.0;
   double r, g, b, a;
   a = 1.0;
 
-  current_gc = gc;
-
-  if (old_name != NULL)
-    {
-      if (strcmp (name, old_name) == 0)
-        return;
-      free (old_name);
-    }
+  if (priv->current_colorname != NULL &&
+      strcmp (priv->current_colorname, gc->colorname) == 0)
+    return;
 
-  old_name = strdup (name);
-  gc->colorname = (char *) name;
+  free (priv->current_colorname);
+  priv->current_colorname = strdup (gc->colorname);
 
   if (gport->colormap == NULL)
     gport->colormap = gtk_widget_get_colormap (gport->top_window);
-  if (strcmp (name, "erase") == 0)
+  if (strcmp (gc->colorname, "erase") == 0)
     {
       r = gport->bg_color.red   / 65535.;
       g = gport->bg_color.green / 65535.;
       b = gport->bg_color.blue  / 65535.;
     }
-  else if (strcmp (name, "drill") == 0)
+  else if (strcmp (gc->colorname, "drill") == 0)
     {
       alpha_mult = 0.85;
       r = gport->offlimits_color.red   / 65535.;
@@ -387,19 +382,19 @@ ghid_set_color (hidGC gc, const char *name)
   else
     {
       alpha_mult = 0.7;
-      if (hid_cache_color (0, name, &cval, &cache))
+      if (hid_cache_color (0, gc->colorname, &cval, &cache))
         cc = (ColorCache *) cval.ptr;
       else
         {
           cc = (ColorCache *) malloc (sizeof (ColorCache));
           memset (cc, 0, sizeof (*cc));
           cval.ptr = cc;
-          hid_cache_color (1, name, &cval, &cache);
+          hid_cache_color (1, gc->colorname, &cval, &cache);
         }
 
       if (!cc->color_set)
         {
-          if (gdk_color_parse (name, &cc->color))
+          if (gdk_color_parse (gc->colorname, &cc->color))
             gdk_color_alloc (gport->colormap, &cc->color);
           else
             gdk_color_white (gport->colormap, &cc->color);
@@ -449,6 +444,13 @@ ghid_set_color (hidGC gc, const char *name)
 }
 
 void
+ghid_set_color (hidGC gc, const char *name)
+{
+  gc->colorname = name;
+  set_gl_color_for_gc (gc);
+}
+
+void
 ghid_set_line_cap (hidGC gc, EndCapStyle style)
 {
   gc->cap = style;
@@ -502,7 +504,7 @@ use_gc (hidGC gc)
 
   current_gc = gc;
 
-  ghid_set_color (gc, gc->colorname);
+  set_gl_color_for_gc (gc);
   return 1;
 }
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs