|
commit d51481f95e6a6ee2b2482705e8930aac3e15d7b6
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue Feb 16 11:58:07 2021 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue Feb 16 11:58:15 2021 +0100
Remove FL_CFG_SYS_WIN32 preprocessor variable from fl_draw_pixmap.cxx
FL/Fl_Graphics_Driver.H | 2 +-
src/Fl_Graphics_Driver.cxx | 2 +-
src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 2 +-
src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 32 ++++++++++++++++++
src/fl_draw_pixmap.cxx | 43 ++----------------------
5 files changed, 37 insertions(+), 44 deletions(-)
diff --git FL/Fl_Graphics_Driver.H FL/Fl_Graphics_Driver.H
index 88d1423..2c33212 100644
--- FL/Fl_Graphics_Driver.H
+++ FL/Fl_Graphics_Driver.H
@@ -141,7 +141,7 @@ private:
virtual void draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy);
virtual void draw_fixed(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy);
// the default implementation of make_unused_color_() is most probably enough
- virtual void make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b);
+ virtual void make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b, int color_count, void **data);
// some platforms may need to reimplement this
virtual void set_current_();
float scale_; // scale between FLTK and drawing coordinates: drawing = FLTK * scale_
diff --git src/Fl_Graphics_Driver.cxx src/Fl_Graphics_Driver.cxx
index d33e5e5..ec3cc8d 100644
--- src/Fl_Graphics_Driver.cxx
+++ src/Fl_Graphics_Driver.cxx
@@ -413,7 +413,7 @@ void Fl_Graphics_Driver::draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP
void Fl_Graphics_Driver::draw_fixed(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) {}
-void Fl_Graphics_Driver::make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b) {}
+void Fl_Graphics_Driver::make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b, int color_count, void **data) {}
/** Support function for Fl_Pixmap drawing */
void Fl_Graphics_Driver::cache(Fl_Pixmap *img) { }
diff --git src/drivers/GDI/Fl_GDI_Graphics_Driver.H src/drivers/GDI/Fl_GDI_Graphics_Driver.H
index 01014f4..e2a29da 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver.H
+++ src/drivers/GDI/Fl_GDI_Graphics_Driver.H
@@ -40,7 +40,7 @@ private:
void set_current_();
void draw_fixed(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw_fixed(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
- virtual void make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b);
+ virtual void make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b, int color_count, void **data);
protected:
void draw_fixed(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy);
void cache(Fl_RGB_Image *rgb);
diff --git src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index cf476f7..5bb5157 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -700,6 +700,38 @@ void Fl_GDI_Printer_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP,
}
}
+// Makes an RGB triplet different from all the colors used in the pixmap
+// and computes Fl_Graphics_Driver::need_pixmap_bg_color from this triplet
+void Fl_GDI_Graphics_Driver::make_unused_color_(uchar &r, uchar &g, uchar &b, int color_count, void **data) {
+ typedef struct { uchar r; uchar g; uchar b; } UsedColor;
+ UsedColor *used_colors = *(UsedColor**)data;
+ int i;
+ r = 2; g = 3; b = 4;
+ while (1) {
+ for ( i=0; i<color_count; i++ )
+ if ( used_colors[i].r == r &&
+ used_colors[i].g == g &&
+ used_colors[i].b == b )
+ break;
+ if (i >= color_count) {
+ free((void*)used_colors);
+ *(UsedColor**)data = NULL;
+ need_pixmap_bg_color = RGB(r, g, b);
+ return;
+ }
+ if (r < 255) {
+ r++;
+ } else {
+ r = 0;
+ if (g < 255) {
+ g++;
+ } else {
+ g = 0;
+ b++;
+ }
+ }
+ }
+}
void Fl_GDI_Graphics_Driver::cache(Fl_Pixmap *img) {
Fl_Image_Surface *surf = new Fl_Image_Surface(img->data_w(), img->data_h());
diff --git src/fl_draw_pixmap.cxx src/fl_draw_pixmap.cxx
index f515b86..3384f25 100644
--- src/fl_draw_pixmap.cxx
+++ src/fl_draw_pixmap.cxx
@@ -30,12 +30,8 @@
// The above comments were checked in as r2, and much has changed since then;
// transparency added, color cube not required, etc. -erco Oct 20 2013
-#include "config_lib.h"
#include <FL/Fl.H>
#include "Fl_System_Driver.H"
-#if defined(FL_CFG_SYS_WIN32)
-#include "drivers/GDI/Fl_GDI_Graphics_Driver.H"
-#endif
#include <FL/platform.H>
#include <FL/fl_draw.H>
#include <stdio.h>
@@ -72,41 +68,6 @@ int fl_measure_pixmap(const char * const *cdata, int &w, int &h) {
return 1;
}
-#if defined(FL_CFG_SYS_WIN32)
-
-
-// Makes an RGB triplet different from all the colors used in the pixmap
-// and compute Fl_Graphics_Driver::need_pixmap_bg_color from this triplet
-void Fl_GDI_Graphics_Driver::make_unused_color_(uchar &r, uchar &g, uchar &b) {
- int i;
- r = 2; g = 3; b = 4;
- while (1) {
- for ( i=0; i<color_count; i++ )
- if ( used_colors[i].r == r &&
- used_colors[i].g == g &&
- used_colors[i].b == b )
- break;
- if (i >= color_count) {
- free((void*)used_colors); used_colors = NULL;
- need_pixmap_bg_color = RGB(r, g, b);
- return;
- }
- if (r < 255) {
- r++;
- } else {
- r = 0;
- if (g < 255) {
- g++;
- } else {
- g = 0;
- b++;
- }
- }
- }
-}
-#endif // FL_CFG_SYS_WIN32
-
-
int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
int w, h;
const uchar*const* data = (const uchar*const*)(cdata+1);
@@ -194,10 +155,10 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
} // if ncolors
if (Fl_Graphics_Driver::need_pixmap_bg_color) {
if (transparent_c) {
- fl_graphics_driver->make_unused_color_(transparent_c[0], transparent_c[1], transparent_c[2]);
+ fl_graphics_driver->make_unused_color_(transparent_c[0], transparent_c[1], transparent_c[2], color_count, (void**)&used_colors);
} else {
uchar r, g, b;
- fl_graphics_driver->make_unused_color_(r, g, b);
+ fl_graphics_driver->make_unused_color_(r, g, b, color_count, (void**)&used_colors);
}
}
[ Direct Link to Message ] | |