Skip to content

Commit

Permalink
include cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyhughes committed Oct 23, 2003
1 parent 12c3480 commit a1c2cda
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 54 deletions.
19 changes: 10 additions & 9 deletions lib/Font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

extern "C" {
#include "Font.hh"
#include "Color.hh"
#include "Display.hh"
#include "Pen.hh"
#include "Resource.hh"
#include "i18n.hh"

#ifdef XFT
# include <X11/Xft/Xft.h>
#endif
#include <assert.h>
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
}

#include <map>
#include <vector>

#include "Font.hh"
#include "Color.hh"
#include "Display.hh"
#include "Pen.hh"
#include "Resource.hh"
#include "i18n.hh"

// #define FONTCACHE_DEBUG

static const char * const defaultFont = "fixed";
Expand Down
15 changes: 3 additions & 12 deletions lib/Font.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@
#ifndef __Font_hh
#define __Font_hh

extern "C" {
#include <X11/Xlib.h>
#ifdef XFT
# include <X11/Xft/Xft.h>
#endif
}

#include <string>
typedef struct _XftFont XftFont;

#include <string>

namespace bt {

// forward declarations
class Display;
class Pen;
class Rect;
Expand All @@ -61,9 +58,7 @@ namespace bt {

XFontSet fontset(void) const;
XFontStruct *font(void) const;
#ifdef XFT
XftFont *xftFont(unsigned int screen) const;
#endif

Font& operator=(const Font &f)
{ setFontName(f.fontName()); return *this; }
Expand All @@ -78,11 +73,7 @@ namespace bt {
std::string _fontname;
mutable XFontSet _fontset;
mutable XFontStruct *_font;
#ifdef XFT
mutable XftFont *_xftfont;
#else
void *_xftfont; // avoid breaking binary compatibility...
#endif
mutable unsigned int _screen; // only used for Xft
};

Expand Down
2 changes: 2 additions & 0 deletions lib/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "Pen.hh"
#include "Texture.hh"

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef MITSHM
# include <sys/types.h>
# include <sys/ipc.h>
Expand Down
30 changes: 14 additions & 16 deletions lib/Pen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H

extern "C" {
#include <stdio.h>
}

#include <algorithm>

#include "Pen.hh"
#include "Display.hh"
#include "Color.hh"
#include "Font.hh"
#include "Util.hh"

#include <X11/Xlib.h>
#ifdef XFT
# include <X11/Xft/Xft.h>
#endif

#include <stdio.h>

#include <algorithm>


static const unsigned int cache_size = 32u;
static const unsigned int cache_buckets = 8u;
Expand Down Expand Up @@ -481,10 +480,7 @@ void bt::PenCache::release(XftCacheItem *xftitem) {
bt::Pen::Pen(unsigned int screen_, const Color &color_,
int function, int subwindow)
: _screen(screen_), _color(color_), _fontid(0ul),
_function(function), _subwindow(subwindow), _item(0)
#ifdef XFT
, _xftitem(0)
#endif
_function(function), _subwindow(subwindow), _item(0), _xftitem(0)
{ }


Expand Down Expand Up @@ -519,8 +515,8 @@ const GC &bt::Pen::gc(void) const {
}


#ifdef XFT
XftDraw *bt::Pen::xftDraw(Drawable drawable) const {
#ifdef XFT
if (_xftitem && _xftitem->drawable() != drawable) {
pencache->release(_xftitem);
_xftitem = 0;
Expand All @@ -529,7 +525,9 @@ XftDraw *bt::Pen::xftDraw(Drawable drawable) const {
_xftitem = pencache->findXft(_screen, drawable);
}
return _xftitem->xftdraw();
}
#else
return 0;
#endif
}

void bt::Pen::clearCache(void) { pencache->purge(); }
22 changes: 5 additions & 17 deletions lib/Pen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,21 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#ifndef GCCACHE_HH
#define GCCACHE_HH
#ifndef __Pen_hh
#define __Pen_hh

#include "Util.hh"

#ifdef XFT
extern "C" {
#include <X11/Xft/Xft.h>
}
#endif
typedef struct _XftDraw XftDraw;

namespace bt {

// forward declarations
class Color;
class Display;
class Font;
class PenCacheItem;
#ifdef XFT
class XftCacheItem;
#endif

class Pen : public NoCopy {
public:
Expand All @@ -59,9 +54,7 @@ namespace bt {
const Display &display(void) const;
const GC &gc(void) const;

#ifdef XFT
XftDraw *xftDraw(Drawable drawable) const;
#endif

private:
unsigned int _screen;
Expand All @@ -72,14 +65,9 @@ namespace bt {
int _subwindow;

mutable PenCacheItem *_item;

#ifdef XFT
mutable XftCacheItem *_xftitem;
#else
void *_xftitem; // avoid breaking binary compatibility...
#endif
};

} // namespace bt

#endif // GCCACHE_HH
#endif // __Pen_hh

0 comments on commit a1c2cda

Please sign in to comment.