r=pocemit, sr=darin
Checkin for Roland.Mainz@informatik.med.uni-giessen.de - rename of class
This commit is contained in:
mkaply%us.ibm.com 2001-06-26 00:11:17 +00:00
Родитель 17ee52513f
Коммит 958b057933
6 изменённых файлов: 31 добавлений и 40 удалений

Просмотреть файл

@ -32,14 +32,14 @@
/* The GC cache is shared among all windows, since it doesn't hog /* The GC cache is shared among all windows, since it doesn't hog
any scarce resources (like colormap entries.) */ any scarce resources (like colormap entries.) */
Region nsGCCache::copyRegion = 0; Region nsGCCacheXlib::copyRegion = 0;
nsGCCache::nsGCCache() nsGCCacheXlib::nsGCCacheXlib()
{ {
PR_INIT_CLIST(&GCCache); PR_INIT_CLIST(&GCCache);
PR_INIT_CLIST(&GCFreeList); PR_INIT_CLIST(&GCFreeList);
for (int i = 0; i < GC_CACHE_SIZE; i++) { for (int i = 0; i < GC_CACHE_SIZE; i++) {
GCCacheEntry *entry = new GCCacheEntry(); GCCacheEntryXlib *entry = new GCCacheEntryXlib();
entry->gc=NULL; entry->gc=NULL;
PR_INSERT_LINK(&entry->clist, &GCFreeList); PR_INSERT_LINK(&entry->clist, &GCFreeList);
} }
@ -47,7 +47,7 @@ nsGCCache::nsGCCache()
} }
void void
nsGCCache::move_cache_entry(PRCList *clist) nsGCCacheXlib::move_cache_entry(PRCList *clist)
{ {
/* thread on the freelist, at the front */ /* thread on the freelist, at the front */
PR_REMOVE_LINK(clist); PR_REMOVE_LINK(clist);
@ -55,9 +55,9 @@ nsGCCache::move_cache_entry(PRCList *clist)
} }
void void
nsGCCache::free_cache_entry(PRCList *clist) nsGCCacheXlib::free_cache_entry(PRCList *clist)
{ {
GCCacheEntry *entry = (GCCacheEntry *)clist; GCCacheEntryXlib *entry = (GCCacheEntryXlib *)clist;
entry->gc->Release(); entry->gc->Release();
if (entry->clipRegion) if (entry->clipRegion)
::XDestroyRegion(entry->clipRegion); ::XDestroyRegion(entry->clipRegion);
@ -68,7 +68,7 @@ nsGCCache::free_cache_entry(PRCList *clist)
PR_INSERT_LINK(clist, &GCFreeList); PR_INSERT_LINK(clist, &GCFreeList);
} }
nsGCCache::~nsGCCache() nsGCCacheXlib::~nsGCCacheXlib()
{ {
PRCList *head; PRCList *head;
@ -86,12 +86,12 @@ nsGCCache::~nsGCCache()
if (head == &GCFreeList) if (head == &GCFreeList)
break; break;
PR_REMOVE_LINK(head); PR_REMOVE_LINK(head);
delete (GCCacheEntry *)head; delete (GCCacheEntryXlib *)head;
} }
} }
void void
nsGCCache::ReportStats() { nsGCCacheXlib::ReportStats() {
DEBUG_METER( DEBUG_METER(
fprintf(stderr, "GC Cache:\n\thits:"); fprintf(stderr, "GC Cache:\n\thits:");
int hits = 0; int hits = 0;
@ -109,35 +109,35 @@ nsGCCache::ReportStats() {
void void
nsGCCache::XCopyRegion(Region srca, Region dr_return) nsGCCacheXlib::XCopyRegion(Region srca, Region dr_return)
{ {
if (!copyRegion) copyRegion = ::XCreateRegion(); if (!copyRegion) copyRegion = ::XCreateRegion();
::XUnionRegion(srca, copyRegion, dr_return); ::XUnionRegion(srca, copyRegion, dr_return);
} }
/* Dispose of entries matching the given flags, compressing the GC cache */ /* Dispose of entries matching the given flags, compressing the GC cache */
void nsGCCache::Flush(unsigned long flags) void nsGCCacheXlib::Flush(unsigned long flags)
{ {
while (!PR_CLIST_IS_EMPTY(&GCCache)) { while (!PR_CLIST_IS_EMPTY(&GCCache)) {
PRCList *head = PR_LIST_HEAD(&GCCache); PRCList *head = PR_LIST_HEAD(&GCCache);
if (head == &GCCache) if (head == &GCCache)
break; break;
GCCacheEntry *entry = (GCCacheEntry *)head; GCCacheEntryXlib *entry = (GCCacheEntryXlib *)head;
if (entry->flags & flags) if (entry->flags & flags)
free_cache_entry(head); free_cache_entry(head);
} }
} }
xGC *nsGCCache::GetGC(Display *display, Drawable drawable, unsigned long flags, XGCValues *gcv, Region clipRegion) xGC *nsGCCacheXlib::GetGC(Display *display, Drawable drawable, unsigned long flags, XGCValues *gcv, Region clipRegion)
{ {
PRCList *iter; PRCList *iter;
GCCacheEntry *entry; GCCacheEntryXlib *entry;
DEBUG_METER(int i = 0;) DEBUG_METER(int i = 0;)
for (iter = PR_LIST_HEAD(&GCCache); iter != &GCCache; for (iter = PR_LIST_HEAD(&GCCache); iter != &GCCache;
iter = PR_NEXT_LINK(iter)) { iter = PR_NEXT_LINK(iter)) {
entry = (GCCacheEntry *)iter; entry = (GCCacheEntryXlib *)iter;
if (flags == entry->flags && if (flags == entry->flags &&
!memcmp (gcv, &entry->gcv, sizeof (*gcv))) { !memcmp (gcv, &entry->gcv, sizeof (*gcv))) {
/* if there's a clipRegion, we have to match */ /* if there's a clipRegion, we have to match */
@ -172,7 +172,7 @@ xGC *nsGCCache::GetGC(Display *display, Drawable drawable, unsigned long flags,
iter = PR_LIST_HEAD(&GCFreeList); iter = PR_LIST_HEAD(&GCFreeList);
PR_REMOVE_LINK(iter); PR_REMOVE_LINK(iter);
PR_INSERT_LINK(iter, &GCCache); PR_INSERT_LINK(iter, &GCCache);
entry = (GCCacheEntry *)iter; entry = (GCCacheEntryXlib *)iter;
if (!entry->gc) { if (!entry->gc) {
// No old GC, greate new // No old GC, greate new
@ -209,7 +209,7 @@ xGC *nsGCCache::GetGC(Display *display, Drawable drawable, unsigned long flags,
return entry->gc; return entry->gc;
} }
void nsGCCache::ReuseGC(GCCacheEntry *entry, unsigned long flags, XGCValues *gcv) void nsGCCacheXlib::ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv)
{ {
// We have old GC, reuse it and check what // We have old GC, reuse it and check what
// we have to change // we have to change

Просмотреть файл

@ -23,8 +23,8 @@
*/ */
#ifndef nsGCCache_h___ #ifndef nsGCCacheXlib_h___
#define nsGCCache_h___ #define nsGCCacheXlib_h___
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -35,9 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#define countof(x) ((int)(sizeof(x) / sizeof (*x))) #define countof(x) ((int)(sizeof(x) / sizeof (*x)))
#define GC_CACHE_SIZE 10 #define GC_CACHE_SIZE 16
#define DEBUG 1
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_METER(x) x #define DEBUG_METER(x) x
@ -45,15 +43,10 @@
#define DEBUG_METER(x) #define DEBUG_METER(x)
#endif #endif
#ifdef _IMPL_NS_XPRINT class nsGCCacheXlib;
#define nsGCCache nsGCCacheXlib
#define GCCacheEntry GCCacheEntryXlib
#endif
class nsGCCache;
class xGC { class xGC {
friend class nsGCCache; friend class nsGCCacheXlib;
public: public:
xGC(Display *display, Drawable d, unsigned long valuemask, XGCValues *values) xGC(Display *display, Drawable d, unsigned long valuemask, XGCValues *values)
@ -94,7 +87,7 @@ private:
}; };
struct GCCacheEntry struct GCCacheEntryXlib
{ {
PRCList clist; PRCList clist;
unsigned long flags; unsigned long flags;
@ -103,18 +96,18 @@ struct GCCacheEntry
xGC *gc; xGC *gc;
}; };
class nsGCCache class nsGCCacheXlib
{ {
public: public:
nsGCCache(); nsGCCacheXlib();
virtual ~nsGCCache(); virtual ~nsGCCacheXlib();
void Flush(unsigned long flags); void Flush(unsigned long flags);
xGC *GetGC(Display *display, Window window, unsigned long flags, XGCValues *gcv, Region clipRegion); xGC *GetGC(Display *display, Window window, unsigned long flags, XGCValues *gcv, Region clipRegion);
private: private:
void ReuseGC(GCCacheEntry *entry, unsigned long flags, XGCValues *gcv); void ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv);
PRCList GCCache; PRCList GCCache;
PRCList GCFreeList; PRCList GCFreeList;
void free_cache_entry(PRCList *clist); void free_cache_entry(PRCList *clist);

Просмотреть файл

@ -37,7 +37,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsRenderingContextXlib, nsIRenderingContext)
static PRLogModuleInfo * RenderingContextXlibLM = PR_NewLogModule("RenderingContextXlib"); static PRLogModuleInfo * RenderingContextXlibLM = PR_NewLogModule("RenderingContextXlib");
static nsGCCache *gcCache = nsnull; static nsGCCacheXlib *gcCache = nsnull;
class GraphicsState class GraphicsState
{ {
@ -401,7 +401,7 @@ void nsRenderingContextXlib::UpdateGC()
} }
if (!gcCache) { if (!gcCache) {
gcCache = new nsGCCache(); gcCache = new nsGCCacheXlib();
if (!gcCache) return; if (!gcCache) return;
} }

Просмотреть файл

@ -40,7 +40,7 @@ static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
static PRLogModuleInfo *RenderingContextXpLM = PR_NewLogModule("nsRenderingContextXp"); static PRLogModuleInfo *RenderingContextXpLM = PR_NewLogModule("nsRenderingContextXp");
#endif /* PR_LOGGING */ #endif /* PR_LOGGING */
static nsGCCache *gcCache = nsnull; static nsGCCacheXlib *gcCache = nsnull;
class GraphicsState class GraphicsState
{ {
@ -417,7 +417,7 @@ void nsRenderingContextXp::UpdateGC()
} }
if (!gcCache) { if (!gcCache) {
gcCache = new nsGCCache(); gcCache = new nsGCCacheXlib();
if (!gcCache) return; if (!gcCache) return;
} }

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsVoidArray.h" #include "nsVoidArray.h"
#include "nsRegionXlib.h" #include "nsRegionXlib.h"
#include "nsImageXlib.h" // nsGCCache.h wants this
#include "nsGCCache.h" #include "nsGCCache.h"
class nsXPrintContext; class nsXPrintContext;

Просмотреть файл

@ -35,7 +35,6 @@
#include "nsString.h" #include "nsString.h"
#include "nsIImage.h" #include "nsIImage.h"
#include "nsImageXlib.h" // nsGCCache.h wants this
#include "nsGCCache.h" #include "nsGCCache.h"
#include "nsIDeviceContextSpecXPrint.h" #include "nsIDeviceContextSpecXPrint.h"