Skip to content

Commit

Permalink
Renamed internal member variables id and mask to id_ and mask_ to avoid
Browse files Browse the repository at this point in the history
conflict with Mac OS X/gcc 3.x name clash when compiling with obj-c.
Also made them private instead of public.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7273 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Albrecht Schlosser committed Mar 15, 2010
1 parent 99e9c68 commit 186a8f0
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 96 deletions.
14 changes: 10 additions & 4 deletions FL/Fl_Bitmap.H
Expand Up @@ -46,19 +46,25 @@ class FL_EXPORT Fl_Bitmap : public Fl_Image {
const uchar *array;
/** Non-zero if array points to bitmap data allocated internally */
int alloc_array;

private:

#if defined(__APPLE__) || defined(WIN32)
/** for internal use */
void *id;
void *id_;
#else
/** for internal use */
unsigned id;
unsigned id_;
#endif // __APPLE__ || WIN32

public:

/** The constructors create a new bitmap from the specified bitmap data */
Fl_Bitmap(const uchar *bits, int W, int H) :
Fl_Image(W,H,0), array(bits), alloc_array(0), id(0) {data((const char **)&array, 1);}
Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0) {data((const char **)&array, 1);}
/** The constructors create a new bitmap from the specified bitmap data */
Fl_Bitmap(const char *bits, int W, int H) :
Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id(0) {data((const char **)&array, 1);}
Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0) {data((const char **)&array, 1);}
virtual ~Fl_Bitmap();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
Expand Down
15 changes: 10 additions & 5 deletions FL/Fl_Image.H
Expand Up @@ -193,16 +193,21 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image {
const uchar *array;
int alloc_array; // Non-zero if array was allocated

private:

#if defined(__APPLE__) || defined(WIN32)
void *id; // for internal use
void *mask; // for internal use (mask bitmap)
void *id_; // for internal use
void *mask_; // for internal use (mask bitmap)
#else
unsigned id; // for internal use
unsigned mask; // for internal use (mask bitmap)
unsigned id_; // for internal use
unsigned mask_; // for internal use (mask bitmap)
#endif // __APPLE__ || WIN32

public:

/** The constructor creates a new image from the specified data. */
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) :
Fl_Image(W,H,D), array(bits), alloc_array(0), id(0), mask(0) {data((const char **)&array, 1); ld(LD);}
Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);}
virtual ~Fl_RGB_Image();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
Expand Down
21 changes: 13 additions & 8 deletions FL/Fl_Pixmap.H
Expand Up @@ -56,22 +56,27 @@ class FL_EXPORT Fl_Pixmap : public Fl_Image {
public:

int alloc_data; // Non-zero if data was allocated

private:

#if defined(__APPLE__) || defined(WIN32)
void *id; // for internal use
void *mask; // for internal use (mask bitmap)
void *id_; // for internal use
void *mask_; // for internal use (mask bitmap)
#else
unsigned id; // for internal use
unsigned mask; // for internal use (mask bitmap)
unsigned id_; // for internal use
unsigned mask_; // for internal use (mask bitmap)
#endif // __APPLE__ || WIN32

public:

/** The constructors create a new pixmap from the specified XPM data. */
explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();}
virtual ~Fl_Pixmap();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
Expand Down
56 changes: 28 additions & 28 deletions src/Fl_Bitmap.cxx
Expand Up @@ -52,12 +52,12 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
*dst++ = ((reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f))^0xff;
}
CGDataProviderRef srcp = CGDataProviderCreateWithData( 0L, bmask, rowBytes*h, 0L);
CGImageRef id = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
CGImageRef id_ = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
CGDataProviderRelease(srcp);
return (Fl_Bitmask)id;
return (Fl_Bitmask)id_;
}
void fl_delete_bitmask(Fl_Bitmask id) {
if (id) CGImageRelease((CGImageRef)id);
void fl_delete_bitmask(Fl_Bitmask bm) {
if (bm) CGImageRelease((CGImageRef)bm);
}
#elif defined(WIN32) // Windows bitmask functions...
// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
Expand All @@ -69,7 +69,7 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
Fl_Bitmask id;
Fl_Bitmask bm;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
Expand All @@ -81,18 +81,18 @@ static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
dest += w2-w1;
}

id = CreateBitmap(w, h, 1, 1, newarray);
bm = CreateBitmap(w, h, 1, 1, newarray);

delete[] newarray;

return id;
return bm;
}

