[dasher] Replace my_cairo_colour_t with cairo_pattern_t.



commit 0b8b1abde54cb34ab550b30edacf0fbc56a59920
Author: Patrick Welche <prlw1 cam ac uk>
Date:   Fri Feb 26 12:25:27 2010 +0000

    Replace my_cairo_colour_t with cairo_pattern_t.

 ChangeLog           |    4 ++++
 Src/Gtk2/Canvas.cpp |   10 ++++++----
 Src/Gtk2/Canvas.h   |   13 ++-----------
 3 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f5c0cf4..5b374d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-02-26  Patrick Welche <prlw1 cam ac uk>
+
+	* Replace my_cairo_colour_t with cairo_pattern_t.
+
 2009-02-17  Patrick Welche <prlw1 cam ac uk>
 
 	* Move --enable-nls fix into configure.ac, as intltoolize replaces
diff --git a/Src/Gtk2/Canvas.cpp b/Src/Gtk2/Canvas.cpp
index 3e6d8a8..46da872 100644
--- a/Src/Gtk2/Canvas.cpp
+++ b/Src/Gtk2/Canvas.cpp
@@ -455,7 +455,7 @@ void CCanvas::SetColourScheme(const CColourIO::ColourInfo *pColourScheme) {
 #if WITH_CAIRO
   if (cairo_colours)
     delete[] cairo_colours;
-  cairo_colours = new my_cairo_colour_t[iNumColours];
+  cairo_colours = new cairo_pattern_t*[iNumColours];
 #else
   if (colours)
     delete[] colours;
@@ -464,9 +464,11 @@ void CCanvas::SetColourScheme(const CColourIO::ColourInfo *pColourScheme) {
 
   for(int i = 0; i < iNumColours; i++) {
 #if WITH_CAIRO
-    cairo_colours[i].r = pColourScheme->Reds[i] / 255.0;
-    cairo_colours[i].g = pColourScheme->Greens[i] / 255.0;
-    cairo_colours[i].b = pColourScheme->Blues[i] / 255.0;
+    cairo_colours[i] = cairo_pattern_create_rgb (
+      pColourScheme->Reds[i]   / 255.0,
+      pColourScheme->Greens[i] / 255.0,
+      pColourScheme->Blues[i]  / 255.0
+    );
 #else
     colours[i].pixel=0;
     colours[i].red=pColourScheme->Reds[i]*257;
diff --git a/Src/Gtk2/Canvas.h b/Src/Gtk2/Canvas.h
index 45039b6..d0cbb41 100644
--- a/Src/Gtk2/Canvas.h
+++ b/Src/Gtk2/Canvas.h
@@ -17,11 +17,6 @@
 /* Cairo drawing backend */
 #include <gdk/gdkcairo.h>
 
-typedef struct {
-  double r, g, b;
-} my_cairo_colour_t;
-
-
 #define BEGIN_DRAWING_BACKEND				\
   cairo_save(cr)
 
@@ -29,10 +24,7 @@ typedef struct {
   cairo_restore(cr)
 
 #define SET_COLOR_BACKEND(c)				\
-  do {							\
-    my_cairo_colour_t _c = cairo_colours[(c)];		\
-    cairo_set_source_rgb(cr, _c.r, _c.g, _c.b);	\
-  } while (0)
+  cairo_set_source(cr, cairo_colours[(c)])
 
 #else /* WITHOUT_CAIRO */
 
@@ -304,10 +296,9 @@ private:
 #if WITH_CAIRO
   cairo_t *display_cr;
   cairo_t *decoration_cr;
-  //cairo_t *onscreen_cr; // TODO: do we need to do our own double buffering?
 
   cairo_t *cr; // offscreen
-  my_cairo_colour_t *cairo_colours;
+  cairo_pattern_t **cairo_colours;
 #else
   GdkColor *colours;
 #endif  



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