<div dir="ltr">Does this mean this mean that reparenting an RGB24 visual window into an ARGB32 visual window will only be copy-free on Xwayland and not Xorg?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Apr 1, 2014 at 2:53 AM, Kristian Hřgsberg <span dir="ltr"><<a href="mailto:krh@bitplanet.net" target="_blank">krh@bitplanet.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Normally composite will decide to add implicit redirection when a<br>
window with an alternate visual is a parent of a window with a regular<br>
visual or vice versa. This uses extra pixmap memory and incurs an extra<br>
copy. This exception mechanism provides a way for a DDX to override this<br>
if the DDX knows that its acceleration architecture will render correctly.<br>
<br>
The relevant case is that of an RGB window reparented into a ARGB parent<br>
frame window. If the DDX knows that the acceleration architecture in use<br>
will pad the alpha channel to opaque when rendering to the RGB window,<br>
the implicit redirection can be avoided.<br>
<br>
This patch adds a new composite function:<br>
<br>
CompositeRegisterImplicitRedirectionException()<br>
<br>
which lets a DDX register a pair of parent and child window visuals, that<br>
will not be implicitly redirected even if the normal policy would have<br>
made that choice.<br>
<br>
Signed-off-by: Kristian Hřgsberg <<a href="mailto:krh@bitplanet.net">krh@bitplanet.net</a>><br>
Reviewed-by: Keith Packard <<a href="mailto:keithp@keithp.com">keithp@keithp.com</a>><br>
---<br>
composite/compinit.c | 24 ++++++++++++++++++++++++<br>
composite/compint.h | 7 +++++++<br>
composite/compositeext.h | 4 ++++<br>
composite/compwindow.c | 18 ++++++++++++++++++<br>
4 files changed, 53 insertions(+)<br>
<br>
diff --git a/composite/compinit.c b/composite/compinit.c<br>
index 1db9e0b..48e938f 100644<br>
--- a/composite/compinit.c<br>
+++ b/composite/compinit.c<br>
@@ -229,6 +229,28 @@ CompositeRegisterAlternateVisuals(ScreenPtr pScreen, VisualID * vids,<br>
return compRegisterAlternateVisuals(cs, vids, nVisuals);<br>
}<br>
<br>
+Bool<br>
+CompositeRegisterImplicitRedirectionException(ScreenPtr pScreen,<br>
+ VisualID parentVisual,<br>
+ VisualID winVisual)<br>
+{<br>
+ CompScreenPtr cs = GetCompScreen(pScreen);<br>
+ CompImplicitRedirectException *p;<br>
+<br>
+ p = realloc(cs->implicitRedirectExceptions,<br>
+ sizeof(p[0]) * (cs->numImplicitRedirectExceptions + 1));<br>
+ if (p == NULL)<br>
+ return FALSE;<br>
+<br>
+ p[cs->numImplicitRedirectExceptions].parentVisual = parentVisual;<br>
+ p[cs->numImplicitRedirectExceptions].winVisual = winVisual;<br>
+<br>
+ cs->implicitRedirectExceptions = p;<br>
+ cs->numImplicitRedirectExceptions++;<br>
+<br>
+ return TRUE;<br>
+}<br>
+<br>
typedef struct _alternateVisual {<br>
int depth;<br>
CARD32 format;<br>
@@ -349,6 +371,8 @@ compScreenInit(ScreenPtr pScreen)<br>
<br>
cs->numAlternateVisuals = 0;<br>
cs->alternateVisuals = NULL;<br>
+ cs->numImplicitRedirectExceptions = 0;<br>
+ cs->implicitRedirectExceptions = NULL;<br>
<br>
if (!compAddAlternateVisuals(pScreen, cs)) {<br>
free(cs);<br>
diff --git a/composite/compint.h b/composite/compint.h<br>
index 12dc8b3..56b76c5 100644<br>
--- a/composite/compint.h<br>
+++ b/composite/compint.h<br>
@@ -119,6 +119,11 @@ typedef struct _CompOverlayClientRec {<br>
XID resource;<br>
} CompOverlayClientRec;<br>
<br>
+typedef struct _CompImplicitRedirectException {<br>
+ XID parentVisual;<br>
+ XID winVisual;<br>
+} CompImplicitRedirectException;<br>
+<br>
typedef struct _CompScreen {<br>
PositionWindowProcPtr PositionWindow;<br>
CopyWindowProcPtr CopyWindow;<br>
@@ -155,6 +160,8 @@ typedef struct _CompScreen {<br>
CloseScreenProcPtr CloseScreen;<br>
int numAlternateVisuals;<br>
VisualID *alternateVisuals;<br>
+ int numImplicitRedirectExceptions;<br>
+ CompImplicitRedirectException *implicitRedirectExceptions;<br>
<br>
WindowPtr pOverlayWin;<br>
Window overlayWid;<br>
diff --git a/composite/compositeext.h b/composite/compositeext.h<br>
index 0b148f0..b96cb1d 100644<br>
--- a/composite/compositeext.h<br>
+++ b/composite/compositeext.h<br>
@@ -35,6 +35,10 @@ extern _X_EXPORT Bool CompositeRegisterAlternateVisuals(ScreenPtr pScreen,<br>
VisualID * vids,<br>
int nVisuals);<br>
<br>
+extern _X_EXPORT Bool CompositeRegisterImplicitRedirectionException(ScreenPtr pScreen,<br>
+ VisualID parentVisual,<br>
+ VisualID winVisual);<br>
+<br>
extern _X_EXPORT RESTYPE CompositeClientWindowType;<br>
<br>
#endif /* _COMPOSITEEXT_H_ */<br>
diff --git a/composite/compwindow.c b/composite/compwindow.c<br>
index 6c24349..8824294 100644<br>
--- a/composite/compwindow.c<br>
+++ b/composite/compwindow.c<br>
@@ -336,6 +336,21 @@ compIsAlternateVisual(ScreenPtr pScreen, XID visual)<br>
}<br>
<br>
static Bool<br>
+compIsImplicitRedirectException(ScreenPtr pScreen,<br>
+ XID parentVisual, XID winVisual)<br>
+{<br>
+ CompScreenPtr cs = GetCompScreen(pScreen);<br>
+ int i;<br>
+<br>
+ for (i = 0; i < cs->numImplicitRedirectExceptions; i++)<br>
+ if (cs->implicitRedirectExceptions[i].parentVisual == parentVisual &&<br>
+ cs->implicitRedirectExceptions[i].winVisual == winVisual)<br>
+ return TRUE;<br>
+<br>
+ return FALSE;<br>
+}<br>
+<br>
+static Bool<br>
compImplicitRedirect(WindowPtr pWin, WindowPtr pParent)<br>
{<br>
if (pParent) {<br>
@@ -343,6 +358,9 @@ compImplicitRedirect(WindowPtr pWin, WindowPtr pParent)<br>
XID winVisual = wVisual(pWin);<br>
XID parentVisual = wVisual(pParent);<br>
<br>
+ if (compIsImplicitRedirectException(pScreen, parentVisual, winVisual))<br>
+ return FALSE;<br>
+<br>
if (winVisual != parentVisual &&<br>
(compIsAlternateVisual(pScreen, winVisual) ||<br>
compIsAlternateVisual(pScreen, parentVisual)))<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.0<br>
<br>
_______________________________________________<br>
<a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
Archives: <a href="http://lists.x.org/archives/xorg-devel" target="_blank">http://lists.x.org/archives/xorg-devel</a><br>
Info: <a href="http://lists.x.org/mailman/listinfo/xorg-devel" target="_blank">http://lists.x.org/mailman/listinfo/xorg-devel</a></font></span></blockquote></div><br><br clear="all"><br>-- <br> Jasper<br>
</div>