// 'fl_create_bitmask()' - Create an N-bit bitmap for masking...
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
// this won't work when the user changes display mode during run or
// has two screens with differnet depths
Fl_Bitmask id;
Fl_Bitmask bm;
static uchar hiNibble[16] =
{ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0 };
Expand Down Expand Up @@ -141,10 +141,10 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
dst += pad;
}

id = CreateBitmap(w, h, np, bpp, newarray);
bm = CreateBitmap(w, h, np, bpp, newarray);
delete[] newarray;

return id;
return bm;
}

#if 0 // This doesn't appear to be used anywhere...
Expand All @@ -156,7 +156,7 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data, int for_mask) {
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
Fl_Bitmask id;
Fl_Bitmask bm;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
Expand All @@ -168,11 +168,11 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data, int for_mask) {
dest += w2-w1;
}

id = CreateBitmap(w, h, 1, 1, newarray);
bm = CreateBitmap(w, h, 1, 1, newarray);

delete[] newarray;

return (id);
return bm;
}
# endif // 0

Expand All @@ -193,7 +193,7 @@ void fl_delete_bitmask(Fl_Bitmask bm) {

// Create a 1-bit mask used for alpha blending
Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) {
Fl_Bitmask mask;
Fl_Bitmask bm;
int bmw = (w + 7) / 8;
uchar *bitmap = new uchar[bmw * h];
uchar *bitptr, bit;
Expand Down Expand Up @@ -258,10 +258,10 @@ Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array)
}
}

mask = fl_create_bitmask(w, h, bitmap);
bm = fl_create_bitmask(w, h, bitmap);
delete[] bitmap;

return (mask);
return (bm);
}

void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
Expand All @@ -286,17 +286,17 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (H <= 0) return;

#if defined(USE_X11)
if (!id) id = fl_create_bitmask(w(), h(), array);
if (!id_) id_ = fl_create_bitmask(w(), h(), array);

XSetStipple(fl_display, fl_gc, id);
XSetStipple(fl_display, fl_gc, id_);
int ox = X-cx; if (ox < 0) ox += w();
int oy = Y-cy; if (oy < 0) oy += h();
XSetTSOrigin(fl_display, fl_gc, ox, oy);
XSetFillStyle(fl_display, fl_gc, FillStippled);
XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H);
XSetFillStyle(fl_display, fl_gc, FillSolid);
#elif defined(WIN32)
if (!id) id = fl_create_bitmap(w(), h(), array);
if (!id_) id_ = fl_create_bitmap(w(), h(), array);

typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static fl_transp_func fl_TransparentBlt;
Expand Down Expand Up @@ -326,7 +326,7 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
fl_color(save_c); // back to bitmap's color
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
SelectObject(tempdc, (HGDIOBJ)id);
SelectObject(tempdc, (HGDIOBJ)id_);
SelectObject(fl_gc, fl_brush()); // use bitmap's desired color
BitBlt(fl_gc, 0, 0, W, H, tempdc, 0, 0, 0xE20746L); // draw bitmap to offscreen
fl_end_offscreen(); // offscreen data is in tmp_id
Expand All @@ -338,19 +338,19 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
else { // algorithm for bitmap output to display
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
SelectObject(tempdc, (HGDIOBJ)id);
SelectObject(tempdc, (HGDIOBJ)id_);
SelectObject(fl_gc, fl_brush());
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
}
RestoreDC(tempdc, save);
DeleteDC(tempdc);
#elif defined(__APPLE_QUARTZ__)
if (!id) id = fl_create_bitmask(w(), h(), array);
if (id && fl_gc) {
if (!id_) id_ = fl_create_bitmask(w(), h(), array);
if (id_ && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, w(), h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
CGContextDrawImage(fl_gc, rect, (CGImageRef)id_);
Fl_X::q_end_image();
}
#else
Expand All @@ -368,13 +368,13 @@ Fl_Bitmap::~Fl_Bitmap() {
}

void Fl_Bitmap::uncache() {
if (id) {
if (id_) {
#if defined(__APPLE__) && defined(__APPLE_COCOA__)
fl_delete_bitmask((Fl_Bitmask)id);
fl_delete_bitmask((Fl_Bitmask)id_);
#else
fl_delete_bitmask((Fl_Offscreen)id);
fl_delete_bitmask((Fl_Offscreen)id_);
#endif
id = 0;
id_ = 0;
}
}

Expand Down

0 comments on commit 186a8f0

Please sign in to comment.