@@ -85,12 +85,26 @@ public Handle(String t, String n, int vi, String v, int ti, int l, int sc,
8585 textFormat = "0x%x" ;
8686
8787 } else if ("webcolor" .equals (type )) {
88- Long val = Long .parseLong (strValue .substring (1 , strValue .length ()), 16 );
88+ Long val ;
89+ String prefix ;
90+ if (strValue .length () == 7 ) {
91+ val = Long .parseLong (strValue .substring (1 , strValue .length ()), 16 );
92+ prefix = "" ;
93+ } else {
94+ String valStr = strValue .substring (
95+ strValue .length () - 6 ,
96+ strValue .length ()
97+ );
98+ val = Long .parseLong (valStr , 16 );
99+ prefix = strValue .substring (
100+ 1 ,
101+ strValue .length () - 6
102+ );
103+ }
89104 val = val | 0xff000000 ;
90105 value = newValue = val .intValue ();
91106 strNewValue = strValue ;
92- textFormat = "#%06x" ;
93-
107+ textFormat = "#" + prefix + "%06x" ;
94108 } else if ("float" .equals (type )) {
95109 value = newValue = Float .parseFloat (strValue );
96110 strNewValue = strValue ;
@@ -267,7 +281,19 @@ public void sendNewValue() {
267281 } else if ("hex" .equals (type )) {
268282 tweakClient .sendInt (index , newValue .intValue ());
269283 } else if ("webcolor" .equals (type )) {
270- tweakClient .sendInt (index , newValue .intValue ());
284+ // If full opaque color, don't spend the cycles on string processing
285+ // which does appear to matter at high frame rates. Otherwise take the
286+ // hit and parse back from string value with transparency.
287+ if (strNewValue .length () == 7 ) {
288+ tweakClient .sendInt (index , newValue .intValue ());
289+ } else {
290+ long target = Long .parseLong (
291+ strNewValue .substring (1 , strNewValue .length ()),
292+ 16
293+ );
294+ tweakClient .sendInt (index , (int ) target );
295+ }
296+
271297 } else if ("float" .equals (type )) {
272298 tweakClient .sendFloat (index , newValue .floatValue ());
273299 }
0 commit comments