Exemple #1
0
void XWindow::CreateXImage(int width, int height)
{
#ifdef HAVE_SHM
    if (_useShm) {
      if (_isInitialized && _XShmInfo.shmaddr) {
        XShmDetach (_display, &_XShmInfo);
        shmdt (_XShmInfo.shmaddr);
      }
    } else
#endif
    {
      if (_XImage) {
        _XImage->data = _imageDataOrig;
      }
    }

  if (_XImage)
    XDestroyImage(_XImage);

  _imageDataOrig = NULL;

#ifdef HAVE_SHM
   if (XShmQueryExtension (_display)) {
     _useShm = true;
     PTRACE(1, "X11\tXQueryShmExtension success");
   }
   else {
     _useShm = false;
     PTRACE(1, "X11\tXQueryShmExtension failed");
   }

  if (_useShm)
     ShmAttach(width, height);

  if (_useShm) {
     PTRACE(4, "X11\tUsing shm extension");
  }
  else
#endif
  {
        _XImage = XCreateImage(_display, _XVInfo.visual, _depth, ZPixmap, 0, NULL,  width, height, 8, 0);
         _imageDataOrig = (char*)malloc(width  * height * 4 + 32);
         _XImage->data = _imageDataOrig + 16 - ((long)_imageDataOrig & 15);
         memset(_XImage->data, 0, width * 4 * height);
  }
}
Exemple #2
0
TVerdict CTestShm::doTestStepL()
	{
	int err;

   	if(TestStepName() == KIntgTest1)
   		{
		INFO_PRINTF1(_L("IntgTest1():"));
		err = IntgTest1();
		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
		}
	else
		if(TestStepName() == KIntgTest2)
   			{
   	   		INFO_PRINTF1(_L("IntgTest2():"));
   	   		err = IntgTest2();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KIntgTest3)
   			{
   	   		INFO_PRINTF1(_L("IntgTest3():"));
   	   		err = IntgTest3();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KIntgTest4)
   			{
   	   		INFO_PRINTF1(_L("IntgTest4():"));
   	   		err = IntgTest4();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KIntgTest5)
   			{
   	   		INFO_PRINTF1(_L("IntgTest5():"));
   	   		err = IntgTest5();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KIntgTest6)
   			{
   	   		INFO_PRINTF1(_L("IntgTest6():"));
   	   		err = IntgTest6();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KIntgTest7)
   			{
   	   		INFO_PRINTF1(_L("IntgTest7():"));
   	   		err = IntgTest7();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KShmCreate)
   			{
   	   		INFO_PRINTF1(_L("ShmCreate():"));
   	   		err = ShmCreate();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KShmAttach)
   			{
   	   		INFO_PRINTF1(_L("ShmAttach():"));
   	   		err = ShmAttach();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KShmDetach)
   			{
   	   		INFO_PRINTF1(_L("ShmDetach():"));
   	   		err = ShmDetach();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KShmControl)
   			{
   	   		INFO_PRINTF1(_L("ShmControl():"));
   	   		err = ShmControl();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KCreateThreadL)
   			{
   	   		INFO_PRINTF1(_L("CreateThreadL():"));
   	   		err = CreateThreadL();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else
		if(TestStepName() == KCreateThreadL1)
   			{
   	   		INFO_PRINTF1(_L("KCreateThreadL1():"));
   	   		err = CreateThreadL1();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest1)
   			{
   	   		INFO_PRINTF1(_L("shmgettest1():"));
   	   		err = shmgettest1();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest2)
   			{
   	   		INFO_PRINTF1(_L("shmgettest2():"));
   	   		err = shmgettest2();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest3)
   			{
   	   		INFO_PRINTF1(_L("shmgettest3():"));
   	   		err = shmgettest3();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest4)
   			{
   	   		INFO_PRINTF1(_L("shmgettest4():"));
   	   		err = shmgettest4();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest5)
   			{
   	   		INFO_PRINTF1(_L("shmgettest5():"));
   	   		err = shmgettest5();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest6)
   			{
   	   		INFO_PRINTF1(_L("shmgettest6():"));
   	   		err = shmgettest6();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest7)
   			{
   	   		INFO_PRINTF1(_L("shmgettest7():"));
   	   		err = shmgettest7();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmgettest8)
   			{
   	   		INFO_PRINTF1(_L("shmgettest8():"));
   	   		err = shmgettest8();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
	else if(TestStepName() == KShmgetCreateKey)
   			{
   	   		INFO_PRINTF1(_L("ShmgetCreateKey():"));
   	   		err = ShmgetCreateKey();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmctltest1)
   			{
   	   		INFO_PRINTF1(_L("shmctltest1():"));
   	   		err = shmctltest1();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmctltest2)
   			{
   	   		INFO_PRINTF1(_L("shmctltest2():"));
   	   		err = shmctltest2();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmctltest3)
   			{
   	   		INFO_PRINTF1(_L("shmctltest3():"));
   	   		err = shmctltest3();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmctltest4)
   			{
   	   		INFO_PRINTF1(_L("shmctltest4():"));
   	   		err = shmctltest4();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmctltest5)
   			{
   	   		INFO_PRINTF1(_L("shmctltest5():"));
   	   		err = shmctltest5();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmattest1)
   			{
   	   		INFO_PRINTF1(_L("shmattest1():"));
   	   		err = shmattest1();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmattest2)
   			{
   	   		INFO_PRINTF1(_L("shmattest2():"));
   	   		err = shmattest2();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmattest3)
   			{
   	   		INFO_PRINTF1(_L("shmattest3():"));
   	   		err = shmattest3();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmattest4)
   			{
   	   		INFO_PRINTF1(_L("shmattest4():"));
   	   		err = shmattest4();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmattest5)
   			{
   	   		INFO_PRINTF1(_L("shmattest5():"));
   	   		err = shmattest5();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmdttest1)
   			{
   	   		INFO_PRINTF1(_L("shmdttest1():"));
   	   		err = shmdttest1();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	else if(TestStepName() == Kshmopsvalidatetest)
   			{
   	   		INFO_PRINTF1(_L("shmopsvalidatetest():"));
   	   		err = shmopsvalidatetest();
   	   		SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
   	   		}
   	   	
	return TestStepResult(); 

	}
Exemple #3
0
int 
XVWindow::Init (Display* dp, 
                Window rootWindow, 
                GC gc, 
                int x, 
                int y,
                int windowWidth, 
                int windowHeight, 
                int imageWidth, 
                int imageHeight)
{
  // local variables needed for creation of window 
  // and initialization of XV extension
  unsigned int ver = 0;
  unsigned int rel = 0;
  unsigned int req = 0;
  unsigned int ev = 0;
  unsigned int err = 0;
  int ret = 0;
  unsigned int i = 0;

  _display = dp;
  _rootWindow = rootWindow;
  _imageWidth = imageWidth;
  _imageHeight = imageHeight;

  PTRACE(4, "XVideo\tInitializing XV window with " << windowWidth << "x" << windowHeight << " at " << x << "," << y);
  XLockDisplay (_display);


  // check if SHM XV window is possible
  ret = XvQueryExtension (_display, &ver, &rel, &req, &ev, &err);
  PTRACE(4, "XVideo\tXvQueryExtension: Version: " << ver << " Release: " << rel 
         << " Request Base: " << req << " Event Base: " << ev << " Error Base: " << err  );

  if (Success != ret) {
    if (ret == XvBadExtension)
      PTRACE(1, "XVideo\tXvQueryExtension failed - XvBadExtension");
    else if (ret == XvBadAlloc)
      PTRACE(1, "XVideo\tXvQueryExtension failed - XvBadAlloc");
    else
      PTRACE(1, "XVideo\tXQueryExtension failed");
    XUnlockDisplay (_display);
    return 0;
  }
  
  // Find XV port
  _XVPort = FindXVPort ();
  if (!_XVPort) {
    PTRACE(1, "XVideo\tFindXVPort failed");
    XUnlockDisplay(_display);
    return 0;
  } 
  PTRACE(4, "XVideo\tUsing XVideo port: " << _XVPort);

  if (!CreateAtomsAndWindow(gc, x, y, windowWidth, windowHeight)) {
    XUnlockDisplay(_display);
    return 0;
  }

  XV_SYNC_TO_VBLANK = GetXVAtom("XV_SYNC_TO_VBLANK");
  XV_COLORKEY = GetXVAtom( "XV_COLORKEY" );
  XV_AUTOPAINT_COLORKEY = GetXVAtom( "XV_AUTOPAINT_COLORKEY" );    

  if ( !InitColorkey() )
  {
    PTRACE(1, "XVideo\tColorkey initialization failed");
    XUnlockDisplay(_display);
    return 0; 
  } 

  if (XV_SYNC_TO_VBLANK != None)
    if (XvSetPortAttribute(_display, _XVPort, XV_SYNC_TO_VBLANK, 1) == Success)
      PTRACE(4, "XVideo\tVertical sync successfully activated" );
     else
      PTRACE(4, "XVideo\tFailure when trying to activate vertical sync" );
  else
    PTRACE(4, "XVideo\tVertical sync not supported");

  if (!checkMaxSize (imageWidth, imageHeight)) {
    PTRACE(1, "XVideo\tCheck of image size failed");
    XUnlockDisplay(_display);
    return 0; 
  }

#ifdef HAVE_SHM
   if (XShmQueryExtension (_display)) {
     _useShm = true;
     PTRACE(1, "XVideo\tXQueryShmExtension success");
   }
   else {
     _useShm = false;
     PTRACE(1, "XVideo\tXQueryShmExtension failed");
   }

  if (_useShm)
    ShmAttach(imageWidth, imageHeight);

  if (!_useShm) {
#endif
  for (i = 0; i < NUM_BUFFERS; i++) {

    _XVImage[i] = (XvImage *) XvCreateImage( _display, _XVPort, GUID_YV12_PLANAR, 0, imageWidth, imageHeight);

    if (!_XVImage[i]) {
      PTRACE(1, "XVideo\tUnable to create XVideo Image");
      XUnlockDisplay (_display);
      return 0;
    }

    _XVImage[i]->data = (char*) malloc(_XVImage[i]->data_size);
  }

    PTRACE(1, "XVideo\tNot using SHM extension");
#ifdef HAVE_SHM
  }
  else {
      PTRACE(1, "XVideo\tUsing SHM extension");
  }
#endif

  XSync(_display, False);

  _isInitialized = true;
  XUnlockDisplay (_display);

  // detect the window manager type
  _wmType = GetWMType ();
  CalculateSize (windowWidth, windowHeight, true);

  return 1;
}