r300g: align the height of NPOT textures to POT
[mesa.git] / src / gallium / state_trackers / xorg / xvmc / surface.c
index 0467c4d07d9a8dd89434f31394a68b23d478b2d9..12d94e0c5ca1d6be028dc7f131afabd5791606f3 100644 (file)
@@ -1,3 +1,30 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Younes Manton.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
 #include <assert.h>
 #include <X11/Xlibint.h>
 #include <pipe/p_video_context.h>
@@ -24,8 +51,7 @@ static enum pipe_mpeg12_macroblock_type TypeToPipe(int xvmc_mb_type)
 
 static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
 {
-   switch (xvmc_pic)
-   {
+   switch (xvmc_pic) {
       case XVMC_TOP_FIELD:
          return PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP;
       case XVMC_BOTTOM_FIELD:
@@ -41,8 +67,7 @@ static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
 
 static enum pipe_mpeg12_motion_type MotionToPipe(int xvmc_motion_type, int xvmc_dct_type)
 {
-   switch (xvmc_motion_type)
-   {
+   switch (xvmc_motion_type) {
       case XVMC_PREDICTION_FRAME:
          return xvmc_dct_type == XVMC_DCT_TYPE_FIELD ?
             PIPE_MPEG12_MOTION_TYPE_16x8 : PIPE_MPEG12_MOTION_TYPE_FRAME;
@@ -66,8 +91,7 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u
 
    assert(vpipe);
 
-   if (*backbuffer)
-   {
+   if (*backbuffer) {
       if ((*backbuffer)->width != width || (*backbuffer)->height != height)
          pipe_surface_reference(backbuffer, NULL);
       else
@@ -77,13 +101,12 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u
    memset(&template, 0, sizeof(struct pipe_texture));
    template.target = PIPE_TEXTURE_2D;
    /* XXX: Needs to match the drawable's format? */
-   template.format = PIPE_FORMAT_X8R8G8B8_UNORM;
+   template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
    template.last_level = 0;
-   template.width[0] = width;
-   template.height[0] = height;
-   template.depth[0] = 1;
-   pf_get_block(template.format, &template.block);
-   template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+   template.width0 = width;
+   template.height0 = height;
+   template.depth0 = 1;
+   template.tex_usage = PIPE_TEXTURE_USAGE_SHARED;
 
    tex = vpipe->screen->texture_create(vpipe->screen, &template);
    if (!tex)
@@ -121,8 +144,7 @@ MacroBlocksToPipe(const XvMCMacroBlockArray *xvmc_macroblocks,
 
    xvmc_mb = xvmc_macroblocks->macro_blocks + first_macroblock;
 
-   for (i = 0; i < num_macroblocks; ++i)
-   {
+   for (i = 0; i < num_macroblocks; ++i) {
       pipe_macroblocks->base.codec = PIPE_VIDEO_CODEC_MPEG12;
       pipe_macroblocks->mbx = xvmc_mb->x;
       pipe_macroblocks->mby = xvmc_mb->y;
@@ -171,8 +193,7 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
 
    vsfc = vpipe->screen->video_surface_create(vpipe->screen, vpipe->chroma_format,
                                               vpipe->width, vpipe->height);
-   if (!vsfc)
-   {
+   if (!vsfc) {
       FREE(surface_priv);
       return BadAlloc;
    }
@@ -262,35 +283,21 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur
 
 Status XvMCFlushSurface(Display *dpy, XvMCSurface *surface)
 {
-#if 0
-       struct vlSurface *vl_sfc;
-
-       assert(dpy);
-
-       if (!surface)
-               return XvMCBadSurface;
+   assert(dpy);
 
-       vl_sfc = surface->privData;
+   if (!surface)
+      return XvMCBadSurface;
 
-       vlSurfaceFlush(vl_sfc);
-#endif
    return Success;
 }
 
 Status XvMCSyncSurface(Display *dpy, XvMCSurface *surface)
 {
-#if 0
-       struct vlSurface *vl_sfc;
-
-       assert(dpy);
-
-       if (!surface)
-               return XvMCBadSurface;
+   assert(dpy);
 
-       vl_sfc = surface->privData;
+   if (!surface)
+      return XvMCBadSurface;
 
-       vlSurfaceSync(vl_sfc);
-#endif
    return Success;
 }
 
@@ -359,43 +366,15 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
 
 Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status)
 {
-#if 0
-       struct vlSurface        *vl_sfc;
-       enum vlResourceStatus   res_status;
-
-       assert(dpy);
-
-       if (!surface)
-               return XvMCBadSurface;
-
-       assert(status);
-
-       vl_sfc = surface->privData;
-
-       vlSurfaceGetStatus(vl_sfc, &res_status);
-
-       switch (res_status)
-       {
-               case vlResourceStatusFree:
-               {
-                       *status = 0;
-                       break;
-               }
-               case vlResourceStatusRendering:
-               {
-                       *status = XVMC_RENDERING;
-                       break;
-               }
-               case vlResourceStatusDisplaying:
-               {
-                       *status = XVMC_DISPLAYING;
-                       break;
-               }
-               default:
-                       assert(0);
-       }
-#endif
+   assert(dpy);
+
+   if (!surface)
+      return XvMCBadSurface;
+
+   assert(status);
+
    *status = 0;
+
    return Success;
 }