/**
    \fn init
*/
bool libvaRender::init( GUI_WindowInfo * window, uint32_t w, uint32_t h,renderZoom zoom)
{
    ADM_info("[libva]Xv start\n");
    info=*window;
    if(admLibVA::isOperationnal()==false)
    {
        ADM_warning("[libva] Not operationnal\n");
        return false;
    }
    for(int i=0;i<2;i++)
    {
        VASurfaceID surface=admLibVA::allocateSurface(w,h);
        if(surface==VA_INVALID)
        {
             ADM_warning("[libva] cannot allocate surface\n");
            return false;
        }

        mySurface[i]=new ADM_vaSurface(NULL,w,h);
        mySurface[i]->surface=surface;
    }    
    
    baseInit(w,h,zoom);
    return true;
}
  sp<Retval> GdMonCpustat::draw(int num, sp<info>& info, sp<MonBase>& dest
                        , const char* path)
  {
      sp<Retval> retval;
      if( DFW_RET(retval, MonCpustat::draw(num, info, dest, path)) )
          return DFW_RETVAL_D(retval);
      if( DFW_RET(retval, baseInit()) )
          return DFW_RETVAL_D(retval);

      struct max_st  max;
      struct data_st dt;
      getMax(&max, info, m_g.cs.w);
      setData(&dt);

      drawHead(dest->m_sec, info->m_sec);

      uint64_t first_sec;
      uint64_t last_sec = dest->m_sec;
      for(int k=info->m_aLists.size(), dx=m_g.cr.ex; ((k>0)&&(dx>m_g.cr.sx));)
      {
          sp<GdMonCpustat> p  = info->m_aLists.get(k-1);
          sp<GdMonCpustat> pp = info->m_aLists.get(k-2);
          procData(dx, &max, &dt, p, pp);
          drawData(dx, &dt);
          k--;
          dx--;
          first_sec = p->m_sec;
      }

      drawBottom(dest, &max, &dt);
      drawLast(first_sec, last_sec);
      if( DFW_RET(retval, savePng(path, savename(), 0)) )
          return DFW_RETVAL_D(retval);
      return NULL;
  }
Beispiel #3
0
/** \brief Create a mixer object
 *
 *  The mixer will be initialized with default values: scaling of all
 *  axes is set to 1.0, offsets of throttle, spoiler, retract are set to 0.5.
 *  Mixers are enabled but not effective.
 */
T_TX_Mixer::T_TX_Mixer(T_TX_Interface *parent) 
{
  baseInit(parent);
#if DEBUG_TX_INTERFACE > 0
  printf("T_TX_Mixer::T_TX_Mixer()\n");
#endif
}
/**
    \fn changeZoom
*/
bool simpleRender::init( GUI_WindowInfo *  window, uint32_t w, uint32_t h,renderZoom zoom)
{
    info=*window;
    baseInit(w,h,zoom);
    ADM_info("init, simple render. w=%d, h=%d,zoom=%d\n",(int)w,(int)h,(int)zoom);
    allocateStuff();
    return true;
}
Beispiel #5
0
void AIEntity::init(Brain* _Brain, Weapon* _weapon, AbstractFactoryBase<Entity>* _damageSprayFactory, Skin* _skin)
{
    assert(!mBrain);
    mBrain = _Brain;
    weapon = _weapon;
    mBrain->setEntity(this);
    damageSprayFactory = _damageSprayFactory;
    baseInit(_skin);
}
Beispiel #6
0
/** \brief Create and initialize a mixer object
 *
 *  The mixer will be initialized from the given child
 *  in the SimpleXMLTransfer. This does the same as if you
 *  would call <code>T_TX_Mixer::init(cfg, child)</code>
 *  after calling the empty constructor.
 *
 *  \param cfg Pointer to an XML tree containing the config info.
 *  \param child The name of the child which holds the mixer info.
 */
