[PATCH xserver] use xcb struct in render

Jaya Tiwari tiwari.jaya18 at gmail.com
Fri Jan 9 11:27:42 PST 2015


Replacing manually written proto headers for render extension with xcb
generated structs
Have changed simple requests without list/switch and replies

Signed-off-by: Jaya Tiwari <tiwari.jaya18 at gmail.com>
---
 render/render.c | 173 ++++++++++++++++++++++++++----
--------------------------
 1 file changed, 80 insertions(+), 93 deletions(-)

diff --git a/render/render.c b/render/render.c
index 723f380..e91de3c 100644
--- a/render/render.c
+++ b/render/render.c
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * Author:  Keith Packard, SuSE, Inc.
@@ -41,6 +41,7 @@
 #include "servermd.h"
 #include <X11/extensions/render.h>
 #include <X11/extensions/renderproto.h>
+#include <xcb/render.h>
 #include "picturestr.h"
 #include "glyphstr.h"
 #include <X11/Xfuncproto.h>
@@ -276,11 +277,11 @@ ProcRenderQueryVersion(ClientPtr client)

     REQUEST(xRenderQueryVersionReq);

-    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
-
     pRenderClient->major_version = stuff->majorVersion;
     pRenderClient->minor_version = stuff->minorVersion;

+    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+
     if ((stuff->majorVersion * 1000 + stuff->minorVersion) <
         (SERVER_RENDER_MAJOR_VERSION * 1000 + SERVER_RENDER_MINOR_VERSION)) {
         rep.majorVersion = stuff->majorVersion;
@@ -631,20 +632,20 @@ ProcRenderChangePicture(ClientPtr client)
 static int
 ProcRenderSetPictureClipRectangles(ClientPtr client)
 {
-    REQUEST(xRenderSetPictureClipRectanglesReq);
+    REQUEST(xcb_render_set_picture_clip_rectangles_request_t);
     PicturePtr pPicture;
     int nr;

-    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
+    REQUEST_AT_LEAST_SIZE(xcb_render_set_picture_clip_rectangles_request_t);
     VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
     if (!pPicture->pDrawable)
         return RenderErrBase + BadPicture;

-    nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq);
+    nr = (client->req_len << 2) -
sizeof(xcb_render_set_picture_clip_rectangles_request_t);
     if (nr & 4)
         return BadLength;
     nr >>= 3;
-    return SetPictureClipRects(pPicture,
+    return SetPictureClipRects(pPic/ture,
                                stuff->xOrigin, stuff->yOrigin,
                                nr, (xRectangle *) &stuff[1]);
 }
@@ -654,9 +655,9 @@ ProcRenderFreePicture(ClientPtr client)
 {
     PicturePtr pPicture;

-    REQUEST(xRenderFreePictureReq);
+    REQUEST(xcb_render_free_picture_request_t);

-    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+    REQUEST_SIZE_MATCH(xcb_render_free_picture_request_t);

     VERIFY_PICTURE(pPicture, stuff->picture, client, DixDestroyAccess);
     FreeResource(stuff->picture, RT_NONE);
@@ -682,9 +683,9 @@ ProcRenderComposite(ClientPtr client)
 {
     PicturePtr pSrc, pMask, pDst;

-    REQUEST(xRenderCompositeReq);
+    REQUEST(xcb_render_composite_request_t);

-    REQUEST_SIZE_MATCH(xRenderCompositeReq);
+    REQUEST_SIZE_MATCH(xcb_render_composite_request_t);
     if (!PictOpValid(stuff->op)) {
         client->errorValue = stuff->op;
         return BadValue;
@@ -709,11 +710,11 @@ ProcRenderComposite(ClientPtr client)
                      pSrc,
                      pMask,
                      pDst,
-                     stuff->xSrc,
-                     stuff->ySrc,
-                     stuff->xMask,
-                     stuff->yMask,
-                     stuff->xDst, stuff->yDst, stuff->width, stuff->height);
+                     stuff->src_x,
+                     stuff->src_y,
+                     stuff->mask_x,
+                     stuff->mask_y,
+                     stuff->dst_x, stuff->dst_y, stuff->width, stuff->height);
     return Success;
 }

@@ -904,9 +905,9 @@ ProcRenderCreateGlyphSet(ClientPtr client)
     PictFormatPtr format;
     int rc, f;

-    REQUEST(xRenderCreateGlyphSetReq);
+    REQUEST(xcb_render_create_glyph_set_request_t);

-    REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
+    REQUEST_SIZE_MATCH(xcb_render_create_glyph_set_request_t);

     LEGAL_NEW_RESOURCE(stuff->gsid, client);
     rc = dixLookupResourceByType((void **) &format, stuff->format,
@@ -954,9 +955,9 @@ ProcRenderReferenceGlyphSet(ClientPtr client)
     GlyphSetPtr glyphSet;
     int rc;

-    REQUEST(xRenderReferenceGlyphSetReq);
+    REQUEST(xcb_render_reference_glyph_set_request_t);

-    REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
+    REQUEST_SIZE_MATCH(xcb_render_reference_glyph_set_request_t);

     LEGAL_NEW_RESOURCE(stuff->gsid, client);

@@ -981,9 +982,9 @@ ProcRenderFreeGlyphSet(ClientPtr client)
     GlyphSetPtr glyphSet;
     int rc;

-    REQUEST(xRenderFreeGlyphSetReq);
+    REQUEST(xcb_render_free_glyph_set_request_t);

-    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+    REQUEST_SIZE_MATCH(xcb_render_free_glyph_set_request_t);
     rc = dixLookupResourceByType((void **) &glyphSet, stuff->glyphset,
                                  GlyphSetType, client, DixDestroyAccess);
     if (rc != Success) {
@@ -1459,7 +1460,7 @@ static CARD32 orderedDither[DITHER_DIM][DITHER_DIM] = {
 static int
 ProcRenderCreateCursor(ClientPtr client)
 {
-    REQUEST(xRenderCreateCursorReq);
+    REQUEST(xcb_render_create_cursor_request_t);
     PicturePtr pSrc;
     ScreenPtr pScreen;
     unsigned short width, height;
@@ -1474,10 +1475,10 @@ ProcRenderCreateCursor(ClientPtr client)
     CARD32 twocolor[3];
     int rc, ncolor;

-    REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
+    REQUEST_SIZE_MATCH(xcb_render_create_cursor_request_t);
     LEGAL_NEW_RESOURCE(stuff->cid, client);

-    VERIFY_PICTURE(pSrc, stuff->src, client, DixReadAccess);
+    VERIFY_PICTURE(pSrc, stuff->source, client, DixReadAccess);
     if (!pSrc->pDrawable)
         return BadDrawable;
     pScreen = pSrc->pDrawable->pScreen;
@@ -1548,7 +1549,7 @@ ProcRenderCreateCursor(ClientPtr client)
         FreePicture(pPicture, 0);
     }
     /*
-     * Check whether the cursor can be directly supported by
+     * Check whether the cursor can be directly supported by
      * the core cursor code
      */
     ncolor = 0;
@@ -1648,10 +1649,10 @@ ProcRenderCreateCursor(ClientPtr client)
 static int
 ProcRenderSetPictureTransform(ClientPtr client)
 {
-    REQUEST(xRenderSetPictureTransformReq);
+    REQUEST(xcb_render_set_picture_transform_request_t);
     PicturePtr pPicture;

-    REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
+    REQUEST_SIZE_MATCH(xcb_render_set_picture_transform_request_t);
     VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
     return SetPictureTransform(pPicture, (PictTransform *) &stuff->transform);
 }
@@ -1847,21 +1848,21 @@ ProcRenderCreateSolidFill(ClientPtr client)
     PicturePtr pPicture;
     int error = 0;

-    REQUEST(xRenderCreateSolidFillReq);
+    REQUEST(xcb_render_create_solid_fill_request_t);

-    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
+    REQUEST_AT_LEAST_SIZE(xcb_render_create_solid_fill_request_t);

-    LEGAL_NEW_RESOURCE(stuff->pid, client);
+    LEGAL_NEW_RESOURCE(stuff->picture, client);

-    pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
+    pPicture = CreateSolidPicture(stuff->picture, &stuff->color, &error);
     if (!pPicture)
         return error;
     /* security creation/labeling check */
-    error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+    error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->picture, PictureType,
                      pPicture, RT_NONE, NULL, DixCreateAccess);
     if (error != Success)
         return error;
-    if (!AddResource(stuff->pid, PictureType, (void *) pPicture))
+    if (!AddResource(stuff->picture, PictureType, (void *) pPicture))
         return BadAlloc;
     return Success;
 }
@@ -1995,7 +1996,7 @@ static int
 SProcRenderQueryVersion(ClientPtr client)
 {
     REQUEST(xRenderQueryVersionReq);
-    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+
     swaps(&stuff->length);
     swapl(&stuff->majorVersion);
     swapl(&stuff->minorVersion);
@@ -2006,7 +2007,6 @@ static int
 SProcRenderQueryPictFormats(ClientPtr client)
 {
     REQUEST(xRenderQueryPictFormatsReq);
-    REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
     swaps(&stuff->length);
     return (*ProcRenderVector[stuff->renderReqType]) (client);
 }
@@ -2015,7 +2015,6 @@ static int
 SProcRenderQueryPictIndexValues(ClientPtr client)
 {
     REQUEST(xRenderQueryPictIndexValuesReq);
-    REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq);
     swaps(&stuff->length);
     swapl(&stuff->format);
     return (*ProcRenderVector[stuff->renderReqType]) (client);
@@ -2031,7 +2030,6 @@ static int
 SProcRenderCreatePicture(ClientPtr client)
 {
     REQUEST(xRenderCreatePictureReq);
-    REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
     swaps(&stuff->length);
     swapl(&stuff->pid);
     swapl(&stuff->drawable);
@@ -2045,7 +2043,6 @@ static int
 SProcRenderChangePicture(ClientPtr client)
 {
     REQUEST(xRenderChangePictureReq);
-    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
     swaps(&stuff->length);
     swapl(&stuff->picture);
     swapl(&stuff->mask);
@@ -2057,7 +2054,6 @@ static int
 SProcRenderSetPictureClipRectangles(ClientPtr client)
 {
     REQUEST(xRenderSetPictureClipRectanglesReq);
-    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
     swaps(&stuff->length);
     swapl(&stuff->picture);
     swaps(&stuff->xOrigin);
@@ -2069,38 +2065,35 @@ SProcRenderSetPictureClipRectangles(ClientPtr client)
 static int
 SProcRenderFreePicture(ClientPtr client)
 {
-    REQUEST(xRenderFreePictureReq);
-    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+    REQUEST(xcb_render_free_picture_request_t);
     swaps(&stuff->length);
     swapl(&stuff->picture);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
 SProcRenderComposite(ClientPtr client)
 {
-    REQUEST(xRenderCompositeReq);
-    REQUEST_SIZE_MATCH(xRenderCompositeReq);
+    REQUEST(xcb_render_composite_request_t);
     swaps(&stuff->length);
     swapl(&stuff->src);
     swapl(&stuff->mask);
     swapl(&stuff->dst);
-    swaps(&stuff->xSrc);
-    swaps(&stuff->ySrc);
-    swaps(&stuff->xMask);
-    swaps(&stuff->yMask);
-    swaps(&stuff->xDst);
-    swaps(&stuff->yDst);
+    swaps(&stuff->src_x);
+    swaps(&stuff->src_y);
+    swaps(&stuff->mask_x);
+    swaps(&stuff->mask_y);
+    swaps(&stuff->dst_x);
+    swaps(&stuff->dst_y);
     swaps(&stuff->width);
     swaps(&stuff->height);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
 SProcRenderScale(ClientPtr client)
 {
     REQUEST(xRenderScaleReq);
-    REQUEST_SIZE_MATCH(xRenderScaleReq);
     swaps(&stuff->length);
     swapl(&stuff->src);
     swapl(&stuff->dst);
@@ -2200,33 +2193,30 @@ SProcRenderTransform(ClientPtr client)
 static int
 SProcRenderCreateGlyphSet(ClientPtr client)
 {
-    REQUEST(xRenderCreateGlyphSetReq);
-    REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
+    REQUEST(xcb_render_create_glyph_set_request_t);
     swaps(&stuff->length);
     swapl(&stuff->gsid);
     swapl(&stuff->format);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
 SProcRenderReferenceGlyphSet(ClientPtr client)
 {
-    REQUEST(xRenderReferenceGlyphSetReq);
-    REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
+    REQUEST(xcb_render_reference_glyph_set_request_t);
     swaps(&stuff->length);
     swapl(&stuff->gsid);
     swapl(&stuff->existing);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
 SProcRenderFreeGlyphSet(ClientPtr client)
 {
-    REQUEST(xRenderFreeGlyphSetReq);
-    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+    REQUEST(xcb_render_free_glyph_set_request_t);
     swaps(&stuff->length);
     swapl(&stuff->glyphset);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
@@ -2238,7 +2228,6 @@ SProcRenderAddGlyphs(ClientPtr client)
     xGlyphInfo *gi;

     REQUEST(xRenderAddGlyphsReq);
-    REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
     swaps(&stuff->length);
     swapl(&stuff->glyphset);
     swapl(&stuff->nglyphs);
@@ -2273,7 +2262,6 @@ static int
 SProcRenderFreeGlyphs(ClientPtr client)
 {
     REQUEST(xRenderFreeGlyphsReq);
-    REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
     swaps(&stuff->length);
     swapl(&stuff->glyphset);
     SwapRestL(stuff);
@@ -2291,7 +2279,6 @@ SProcRenderCompositeGlyphs(ClientPtr client)
     int size;

     REQUEST(xRenderCompositeGlyphsReq);
-    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);

     switch (stuff->renderReqType) {
     default:
@@ -2371,22 +2358,22 @@ SProcRenderFillRectangles(ClientPtr client)
 static int
 SProcRenderCreateCursor(ClientPtr client)
 {
-    REQUEST(xRenderCreateCursorReq);
-    REQUEST_SIZE_MATCH(xRenderCreateCursorReq);
+    REQUEST(xcb_render_create_cursor_request_t);
+    REQUEST_SIZE_MATCH(xcb_render_create_cursor_request_t);

     swaps(&stuff->length);
     swapl(&stuff->cid);
-    swapl(&stuff->src);
+    swapl(&stuff->source);
     swaps(&stuff->x);
     swaps(&stuff->y);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
 SProcRenderSetPictureTransform(ClientPtr client)
 {
-    REQUEST(xRenderSetPictureTransformReq);
-    REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
+    REQUEST(xcb_render_set_picture_transform_request_t);
+    REQUEST_SIZE_MATCH(xcb_render_set_picture_transform_request_t);

     swaps(&stuff->length);
     swapl(&stuff->picture);
@@ -2399,7 +2386,7 @@ SProcRenderSetPictureTransform(ClientPtr client)
     swapl(&stuff->transform.matrix31);
     swapl(&stuff->transform.matrix32);
     swapl(&stuff->transform.matrix33);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static int
@@ -2454,16 +2441,16 @@ SProcRenderAddTraps(ClientPtr client)
 static int
 SProcRenderCreateSolidFill(ClientPtr client)
 {
-    REQUEST(xRenderCreateSolidFillReq);
-    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
+    REQUEST(xcb_render_create_solid_fill_request_t);
+    REQUEST_AT_LEAST_SIZE(xcb_render_create_solid_fill_request_t);

     swaps(&stuff->length);
-    swapl(&stuff->pid);
+    swapl(&stuff->picture);
     swaps(&stuff->color.alpha);
     swaps(&stuff->color.red);
     swaps(&stuff->color.green);
     swaps(&stuff->color.blue);
-    return (*ProcRenderVector[stuff->renderReqType]) (client);
+    return (*ProcRenderVector[stuff->minor_opcode]) (client);
 }

 static void
@@ -2684,11 +2671,11 @@
PanoramiXRenderSetPictureClipRectangles(ClientPtr client)
 static int
 PanoramiXRenderSetPictureTransform(ClientPtr client)
 {
-    REQUEST(xRenderSetPictureTransformReq);
+    REQUEST(xcb_render_set_picture_transform_request_t);
     int result = Success, j;
     PanoramiXRes *pict;

-    REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq);
+    REQUEST_AT_LEAST_SIZE(xcb_render_set_picture_transform_request_t);

     VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);

@@ -2731,9 +2718,9 @@ PanoramiXRenderFreePicture(ClientPtr client)
     PanoramiXRes *pict;
     int result = Success, j;

-    REQUEST(xRenderFreePictureReq);
+    REQUEST(xcb_render_free_picture_request_t);

-    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+    REQUEST_SIZE_MATCH(xcb_render_free_picture_request_t);

     client->errorValue = stuff->picture;

@@ -2757,11 +2744,11 @@ PanoramiXRenderComposite(ClientPtr client)
 {
     PanoramiXRes *src, *msk, *dst;
     int result = Success, j;
-    xRenderCompositeReq orig;
+    xcb_render_composite_request_t orig;

-    REQUEST(xRenderCompositeReq);
+    REQUEST(xcb_render_composite_request_t);

-    REQUEST_SIZE_MATCH(xRenderCompositeReq);
+    REQUEST_SIZE_MATCH(xcb_render_composite_request_t);

     VERIFY_XIN_PICTURE(src, stuff->src, client, DixReadAccess);
     VERIFY_XIN_ALPHA(msk, stuff->mask, client, DixReadAccess);
@@ -2772,19 +2759,19 @@ PanoramiXRenderComposite(ClientPtr client)
     FOR_NSCREENS_FORWARD(j) {
         stuff->src = src->info[j].id;
         if (src->u.pict.root) {
-            stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x;
-            stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y;
+            stuff->src_x = orig.src_x - screenInfo.screens[j]->x;
+            stuff->src_y = orig.src_y - screenInfo.screens[j]->y;
         }
         stuff->dst = dst->info[j].id;
         if (dst->u.pict.root) {
-            stuff->xDst = orig.xDst - screenInfo.screens[j]->x;
-            stuff->yDst = orig.yDst - screenInfo.screens[j]->y;
+            stuff->dst_x = orig.dst_x - screenInfo.screens[j]->x;
+            stuff->dst_y = orig.dst_y - screenInfo.screens[j]->y;
         }
         if (msk) {
             stuff->mask = msk->info[j].id;
             if (msk->u.pict.root) {
-                stuff->xMask = orig.xMask - screenInfo.screens[j]->x;
-                stuff->yMask = orig.yMask - screenInfo.screens[j]->y;
+                stuff->mask_x = orig.mask_x - screenInfo.screens[j]->x;
+                stuff->mask_y = orig.mask_y - screenInfo.screens[j]->y;
             }
         }
         result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
@@ -3145,21 +3132,21 @@ PanoramiXRenderAddTraps(ClientPtr client)
 static int
 PanoramiXRenderCreateSolidFill(ClientPtr client)
 {
-    REQUEST(xRenderCreateSolidFillReq);
+    REQUEST(xcb_render_create_solid_fill_request_t);
     PanoramiXRes *newPict;
     int result = Success, j;

-    REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq);
+    REQUEST_AT_LEAST_SIZE(xcb_render_create_solid_fill_request_t);

     if (!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
         return BadAlloc;

     newPict->type = XRT_PICTURE;
-    panoramix_setup_ids(newPict, client, stuff->pid);
+    panoramix_setup_ids(newPict, client, stuff->picture);
     newPict->u.pict.root = FALSE;

     FOR_NSCREENS_BACKWARD(j) {
-        stuff->pid = newPict->info[j].id;
+        stuff->picture = newPict->info[j].id;
         result =
(*PanoramiXSaveRenderVector[X_RenderCreateSolidFill]) (client);
         if (result != Success)
             break;



-- 
Regards,
Jaya


More information about the xorg-devel mailing list