summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-07 17:38:30 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-07 17:39:27 -0800
commit8acbf8a86d4421356dca6d4892e1652043583dfc (patch)
tree12c49f010e829f85409b6541e2e699a18aa4c7c3
parentfe6483c2305ccd2fde0f433a42af2715def33fff (diff)
Add support for DAMAGE extension versions 1.0 & 1.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--COPYING3
-rw-r--r--Makefile.am5
-rw-r--r--damagescope.h61
-rw-r--r--decode_damage.c165
-rw-r--r--extensions.c3
-rw-r--r--extensions.h3
-rw-r--r--man/xscope.man2
-rw-r--r--print_damage.c132
-rw-r--r--x11.h8
9 files changed, 375 insertions, 7 deletions
diff --git a/COPYING b/COPYING
index 1b509fc..2193f2c 100644
--- a/COPYING
+++ b/COPYING
@@ -65,8 +65,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Copyright © 2000, 2001 Keith Packard, member of The XFree86 Project, Inc.
Copyright © 2010 Intel Corporation
-Copyright (c) 2002, 2009, 2012, Oracle and/or its affiliates.
-All rights reserved.
+Copyright (c) 2002, 2023, Oracle and/or its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
diff --git a/Makefile.am b/Makefile.am
index bfd6fc6..1bc52c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+# Copyright (c) 2008, 2023, Oracle and/or its affiliates.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -32,8 +32,10 @@ xscope_SOURCES = \
audio.c \
bigreqscope.h \
common.c \
+ damagescope.h \
decode11.c \
decode_bigreq.c \
+ decode_damage.c \
decode_glx.c \
decode_lbx.c \
decode_randr.c \
@@ -51,6 +53,7 @@ xscope_SOURCES = \
peerinfo.c \
print11.c \
print_bigreq.c \
+ print_damage.c \
print_glx.c \
print_lbx.c \
print_randr.c \
diff --git a/damagescope.h b/damagescope.h
new file mode 100644
index 0000000..612c7ad
--- /dev/null
+++ b/damagescope.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DAMAGESCOPE_H_
+#define _DAMAGESCOPE_H_
+
+#define DAMAGEREQUESTHEADER "DAMAGEREQUEST"
+#define DAMAGEREPLYHEADER "DAMAGEREPLY"
+#define DAMAGEEVENTHEADER "DAMAGEEVENT"
+
+/*
+ Aliases for types for Damage to x11.h types - used for types we don't
+ have specialized printing routines for now, but may want to someday.
+*/
+#define DAMAGE CARD32 /* XID */
+#define REGION CARD32 /* XID */
+
+/*
+ To aid in making the choice between level 1 and level 2, we
+ define the following define, which does not print relatively
+ unimportant fields.
+*/
+
+#define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e)
+
+/* Damage 1.0 */
+extern void DamageQueryVersion(FD fd, const unsigned char *buf);
+extern void DamageQueryVersionReply(FD fd, const unsigned char *buf);
+
+extern void DamageCreate(FD fd, const unsigned char *buf);
+extern void DamageDestroy(FD fd, const unsigned char *buf);
+extern void DamageSubtract(FD fd, const unsigned char *buf);
+
+extern void DamageNotifyEvent(const unsigned char *buf);
+
+extern void DamageBadDamageError(FD fd, const unsigned char *buf);
+
+/* Damage 1.1 addition */
+extern void DamageAdd(FD fd, const unsigned char *buf);
+
+#endif
diff --git a/decode_damage.c b/decode_damage.c
new file mode 100644
index 0000000..62407cd
--- /dev/null
+++ b/decode_damage.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scope.h"
+#include "x11.h"
+#include "damagescope.h"
+#include "extensions.h"
+
+static unsigned char DAMAGERequest, DAMAGEError, DAMAGEEvent;
+
+#define DAMAGENError 1 /* as of DAMAGE 1.1 */
+
+static void
+damage_decode_req(FD fd, const unsigned char *buf)
+{
+ short Major = IByte(&buf[0]);
+ short Minor = IByte(&buf[1]);
+
+ switch (Minor) {
+/* Damage 1.0 requests */
+ case 0:
+ DamageQueryVersion(fd, buf);
+ ExtendedReplyExpected(fd, Major, Minor);
+ break;
+ case 1:
+ DamageCreate(fd, buf);
+ break;
+ case 2:
+ DamageDestroy(fd, buf);
+ break;
+ case 3:
+ DamageSubtract(fd, buf);
+ break;
+/* Damage 1.1 addition */
+ case 4:
+ DamageAdd(fd, buf);
+ break;
+
+ default:
+ ExtendedRequest(fd, buf);
+ ExtendedReplyExpected(fd, Major, Minor);
+ break;
+ }
+}
+
+static void
+damage_decode_reply(FD fd, const unsigned char *buf, short RequestMinor)
+{
+ switch (RequestMinor) {
+/* Damage 1.0 replies */
+ case 0:
+ DamageQueryVersionReply(fd, buf);
+ break;
+
+ default:
+ UnknownReply(buf);
+ break;
+ }
+}
+
+static void
+damage_decode_event(FD fd, const unsigned char *buf)
+{
+ short event = IByte(&buf[0]) - DAMAGEEvent;
+
+ switch (event) {
+/* Damage 1.0 events */
+ case 0:
+ DamageNotifyEvent(buf);
+ break;
+
+ default:
+ UnknownEvent(buf);
+ break;
+ }
+}
+
+static void
+damage_decode_error(FD fd, const unsigned char *buf)
+{
+ short error = IByte(&buf[1]) - DAMAGEError;
+
+ switch (error) {
+/* Damage 1.0 error */
+ case 0:
+ DamageBadDamageError(fd, buf);
+ break;
+
+ default:
+ UnknownError(buf);
+ break;
+ }
+}
+
+void
+InitializeDAMAGE(const unsigned char *buf)
+{
+ TYPE p;
+
+ DAMAGERequest = (unsigned char) (buf[9]);
+ DAMAGEEvent = (unsigned char) (buf[10]);
+ DAMAGEError = (unsigned char) (buf[11]);
+
+ DefineEValue(&TD[REQUEST], (unsigned long) DAMAGERequest, "DamageRequest");
+ DefineEValue(&TD[REPLY], (unsigned long) DAMAGERequest, "DamageReply");
+ DefineEValue(&TD[EVENT], (unsigned long) DAMAGEEvent, "DamageNotify");
+
+ DefineEValue(&TD[ERROR], (unsigned long) DAMAGEError + 0, "BadDamage");
+
+ p = DefineType(DAMAGEREQUEST, ENUMERATED, "DAMAGEREQUEST",
+ (PrintProcType) PrintENUMERATED);
+ DefineEValue(p, 0L, "DamageQueryVersion");
+ DefineEValue(p, 1L, "DamageCreate");
+ DefineEValue(p, 2L, "DamageDestroy");
+ DefineEValue(p, 3L, "DamageSubtract");
+ DefineEValue(p, 4L, "DamageAdd");
+
+ p = DefineType(DAMAGEREPLY, ENUMERATED, "DAMAGEREPLY",
+ (PrintProcType) PrintENUMERATED);
+ DefineEValue(p, 0L, "QueryVersion");
+
+ p = DefineType(DAMAGEEVENT, ENUMERATED, "DAMAGEEVENT",
+ (PrintProcType) PrintENUMERATED);
+ DefineEValue(p, 0L, "DamageNotify");
+
+ p = DefineType(DAMAGEREPORTLEVEL, ENUMERATED, "DAMAGEREPORTLEVEL",
+ (PrintProcType) PrintENUMERATED);
+ DefineEValue(p, 0L, "ReportRawRectangles");
+ DefineEValue(p, 1L, "ReportDeltaRectangles");
+ DefineEValue(p, 2L, "ReportBoundingBox");
+ DefineEValue(p, 3L, "ReportNonEmpty");
+ DefineEValue(p, 0x80L, "ReportRawRectangles & DamageNotifyMore");
+ DefineEValue(p, 0x81L, "ReportDeltaRectangles & DamageNotifyMore");
+ DefineEValue(p, 0x82L, "ReportBoundingBox & DamageNotifyMore");
+ DefineEValue(p, 0x83L, "ReportNonEmpty & DamageNotifyMore");
+
+ InitializeExtensionDecoder(DAMAGERequest, damage_decode_req,
+ damage_decode_reply);
+ InitializeExtensionEventDecoder(DAMAGEEvent, damage_decode_event);
+ InitializeExtensionErrorDecoder(DAMAGEError, damage_decode_error);
+}
diff --git a/extensions.c b/extensions.c
index 53b45b3..1407e8b 100644
--- a/extensions.c
+++ b/extensions.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2023, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -37,6 +37,7 @@ struct extension_decoders {
static const struct extension_decoders decodable_extensions[] = {
{"BIG-REQUESTS", InitializeBIGREQ},
+ {"DAMAGE", InitializeDAMAGE},
{"LBX", InitializeLBX},
{"MIT-SHM", InitializeMITSHM},
{"NCD-WinCenterPro", InitializeWCP},
diff --git a/extensions.h b/extensions.h
index df2d5ec..489fea5 100644
--- a/extensions.h
+++ b/extensions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2023, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -47,6 +47,7 @@ extern void ExtensionEvent(FD fd, const unsigned char *buf, short Event);
/* X11 Extension decoders in decode_*.c */
extern void InitializeBIGREQ(const unsigned char *buf);
+extern void InitializeDAMAGE(const unsigned char *buf);
extern void InitializeGLX(const unsigned char *buf);
extern void InitializeLBX(const unsigned char *buf);
extern void InitializeMITSHM(const unsigned char *buf);
diff --git a/man/xscope.man b/man/xscope.man
index 6163f60..2bb316b 100644
--- a/man/xscope.man
+++ b/man/xscope.man
@@ -26,7 +26,7 @@ sits in-between an X11 client and an X11 server and prints the contents
of each request, reply, error, or event that is communicated between them.
.I Xscope
can decode the core X11 protocol and several extensions, including
-BIG-REQUESTS, LBX, MIT-SHM, NCD-WinCenterPro, RANDR, and RENDER.
+BIG-REQUESTS, DAMAGE, LBX, MIT-SHM, NCD-WinCenterPro, RANDR, and RENDER.
This information can be useful in debugging and performance
tuning of X11 servers and clients.
.PP
diff --git a/print_damage.c b/print_damage.c
new file mode 100644
index 0000000..23f70f3
--- /dev/null
+++ b/print_damage.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "scope.h"
+#include "x11.h"
+#include "damagescope.h"
+
+/* Print the portion of the damage request header common to all requests */
+static inline void
+DamageRequestHeader(FD fd, const unsigned char *buf)
+{
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* DamageRequest */
+ PrintField(buf, 1, 1, DAMAGEREQUEST, DAMAGEREQUESTHEADER); /* minor op */
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+}
+
+void
+DamageQueryVersion(FD fd, const unsigned char *buf)
+{
+ DamageRequestHeader(fd, buf);
+ if (Verbose < 1)
+ return;
+
+ printreqlen(buf, fd, CONST2(2));
+ PrintField(buf, 4, 4, CARD32, "major-version");
+ PrintField(buf, 8, 4, CARD32, "minor-version");
+}
+
+void
+DamageQueryVersionReply(FD fd, const unsigned char *buf)
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* DamageRequest reply */
+ PrintField(RBf, 1, 1, DAMAGEREPLY,
+ DAMAGEREPLYHEADER); /* DamageQueryVersion reply */
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 4, CARD32, "major-version");
+ PrintField(buf, 12, 4, CARD32, "minor-version");
+}
+
+void
+DamageCreate(FD fd, const unsigned char *buf)
+{
+ DamageRequestHeader(fd, buf);
+ if (Verbose < 1)
+ return;
+
+ printreqlen(buf, fd, CONST2(3));
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, DAMAGE, "damage");
+ PrintField(buf, 12, 1, DAMAGEREPORTLEVEL, "level");
+}
+
+void
+DamageDestroy(FD fd, const unsigned char *buf)
+{
+ DamageRequestHeader(fd, buf);
+ if (Verbose < 1)
+ return;
+
+ printreqlen(buf, fd, CONST2(1));
+ PrintField(buf, 4, 4, DAMAGE, "damage");
+}
+
+void
+DamageSubtract(FD fd, const unsigned char *buf)
+{
+ DamageRequestHeader(fd, buf);
+ if (Verbose < 1)
+ return;
+
+ printreqlen(buf, fd, CONST2(3));
+ PrintField(buf, 4, 4, DAMAGE, "damage");
+ PrintField(buf, 8, 4, REGION, "repair");
+ PrintField(buf, 12, 4, REGION, "parts");
+}
+
+void
+DamageAdd(FD fd, const unsigned char *buf)
+{
+ DamageRequestHeader(fd, buf);
+ if (Verbose < 1)
+ return;
+
+ printreqlen(buf, fd, CONST2(2));
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, REGION, "region");
+}
+
+void
+DamageNotifyEvent(const unsigned char *buf)
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* DamageNotify */
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, DAMAGEREPORTLEVEL, "level");
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, DAMAGE, "damage");
+ PrintField(buf, 12, 4, TIMESTAMP, "timestamp");
+ PrintField(buf, 16, 8, RECTANGLE, "area");
+ PrintField(buf, 24, 8, RECTANGLE, "geometry");
+}
+
+void
+DamageBadDamageError(FD fd, const unsigned char *buf)
+{
+ printErrorWithValue(buf, DAMAGE, "bad damage");
+}
diff --git a/x11.h b/x11.h
index 09deb0c..f2cc8ef 100644
--- a/x11.h
+++ b/x11.h
@@ -25,7 +25,7 @@
*
*/
/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2023, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -279,6 +279,12 @@
#define CONNECTION 174
#define SETofPROVIDER_CAPS 175
+#define DAMAGEREQUEST 176
+#define DAMAGEREPLY 177
+#define DAMAGEEVENT 178
+#define DAMAGEERROR 179
+#define DAMAGEREPORTLEVEL 180
+
#define MaxTypes 256
/* ************************************************************ */