T_TX_Mixer::T_TX_Mixer(T_TX_Interface *parent, 
                       SimpleXMLTransfer* cfg, std::string child)
{
  baseInit(parent);
#if DEBUG_TX_INTERFACE > 0
  printf("T_TX_Mixer::T_TX_Mixer(cfg, child)\n");
#endif
  init(cfg, child);
}
Beispiel #7
0
/**
    \fn init
*/
bool vdpauRender::init( GUI_WindowInfo *window, uint32_t w, uint32_t h, float zoom)
{
    if(!w || !h)
    {
        ADM_info("[VDPAU] Not trying to initialize with zero size dimensions\n");
        return false;
    }
    ADM_info("[Vdpau]Init\n");
    info=*window;
    if(admVdpau::isOperationnal()==false)
    {
        ADM_warning("[Vdpau] Not operationnal\n");
    }
    baseInit(w,h,zoom);
    // Create couple of outputSurface
    surface[0]=surface[1]=VDP_INVALID_HANDLE;
    currentSurface=0;
    
    //
    int widthToUse=admVdpau::dimensionRoundUp(w);
    int heightToUse=admVdpau::dimensionRoundUp(h);
    
    ADM_info("[VDpau] Allocating surfaces %d x%d , %d x %d, %d x x%d\n",w,h,widthToUse,heightToUse,displayWidth,displayHeight);
    
    if(!reallocOutputSurface(displayWidth,displayHeight))
    {
        goto badInit;
    }
    if(VDP_STATUS_OK!=admVdpau::surfaceCreate(widthToUse,heightToUse,&input)) 
    {
        ADM_error("Cannot create input Surface\n");
        goto badInit;
    }
    if(VDP_STATUS_OK!=admVdpau::presentationQueueCreate(&queue)) 
    {
        ADM_error("Cannot create queue\n");
        goto badInit;
    } 
    if(VDP_STATUS_OK!=admVdpau::mixerCreate(widthToUse,heightToUse,&mixer)) 
    {
        ADM_error("Cannot create mixer\n");
        goto badInit;
    } 

    return true;
badInit:
    
    return false;
}
void ControllerDirectRead::Init()
{
	Release();
	stringstream ss;

	//ss.str("");
	//ss << "IsRealModel = " << IsRealModel << endl;
	//MFCConsole::Output(ss.str());

	if (IsRealModel)
	{
		int virtualCamEnable = 1;
		if (SettingHelper::GetKeyInt("E2V", "Virtual_Cam_Enable", virtualCamEnable))
			IsRealModel = virtualCamEnable == 0;
	}

	//ss.str("");
	//ss << "IsRealModel = " << IsRealModel << endl;
	//MFCConsole::Output(ss.str());

	//初始化E2V相机
	if (IsRealModel)
	{
		int COLOR_TYPE_IS_GRAY = 1;
		SettingHelper::GetKeyInt("E2V", "COLOR_TYPE_IS_GRAY", COLOR_TYPE_IS_GRAY);
		if (COLOR_TYPE_IS_GRAY != 0)
			p_e2v = new	E2VCameraDirectRead(4096, PhotoHeight, CV_8U, 0, PORT_A);
		else
			p_e2v = new	E2VCameraDirectRead(4096, PhotoHeight, CV_8UC3, 0, PORT_A);


		if (!p_e2v->HasBeenInited)
		{
			//若初始化e2v_EV71YC1CCL4005BA0失败
			//则删除已实例化的对象,切换为虚拟相机模式
			if (p_e2v != NULL)
			{
				delete p_e2v;
				p_e2v = NULL;
			}
			e2vInited = false;
		}
		else
			e2vInited = true;
	}

	baseInit();
}
Beispiel #9
0
void TIMERONE::begin(uint32_t period,uint32_t prescaler)
{
	NVIC_InitTypeDef NVIC_InitStructure;
	
	baseInit(period,prescaler);
	
	NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;//
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// 
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;// 
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);

	
	interrupt(DISABLE);
	stop();
}
/**
    \fn changeZoom
*/
bool dxvaRender::init( GUI_WindowInfo *  window, uint32_t w, uint32_t h,renderZoom zoom)
{
    ADM_info("Initializing dxva2/D3D render\n");
    info=*window;
    baseInit(w,h,zoom);

    windowId=(HWND)window->systemWindowId;

    if(!d3dHandle)
    {
        ADM_warning("No D3DHandle\n");
        return false;
    }

    if (ADM_FAILED(IDirect3D9_GetAdapterDisplayMode(d3dHandle,
                                                D3DADAPTER_DEFAULT,
                                                &displayMode)))
    {
        ADM_warning("Dxv2/D3D Render: Cannot get display mode\n");
        return 0;
    }

    D3DCAPS9 deviceCapabilities;
    ADM_info("D3D Checking device capabilities\n");
    if (ADM_FAILED(IDirect3D9_GetDeviceCaps(d3dHandle,
                                        D3DADAPTER_DEFAULT,
                                        D3DDEVTYPE_HAL,
                                        &deviceCapabilities)))
    {
      ADM_warning("Cannot get device capabilities");
      return false;
    }
    int texture = deviceCapabilities.TextureCaps;
    ADM_info("Power of 2 : %d\n",  (texture & D3DPTEXTURECAPS_POW2) &&   !(texture & D3DPTEXTURECAPS_NONPOW2CONDITIONAL));
    ADM_info("Square only: %d\n",  (texture & D3DPTEXTURECAPS_SQUAREONLY));



      // Check if we support YV12
    D3DFORMAT fmt=displayMode.Format;
    D3DFORMAT yv12=(D3DFORMAT)MAKEFOURCC('Y','V','1','2');
    if (ADM_FAILED(IDirect3D9_CheckDeviceFormatConversion(   d3dHandle, // adapter
                                                         D3DADAPTER_DEFAULT, // device type
                                                         D3DDEVTYPE_HAL, // adapter format
                                                         yv12, // render target format
                                                         fmt)))  // depth stencil format
    {
        useYV12=false;
        ADM_info("D3D YV12 not supported\n");
    }
    else
    {
        useYV12=true;
        ADM_info("D3D YV12 is supported\n");
    }



    if(!setup())
    {
      ADM_warning("Dxva/D3D setup failed\n");
      return false;
    }
    videoWidget=(ADM_Qvideo *)info.widget;
    videoWidget->useExternalRedraw(true); // deactivate Qt Double buffering
    videoWidget->setDrawer(this);

    ADM_info("Dxva (D3D) init successful, dxva render. w=%d, h=%d,zoom=%d, displayWidth=%d, displayHeight=%d\n",(int)w,(int)h,(int)zoom,(int)displayWidth,(int)displayHeight);
    return true;
}
Beispiel #11
0
LLNameValue::LLNameValue()
{
	baseInit();
}
Beispiel #12
0
// data is in the format:
// "NameValueName	Type	Class	Data"
LLNameValue::LLNameValue(const char *data)
{
	baseInit();
	static char name[NV_BUFFER_LEN];	/*Flawfinder: ignore*/
	static char type[NV_BUFFER_LEN];	/*Flawfinder: ignore*/
	static char nvclass[NV_BUFFER_LEN];	/*Flawfinder: ignore*/
	static char nvsendto[NV_BUFFER_LEN];	/*Flawfinder: ignore*/
	static char nvdata[NV_BUFFER_LEN];	/*Flawfinder: ignore*/

	S32 i;

	S32	character_count = 0;
	S32	length = 0;

	// go to first non-whitespace character
	while (1)
	{
		if (  (*(data + character_count) == ' ')
			||(*(data + character_count) == '\n')
			||(*(data + character_count) == '\t')
			||(*(data + character_count) == '\r'))
		{
			character_count++;
		}
		else
		{
			break;
		}
	}

	// read in the name
	sscanf((data + character_count), "%2047s", name);	/*Flawfinder: ignore*/

	// bump past it and add null terminator
	length = (S32)strlen(name);			/* Flawfinder: ignore */
	name[length] = 0;
	character_count += length;

	// go to the next non-whitespace character
	while (1)
	{
		if (  (*(data + character_count) == ' ')
			||(*(data + character_count) == '\n')
			||(*(data + character_count) == '\t')
			||(*(data + character_count) == '\r'))
		{
			character_count++;
		}
		else
		{
			break;
		}
	}

	// read in the type
	sscanf((data + character_count), "%2047s", type);	/*Flawfinder: ignore*/

	// bump past it and add null terminator
	length = (S32)strlen(type);		/* Flawfinder: ignore */
	type[length] = 0;
	character_count += length;

	// go to the next non-whitespace character
	while (1)
	{
		if (  (*(data + character_count) == ' ')
			||(*(data + character_count) == '\n')
			||(*(data + character_count) == '\t')
			||(*(data + character_count) == '\r'))
		{
			character_count++;
		}
		else
		{
			break;
		}
	}

	// do we have a type argument?
	for (i = NVC_READ_ONLY; i < NVC_EOF; i++)
	{
		if (!strncmp(NameValueClassStrings[i], data + character_count, strlen(NameValueClassStrings[i])))		/* Flawfinder: ignore */
		{
			break;
		}
	}

	if (i != NVC_EOF)
	{
		// yes we do!
		// read in the class
		sscanf((data + character_count), "%2047s", nvclass);	/*Flawfinder: ignore*/

		// bump past it and add null terminator
		length = (S32)strlen(nvclass);		/* Flawfinder: ignore */
		nvclass[length] = 0;
		character_count += length;

		// go to the next non-whitespace character
		while (1)
		{
			if (  (*(data + character_count) == ' ')
				||(*(data + character_count) == '\n')
				||(*(data + character_count) == '\t')
				||(*(data + character_count) == '\r'))
			{
				character_count++;
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		// no type argument given, default to read-write
		strncpy(nvclass, "READ_WRITE", sizeof(nvclass) -1);		/* Flawfinder: ignore */
		nvclass[sizeof(nvclass) -1] = '\0';
	}

	// Do we have a sendto argument?
	for (i = NVS_SIM; i < NVS_EOF; i++)
	{
		if (!strncmp(NameValueSendtoStrings[i], data + character_count, strlen(NameValueSendtoStrings[i])))		/* Flawfinder: ignore */
		{
			break;
		}
	}

	if (i != NVS_EOF)
	{
		// found a sendto argument
		sscanf((data + character_count), "%2047s", nvsendto);	/*Flawfinder: ignore*/

		// add null terminator
		length = (S32)strlen(nvsendto);		/* Flawfinder: ignore */
		nvsendto[length] = 0;
		character_count += length;

		// seek to next non-whitespace characer
		while (1)
		{
			if (  (*(data + character_count) == ' ')
				||(*(data + character_count) == '\n')
				||(*(data + character_count) == '\t')
				||(*(data + character_count) == '\r'))
			{
				character_count++;
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		// no sendto argument given, default to sim only
		strncpy(nvsendto, "SIM", sizeof(nvsendto) -1);		/* Flawfinder: ignore */
		nvsendto[sizeof(nvsendto) -1] ='\0';
	}


	// copy the rest character by character into data
	length = 0;

	while ( (*(nvdata + length++) = *(data + character_count++)) )
		;

	init(name, nvdata, type, nvclass, nvsendto);
}
Beispiel #13
0
// Initialize without any initial data.
LLNameValue::LLNameValue(const char *name, const char *type, const char *nvclass)
{
	baseInit();
	mName = mNVNameTable->addString(name);
	
	// Nota Bene: Whatever global structure manages this should have these in the name table already!
	mStringType = mNVNameTable->addString(type);
	if (!strcmp(mStringType, "STRING"))
	{
		mType = NVT_STRING;
		mNameValueReference.string = NULL;
	}
	else if (!strcmp(mStringType, "F32"))
	{
		mType = NVT_F32;
		mNameValueReference.f32 = NULL;
	}
	else if (!strcmp(mStringType, "S32"))
	{
		mType = NVT_S32;
		mNameValueReference.s32 = NULL;
	}
	else if (!strcmp(mStringType, "VEC3"))
	{
		mType = NVT_VEC3;
		mNameValueReference.vec3 = NULL;
	}
	else if (!strcmp(mStringType, "U32"))
	{
		mType = NVT_U32;
		mNameValueReference.u32 = NULL;
	}
	else if (!strcmp(mStringType, "U64"))
	{
		mType = NVT_U64;
		mNameValueReference.u64 = NULL;
	}
	else if(!strcmp(mStringType, (const char*)NameValueTypeStrings[NVT_ASSET]))
	{
		mType = NVT_ASSET;
		mNameValueReference.string = NULL;
	}
	else
	{
		mType = NVT_NULL;
		llinfos << "Unknown name-value type " << mStringType << llendl;
	}

	// Nota Bene: Whatever global structure manages this should have these in the name table already!
	mStringClass = mNVNameTable->addString(nvclass);
	if (!strcmp(mStringClass, "READ_ONLY"))
	{
		mClass = NVC_READ_ONLY;
	}
	else if (!strcmp(mStringClass, "READ_WRITE"))
	{
		mClass = NVC_READ_WRITE;
	}
	else
	{
		mClass = NVC_NULL;
	}

	// Initialize the sendto variable
	mStringSendto = mNVNameTable->addString("SIM");
	mSendto = NVS_SIM;
}
Beispiel #14
0
LLNameValue::LLNameValue(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto)
{
	baseInit();
	init(name, data, type, nvclass, nvsendto);
}
Beispiel #15
0
LLNameValue::LLNameValue(const char *name, const char *data, const char *type, const char *nvclass)
{
	baseInit();
	// if not specified, send to simulator only
	init(name, data, type, nvclass, "SIM");
}
Beispiel #16
0
void SceneBase::start()
{
	baseInit();
	run();
}
Beispiel #17
0
/**
 * Initializes a file object but does *not* open the file on the guest
 * yet. This is done in the dedidcated openFile call.
 *
 * @return  IPRT status code.
 * @param   pConsole                Pointer to console object.
 * @param   pSession                Pointer to session object.
 * @param   uFileID                 Host-based file ID (part of the context ID).
 * @param   openInfo                File opening information.
 */
int GuestFile::init(Console *pConsole, GuestSession *pSession,
                    ULONG uFileID, const GuestFileOpenInfo &openInfo)
{
    LogFlowThisFunc(("pConsole=%p, pSession=%p, uFileID=%RU32, strPath=%s\n",
                     pConsole, pSession, uFileID, openInfo.mFileName.c_str()));

    AssertPtrReturn(pConsole, VERR_INVALID_POINTER);
    AssertPtrReturn(pSession, VERR_INVALID_POINTER);

    /* Enclose the state transition NotReady->InInit->Ready. */
    AutoInitSpan autoInitSpan(this);
    AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);

    int vrc = bindToSession(pConsole, pSession, uFileID /* Object ID */);
    if (RT_SUCCESS(vrc))
    {
        mSession = pSession;

        mData.mID = uFileID;
        mData.mInitialSize = 0;
        mData.mStatus = FileStatus_Undefined;
        mData.mOpenInfo = openInfo;

        unconst(mEventSource).createObject();
        HRESULT hr = mEventSource->init();
        if (FAILED(hr))
            vrc = VERR_COM_UNEXPECTED;
    }

    if (RT_SUCCESS(vrc))
    {
        try
        {
            GuestFileListener *pListener = new GuestFileListener();
            ComObjPtr<GuestFileListenerImpl> thisListener;
            HRESULT hr = thisListener.createObject();
            if (SUCCEEDED(hr))
                hr = thisListener->init(pListener, this);

            if (SUCCEEDED(hr))
            {
                com::SafeArray <VBoxEventType_T> eventTypes;
                eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
                eventTypes.push_back(VBoxEventType_OnGuestFileOffsetChanged);
                eventTypes.push_back(VBoxEventType_OnGuestFileRead);
                eventTypes.push_back(VBoxEventType_OnGuestFileWrite);
                hr = mEventSource->RegisterListener(thisListener,
                                                    ComSafeArrayAsInParam(eventTypes),
                                                    TRUE /* Active listener */);
                if (SUCCEEDED(hr))
                {
                    vrc = baseInit();
                    if (RT_SUCCESS(vrc))
                    {
                        mLocalListener = thisListener;
                    }
                }
                else
                    vrc = VERR_COM_UNEXPECTED;
            }
            else
                vrc = VERR_COM_UNEXPECTED;
        }
        catch(std::bad_alloc &)
        {
            vrc = VERR_NO_MEMORY;
        }
    }

    if (RT_SUCCESS(vrc))
    {
        /* Confirm a successful initialization when it's the case. */
        autoInitSpan.setSucceeded();
    }
    else
        autoInitSpan.setFailed();

    LogFlowFuncLeaveRC(vrc);
    return vrc;
}
/**
    \fn init
*/
bool sdlRenderImpl::init( GUI_WindowInfo * window, uint32_t w, uint32_t h,renderZoom zoom)
{
    ADM_info("[SDL] Initializing video subsystem\n");

    int bpp;
    int flags;
    baseInit(w,h,zoom);

    if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
    {
        ADM_warning("[SDL] FAILED initialising video subsystem\n");
        ADM_warning("[SDL] ERROR: %s\n", SDL_GetError());
        return false;
    }
    ADM_info("[SDL] Video subsystem init ok\n");

    sdl_running=true;
    ADM_info("[SDL] Creating window (at %x,%d)\n",window->x,window->y);
    
    int nbDriver=listOfSDLDrivers.size();
    if(!nbDriver)
    {
        ADM_warning("[SDL] No driver loaded\n");
        return false;
    }
    if(sdlDriverIndex==-1 || sdlDriverIndex>=nbDriver)
    {
        ADM_warning("[SDL] No available driver found\n");
        return false;
    }
    
#if 0
    sdl_window = SDL_CreateWindow("avidemux_sdl2",
                          SDL_WINDOWPOS_UNDEFINED,
                          SDL_WINDOWPOS_UNDEFINED,
                          w, h,
                          SDL_WINDOW_BORDERLESS | SDL_WINDOW_FOREIGN*1);    
    SDL_SetWindowPosition(sdl_window,window->x,window->y);
#else
    sdl_window=SDL_CreateWindowFrom((void*)window->systemWindowId);
#endif    
    
    if(!sdl_window)
    {
        ADM_info("[SDL] Creating window failed!\n");
        ADM_warning("[SDL] ERROR: %s\n", SDL_GetError());
        cleanup();
        return false;
    }
    
    sdl_renderer = SDL_CreateRenderer(sdl_window, sdlDriverIndex, SDL_RENDERER_ACCELERATED |  SDL_RENDERER_PRESENTVSYNC);
    if(!sdl_renderer)
        sdl_renderer = SDL_CreateRenderer(sdl_window, sdlDriverIndex, 0);
    if(!sdl_renderer)
    {
        ADM_warning("[SDL] FAILED to create a renderer\n");
        cleanup();
        return false;
    }
    
    sdl_texture = SDL_CreateTexture(sdl_renderer,
                               SDL_PIXELFORMAT_YV12,
                               SDL_TEXTUREACCESS_STREAMING,
                               w, h);
    if(sdl_texture)
    {
        useYV12=true;
    }else
    {
        useYV12=false;
        sdl_texture = SDL_CreateTexture(sdl_renderer,
                               SDL_PIXELFORMAT_ARGB8888,
                               SDL_TEXTUREACCESS_STREAMING,
                               w, h);
        if(!sdl_texture)
        {
            ADM_warning("[SDL] FAILED to create a texture (rgb)\n");
            cleanup();
            return false;
        }
    }
    ADM_info("[SDL] Setting final size\n");
    changeZoom(zoom);
    ADM_info("[SDL] All init done.\n");
    return true;
}