Path: blob/21.2-virgl/src/gallium/frontends/xvmc/tests/test_surface.c
4573 views
/**************************************************************************1*2* Copyright 2009 Younes Manton.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/* Force assertions, even on release builds. */28#undef NDEBUG29#include <assert.h>30#include <stdio.h>31#include <stdlib.h>32#include "testlib.h"3334int main(int argc, char **argv)35{36const unsigned int width = 16, height = 16;37const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};3839Display *display;40XvPortID port_num;41int surface_type_id;42unsigned int is_overlay, intra_unsigned;43int colorkey;44XvMCContext context;45XvMCSurface surface = {0};4647display = XOpenDisplay(NULL);4849if (!GetPort50(51display,52width,53height,54XVMC_CHROMA_FORMAT_420,55mc_types,562,57&port_num,58&surface_type_id,59&is_overlay,60&intra_unsigned61))62{63XCloseDisplay(display);64fprintf(stderr, "Error, unable to find a good port.\n");65exit(1);66}6768if (is_overlay)69{70Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);71XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);72}7374assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);7576/* Test NULL context */77assert(XvMCCreateSurface(display, NULL, &surface) == XvMCBadContext);78/* Test NULL surface */79assert(XvMCCreateSurface(display, &context, NULL) == XvMCBadSurface);80/* Test valid params */81assert(XvMCCreateSurface(display, &context, &surface) == Success);82/* Test surface id assigned */83assert(surface.surface_id != 0);84/* Test context id assigned and correct */85assert(surface.context_id == context.context_id);86/* Test surface type id assigned and correct */87assert(surface.surface_type_id == surface_type_id);88/* Test width & height assigned and correct */89assert(surface.width == width && surface.height == height);90/* Test valid params */91assert(XvMCDestroySurface(display, &surface) == Success);92/* Test NULL surface */93assert(XvMCDestroySurface(display, NULL) == XvMCBadSurface);9495assert(XvMCDestroyContext(display, &context) == Success);9697XvUngrabPort(display, port_num, CurrentTime);98XCloseDisplay(display);99100return 0;101}102103104