aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c
diff options
context:
space:
mode:
authorMihai Moldovan <ïonic@ionic.de>2016-05-30 16:10:32 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-05-31 12:11:59 +0200
commit36c3613a7af499eb4655e1aa37b04ec6602a2518 (patch)
tree7b9cc4491de36ea0a971b3dd3159ae6f2323bece /nx-X11/programs/Xserver/hw/nxagent/NXpicture.c
parent62aac6950c6c140fb3c57e90d459b5dc74084fb2 (diff)
downloadnx-libs-36c3613a7af499eb4655e1aa37b04ec6602a2518.tar.gz
nx-libs-36c3613a7af499eb4655e1aa37b04ec6602a2518.tar.bz2
nx-libs-36c3613a7af499eb4655e1aa37b04ec6602a2518.zip
nx-X11/programs/Xserver/{hw/nxagent/NX,render/}picture.c: add and use new function ReduceCompositeOp().
More or less just an optimization for more "trivial" composite operations requiring less work, but syncs up the newer X.Org Server and nx-libs a bit more.
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/NXpicture.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXpicture.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c
index 67cd5d6ed..5087fa493 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c
@@ -1800,6 +1800,99 @@ FreePictFormat (void * pPictFormat,
return Success;
}
+/**
+ * ReduceCompositeOp is used to choose simpler ops for cases where alpha
+ * channels are always one and so math on the alpha channel per pixel becomes
+ * unnecessary. It may also avoid destination reads sometimes if apps aren't
+ * being careful to avoid these cases.
+ */
+static CARD8
+ReduceCompositeOp (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst)
+{
+ Bool no_src_alpha, no_dst_alpha;
+
+ no_src_alpha = PICT_FORMAT_COLOR(pSrc->format) &&
+ PICT_FORMAT_A(pSrc->format) == 0 &&
+ pSrc->alphaMap == NULL &&
+ pMask == NULL;
+ no_dst_alpha = PICT_FORMAT_COLOR(pDst->format) &&
+ PICT_FORMAT_A(pDst->format) == 0 &&
+ pDst->alphaMap == NULL;
+
+ /* TODO, maybe: Conjoint and Disjoint op reductions? */
+
+ /* Deal with simplifications where the source alpha is always 1. */
+ if (no_src_alpha)
+ {
+ switch (op) {
+ case PictOpOver:
+ op = PictOpSrc;
+ break;
+ case PictOpInReverse:
+ op = PictOpDst;
+ break;
+ case PictOpOutReverse:
+ op = PictOpClear;
+ break;
+ case PictOpAtop:
+ op = PictOpIn;
+ break;
+ case PictOpAtopReverse:
+ op = PictOpOverReverse;
+ break;
+ case PictOpXor:
+ op = PictOpOut;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Deal with simplifications when the destination alpha is always 1 */
+ if (no_dst_alpha)
+ {
+ switch (op) {
+ case PictOpOverReverse:
+ op = PictOpDst;
+ break;
+ case PictOpIn:
+ op = PictOpSrc;
+ break;
+ case PictOpOut:
+ op = PictOpClear;
+ break;
+ case PictOpAtop:
+ op = PictOpOver;
+ break;
+ case PictOpXor:
+ op = PictOpOutReverse;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Reduce some con/disjoint ops to the basic names. */
+ switch (op) {
+ case PictOpDisjointClear:
+ case PictOpConjointClear:
+ op = PictOpClear;
+ break;
+ case PictOpDisjointSrc:
+ case PictOpConjointSrc:
+ op = PictOpSrc;
+ break;
+ case PictOpDisjointDst:
+ case PictOpConjointDst:
+ op = PictOpDst;
+ break;
+ default:
+ break;
+ }
+
+ return op;
+}
+
void
CompositePicture (CARD8 op,
PicturePtr pSrc,
@@ -1820,6 +1913,11 @@ CompositePicture (CARD8 op,
if (pMask)
ValidatePicture (pMask);
ValidatePicture (pDst);
+
+ op = ReduceCompositeOp (op, pSrc, pMask, pDst);
+ if (op == PictOpDst)
+ return;
+
(*ps->Composite) (op,
pSrc,
pMask,