Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2009 Younes Manton.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice (including the
  15.  * next paragraph) shall be included in all copies or substantial portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #include <assert.h>
  29. #include <error.h>
  30. #include "testlib.h"
  31.  
  32. int main(int argc, char **argv)
  33. {
  34.         const unsigned int      width = 16, height = 16;
  35.         const unsigned int      mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
  36.  
  37.         Display                 *display;
  38.         XvPortID                port_num;
  39.         int                     surface_type_id;
  40.         unsigned int            is_overlay, intra_unsigned;
  41.         int                     colorkey;
  42.         XvMCContext             context;
  43.         XvMCSurface             surface = {0};
  44.  
  45.         display = XOpenDisplay(NULL);
  46.  
  47.         if (!GetPort
  48.         (
  49.                 display,
  50.                 width,
  51.                 height,
  52.                 XVMC_CHROMA_FORMAT_420,
  53.                 mc_types,
  54.                 2,
  55.                 &port_num,
  56.                 &surface_type_id,
  57.                 &is_overlay,
  58.                 &intra_unsigned
  59.         ))
  60.         {
  61.                 XCloseDisplay(display);
  62.                 error(1, 0, "Error, unable to find a good port.\n");
  63.         }
  64.  
  65.         if (is_overlay)
  66.         {
  67.                 Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
  68.                 XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
  69.         }
  70.  
  71.         assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
  72.  
  73.         /* Test NULL context */
  74.         assert(XvMCCreateSurface(display, NULL, &surface) == XvMCBadContext);
  75.         /* Test NULL surface */
  76.         assert(XvMCCreateSurface(display, &context, NULL) == XvMCBadSurface);
  77.         /* Test valid params */
  78.         assert(XvMCCreateSurface(display, &context, &surface) == Success);
  79.         /* Test surface id assigned */
  80.         assert(surface.surface_id != 0);
  81.         /* Test context id assigned and correct */
  82.         assert(surface.context_id == context.context_id);
  83.         /* Test surface type id assigned and correct */
  84.         assert(surface.surface_type_id == surface_type_id);
  85.         /* Test width & height assigned and correct */
  86.         assert(surface.width == width && surface.height == height);
  87.         /* Test valid params */
  88.         assert(XvMCDestroySurface(display, &surface) == Success);
  89.         /* Test NULL surface */
  90.         assert(XvMCDestroySurface(display, NULL) == XvMCBadSurface);
  91.  
  92.         assert(XvMCDestroyContext(display, &context) == Success);
  93.  
  94.         XvUngrabPort(display, port_num, CurrentTime);
  95.         XCloseDisplay(display);
  96.  
  97.         return 0;
  98. }
  99.