From 127328b00c3ceddebeeff6fac59f207a8469f6dc Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 20 Sep 2013 17:35:53 -0700 Subject: [PATCH] Themes: Eliminate some divides. --- src/Cairo_Theme.cxx | 10 ++++++---- src/Fl_Cairo_Graphics_Driver.cxx | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Cairo_Theme.cxx b/src/Cairo_Theme.cxx index 9938bde..c8b3e62 100644 --- a/src/Cairo_Theme.cxx +++ b/src/Cairo_Theme.cxx @@ -34,6 +34,8 @@ bool fl_debug_boxes = false; static const int DX = 1; +#define BSCALE 0.00392156862f + static void cairo_color(Fl_Color c) { cairo_t *cr = Fl::cairo_cc(); @@ -48,7 +50,7 @@ static void cairo_color(Fl_Color c) Fl::get_color( bc, r, g, b ); - cairo_set_source_rgb( cr, r / 255.0, g / 255.0, b / 255.0 ); + cairo_set_source_rgb( cr, r * BSCALE, g * BSCALE, b * BSCALE ); } static void rect_path ( int x, int y, int w, int h, double radius ) @@ -95,9 +97,9 @@ static void draw_rectf(int x, int y, int w, int h, Fl_Color bc, double radius = Fl::get_color( fl_color(), r, g, b ); - float rf = r / 255.0; - float gf = g / 255.0; - float bf = b / 255.0; + float rf = r * BSCALE; + float gf = g * BSCALE; + float bf = b * BSCALE; cairo_pattern_t *grad = 0; diff --git a/src/Fl_Cairo_Graphics_Driver.cxx b/src/Fl_Cairo_Graphics_Driver.cxx index d468852..93bc66a 100644 --- a/src/Fl_Cairo_Graphics_Driver.cxx +++ b/src/Fl_Cairo_Graphics_Driver.cxx @@ -62,6 +62,8 @@ double fl_hwo = 1.0; #define VHO(n) ( n + fl_vho ) #define HWO(n) ( n + fl_hwo ) +#define BSCALE 0.00392156862f + Fl_Color fl_color_add_alpha ( Fl_Color c, uchar alpha ) { if ( !( c & 0xFFFFFF00 ) ) @@ -291,7 +293,7 @@ void Fl_Cairo_Graphics_Driver::color ( uchar r, uchar g, uchar b ) if ( ! cr ) return; - cairo_set_source_rgb( cr, r / 255.0f, g / 255.0f, b / 255.0f ); + cairo_set_source_rgb( cr, r * BSCALE, g * BSCALE, b * BSCALE ); } void fl_set_antialias ( int v ) @@ -331,7 +333,7 @@ void Fl_Cairo_Graphics_Driver::color (uchar r, uchar g, uchar b, uchar a ) if ( ! cr ) return; - cairo_set_source_rgba( cr, r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f ); + cairo_set_source_rgba( cr, r * BSCALE, g * BSCALE, b * BSCALE, a * BSCALE ); } void Fl_Cairo_Graphics_Driver::circle( double x, double y, double r ) -- 2.11.4.GIT