[RFC] [PATCH 4/8] [xserver] dix: add reference count of the resource to ResourceSizeRec
Erkki Seppälä
erkki.seppala at vincit.fi
Mon Dec 27 06:56:58 PST 2010
The ResourceSizeRec now contains the number of references to the
resource. For example a Pixmap knows this value and it can be useful
for determining the "weight" of the resource. Typically this value
is 1.
Reviewed-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
Xext/xres.c | 2 +-
dix/resource.c | 11 +++++++++--
include/resource.h | 2 ++
render/picture.c | 4 +++-
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/Xext/xres.c b/Xext/xres.c
index 7244677..2be60aa 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -298,7 +298,7 @@ static void
ResFindResourcePixmaps (pointer value, XID id, RESTYPE type, pointer cdata)
{
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
- ResourceSizeRec size = { 0, 0 };
+ ResourceSizeRec size = { 0, 0, 0 };
unsigned long *bytes = cdata;
sizeFunc(value, id, &size);
diff --git a/dix/resource.c b/dix/resource.c
index 82d82df..d4db8b2 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -210,6 +210,7 @@ GetDefaultBytes(pointer value, XID id, ResourceSizePtr size)
{
size->resourceSize = 0;
size->pixmapRefSize = 0;
+ size->refCnt = 1;
}
/**
@@ -276,6 +277,7 @@ GetPixmapBytes(pointer value, XID id, ResourceSizePtr size)
size->resourceSize = 0;
size->pixmapRefSize = 0;
+ size->refCnt = pixmap->refcnt;
if (pixmap && pixmap->refcnt)
{
@@ -301,7 +303,7 @@ static void
GetWindowBytes(pointer value, XID id, ResourceSizePtr size)
{
SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
- ResourceSizeRec pixmapSize = { 0, 0 };
+ ResourceSizeRec pixmapSize = { 0, 0, 0 };
WindowPtr window = value;
/* Currently only pixmap bytes are reported to clients. */
@@ -309,6 +311,9 @@ GetWindowBytes(pointer value, XID id, ResourceSizePtr size)
/* Calculate pixmap reference sizes. */
size->pixmapRefSize = 0;
+
+ size->refCnt = 1;
+
if (window->backgroundState == BackgroundPixmap)
{
PixmapPtr pixmap = window->background.pixmap;
@@ -371,7 +376,7 @@ static void
GetGcBytes(pointer value, XID id, ResourceSizePtr size)
{
SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
- ResourceSizeRec pixmapSize = { 0, 0 };
+ ResourceSizeRec pixmapSize = { 0, 0, 0 };
GCPtr gc = value;
/* Currently only pixmap bytes are reported to clients. */
@@ -379,6 +384,8 @@ GetGcBytes(pointer value, XID id, ResourceSizePtr size)
/* Calculate pixmap reference sizes. */
size->pixmapRefSize = 0;
+
+ size->refCnt = 1;
if (gc->stipple)
{
PixmapPtr pixmap = gc->stipple;
diff --git a/include/resource.h b/include/resource.h
index ded49ec..c88c87e 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -144,6 +144,8 @@ typedef struct {
unsigned long resourceSize;
/* Size attributed to pixmap references from the resource. */
unsigned long pixmapRefSize;
+ /* Number of references to this resource; typically 1 */
+ unsigned long refCnt;
} ResourceSizeRec, *ResourceSizePtr;
typedef int (*DeleteType)(
diff --git a/render/picture.c b/render/picture.c
index 64d9b72..d039ee3 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -615,12 +615,14 @@ GetPictureBytes(pointer value, XID id, ResourceSizePtr size)
/* Currently only pixmap bytes are reported to clients. */
size->resourceSize = 0;
+ size->refCnt = picture->refcnt;
+
/* Calculate pixmap reference sizes. */
size->pixmapRefSize = 0;
if (picture->pDrawable && (picture->pDrawable->type == DRAWABLE_PIXMAP))
{
SizeType pixmapSizeFunc = GetResourceTypeSizeFunc(RT_PIXMAP);
- ResourceSizeRec pixmapSize = { 0, 0 };
+ ResourceSizeRec pixmapSize = { 0, 0, 0 };
PixmapPtr pixmap = (PixmapPtr)picture->pDrawable;
pixmapSizeFunc(pixmap, pixmap->drawable.id, &pixmapSize);
size->pixmapRefSize += pixmapSize.pixmapRefSize;
--
1.7.0.4
More information about the xorg-devel
mailing list