~ubuntu-branches/ubuntu/quantal/mesa/quantal-proposed

« back to all changes in this revision

Viewing changes to src/gallium/state_trackers/dri/drm/dri2.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-09-17 13:24:35 UTC
  • mfrom: (1.7.9)
  • Revision ID: package-import@ubuntu.com-20120917132435-fqt9q6beebhc8t9r
Tags: 9.0~git20120917.7cfd42ce-0ubuntu1
Merge from unreleased debian git. (LP: #1047306)

Show diffs side-by-side

added added

removed removed

Lines of Context:
314
314
         break;
315
315
   }
316
316
 
 
317
   /* because we get the handle and stride */
 
318
   bind |= PIPE_BIND_SHARED;
 
319
 
317
320
   switch (format) {
318
321
      case 32:
319
322
         pf = PIPE_FORMAT_B8G8R8A8_UNORM;
571
574
   img->level = 0;
572
575
   img->layer = 0;
573
576
   img->dri_format = format;
 
577
   img->dri_components = 0;
574
578
 
575
579
   img->loader_private = loaderPrivate;
576
580
   return img;
603
607
   case __DRI_IMAGE_ATTRIB_FORMAT:
604
608
      *value = image->dri_format;
605
609
      return GL_TRUE;
 
610
   case __DRI_IMAGE_ATTRIB_WIDTH:
 
611
      *value = image->texture->width0;
 
612
      return GL_TRUE;
 
613
   case __DRI_IMAGE_ATTRIB_HEIGHT:
 
614
      *value = image->texture->height0;
 
615
      return GL_TRUE;
 
616
   case __DRI_IMAGE_ATTRIB_COMPONENTS:
 
617
      if (image->dri_components == 0)
 
618
         return GL_FALSE;
 
619
      *value = image->dri_components;
 
620
      return GL_TRUE;
606
621
   default:
607
622
      return GL_FALSE;
608
623
   }
621
636
   pipe_resource_reference(&img->texture, image->texture);
622
637
   img->level = image->level;
623
638
   img->layer = image->layer;
 
639
   /* This should be 0 for sub images, but dup is also used for base images. */
 
640
   img->dri_components = image->dri_components;
624
641
   img->loader_private = loaderPrivate;
625
642
 
626
643
   return img;
627
644
}
628
645
 
 
646
static GLboolean
 
647
dri2_validate_usage(__DRIimage *image, unsigned int use)
 
648
{
 
649
   /*
 
650
    * Gallium drivers are bad at adding usages to the resources
 
651
    * once opened again in another process, which is the main use
 
652
    * case for this, so we have to lie.
 
653
    */
 
654
   if (image != NULL)
 
655
      return GL_TRUE;
 
656
   else
 
657
      return GL_FALSE;
 
658
}
 
659
 
 
660
static __DRIimage *
 
661
dri2_from_names(__DRIscreen *screen, int width, int height, int format,
 
662
                int *names, int num_names, int *strides, int *offsets,
 
663
                void *loaderPrivate)
 
664
{
 
665
   __DRIimage *img;
 
666
   int stride, dri_components;
 
667
 
 
668
   if (num_names != 1)
 
669
      return NULL;
 
670
   if (offsets[0] != 0)
 
671
      return NULL;
 
672
 
 
673
   switch(format) {
 
674
   case __DRI_IMAGE_FOURCC_RGB565:
 
675
      format = __DRI_IMAGE_FORMAT_RGB565;
 
676
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
 
677
      break;
 
678
   case __DRI_IMAGE_FOURCC_ARGB8888:
 
679
      format = __DRI_IMAGE_FORMAT_ARGB8888;
 
680
      dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
 
681
      break;
 
682
   case __DRI_IMAGE_FOURCC_XRGB8888:
 
683
      format = __DRI_IMAGE_FORMAT_XRGB8888;
 
684
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
 
685
      break;
 
686
   case __DRI_IMAGE_FOURCC_ABGR8888:
 
687
      format = __DRI_IMAGE_FORMAT_ABGR8888;
 
688
      dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
 
689
      break;
 
690
   case __DRI_IMAGE_FOURCC_XBGR8888:
 
691
      format = __DRI_IMAGE_FORMAT_XBGR8888;
 
692
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
 
693
      break;
 
694
   default:
 
695
      return NULL;
 
696
   }
 
697
 
 
698
   /* Strides are in bytes not pixels. */
 
699
   stride = strides[0] /4;
 
700
 
 
701
   img = dri2_create_image_from_name(screen, width, height, format,
 
702
                                     names[0], stride, loaderPrivate);
 
703
   if (img == NULL)
 
704
      return NULL;
 
705
 
 
706
   img->dri_components = dri_components;
 
707
   return img;
 
708
}
 
709
 
 
710
static __DRIimage *
 
711
dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
 
712
{
 
713
   __DRIimage *img;
 
714
 
 
715
   if (plane != 0)
 
716
      return NULL;
 
717
 
 
718
   if (image->dri_components == 0)
 
719
      return NULL;
 
720
 
 
721
   img = dri2_dup_image(image, loaderPrivate);
 
722
   if (img == NULL)
 
723
      return NULL;
 
724
 
 
725
   /* set this to 0 for sub images. */
 
726
   img->dri_components = 0;
 
727
   return img;
 
728
}
 
729
 
629
730
static void
630
731
dri2_destroy_image(__DRIimage *img)
631
732
{
634
735
}
635
736
 
636
737
static struct __DRIimageExtensionRec dri2ImageExtension = {
637
 
    { __DRI_IMAGE, 1 },
 
738
    { __DRI_IMAGE, 5 },
638
739
    dri2_create_image_from_name,
639
740
    dri2_create_image_from_renderbuffer,
640
741
    dri2_destroy_image,
641
742
    dri2_create_image,
642
743
    dri2_query_image,
643
744
    dri2_dup_image,
 
745
    dri2_validate_usage,
 
746
    dri2_from_names,
 
747
    dri2_from_planar,
644
748
};
645
749
 
646
750
/*