示例#1
0
文件: cgco.cpp 项目: yujiali/pygco
extern "C" int gcoSetNeighborPair(int handle, SiteID s1, SiteID s2, EnergyTermType e)
{
    GCoptimizationGeneralGraph *gco = (GCoptimizationGeneralGraph*)findInstance(handle);
    if (s1 < s2)
        gco->setNeighbors(s1, s2, e);
    return 0;
}
// static
void JCFloaterAreaSearch::processObjectPropertiesFamily(LLMessageSystem* msg, void** user_data)
{
	JCFloaterAreaSearch* floater = findInstance();
	if(!floater)
		return;
	floater->checkRegion();

	LLUUID object_id;
	msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, object_id);

	std::set<LLUUID>::iterator it = floater->mPendingObjects.find(object_id);
	if(it != floater->mPendingObjects.end())
		floater->mPendingObjects.erase(it);
	//else if(floater->mCachedObjects.count(object_id)) //Let entries update.
	//	return;

	ObjectData* data = &floater->mCachedObjects[object_id];
	// We cache unknown objects (to avoid having to request them later)
	// and requested objects.
	msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_OwnerID, data->owner_id);
	msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_GroupID, data->group_id);
	msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, data->name);
	msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Description, data->desc);
	gCacheName->get(data->owner_id, false, boost::bind(&JCFloaterAreaSearch::results,floater));
	gCacheName->get(data->group_id, true, boost::bind(&JCFloaterAreaSearch::results,floater));
	//llinfos << "Got info for " << (exists ? "requested" : "unknown") << " object " << object_id << llendl;
}
示例#3
0
status_t OMX::getExtensionIndex(
        node_id node,
        const char *parameter_name,
        OMX_INDEXTYPE *index) {
    return findInstance(node)->getExtensionIndex(
            parameter_name, index);
}
// Callback when we rez a new object when the importer is running.
//static
void LLObjectBackup::newPrim(LLViewerObject* object)
{
	LLObjectBackup* self = findInstance();
	if (!object || !self || !self->mRunning) return;

	++self->mRezCount;
	self->mToSelect.push_back(object);
	self->updateImportNumbers();
	++self->mPrimImportIter;

	object->setPosition(self->offsetAgent(LLVector3(0.0, 1.0, 0.0)));
	LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_POSITION);

	if (self->mPrimImportIter != self->mThisGroup.endMap())
	{
		self->rezAgentOffset(LLVector3(1.0, 0.0 ,0.0));
	}
	else
	{
		LL_INFOS() << "All prims rezzed, moving to build stage" << LL_ENDL;
		// Deselecting is required to ensure that the first child prim in
		// the link set (which is also the last rezzed prim and thus
		// currently selected) will be properly renamed and desced.
		LLSelectMgr::getInstance()->deselectAll();
		self->mPrimImportIter = self->mThisGroup.beginMap();
		LLSD prim_llsd = self->mThisGroup[self->mPrimImportIter->first];
		self->mProcessIter = self->mToSelect.begin();
		self->xmlToPrim(prim_llsd, *(self->mProcessIter));
	}
}
示例#5
0
static int windowsInit()
{
#if ONLY_SINGLE_INSTANCE
	if (serviceOp == 0 && findInstance()) {
		mprError(MPR_L, MPR_USER, "Application %s is already active.", program);
		return MPR_ERR_BUSY;
	}
#endif

	//
	//	Create the window
	// 
	if (initWindow() < 0) {
		mprError(MPR_L, MPR_ERROR, "Can't initialize application Window");
		return MPR_ERR_CANT_INITIALIZE;
	}

	if (trayIcon > 0) {
		if (openTrayIcon() < 0 && mp->isService()) {
			trayTimer = new MprTimer(10 * 1000, trayIconProc, (void *) NULL);
		}
	}
	mprGetMpr()->setAsyncSelectMode(MPR_ASYNC_SELECT);
	return 0;
}
示例#6
0
int WP_TextureManager::getTexture(const string &name, void* owner, bool keepImages)
{
  //search texture list for instance of texture 'name'

  WP_Texture* tex = findInstance(name);
  if (tex)
    {
      tex->owners.push_back(owner); //another object is using this texture so add address to owners list
      return tex->texture_id;
    }

  //texture not in list, so load and add it

  tex = new WP_Texture(name,keepImages);
  if (tex)
    {
      if (tex->texture_ok)
	{
	  tex->owners.push_back(owner);
	  textures.push_back(tex);
	  return tex->texture_id;
	}
      else
	{
	  delete tex;
	}
    }
  cerr << "Error: Unable to get texture " << name << endl;
  return 0;
}
示例#7
0
status_t OMX::freeNode(node_id node) {
    OMXNodeInstance *instance = findInstance(node);

    {
        Mutex::Autolock autoLock(mLock);
        ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder());
        if (index < 0) {
            // This could conceivably happen if the observer dies at roughly the
            // same time that a client attempts to free the node explicitly.
            return OK;
        }
        mLiveNodes.removeItemsAt(index);
    }

    instance->observer()->asBinder()->unlinkToDeath(this);

    status_t err = instance->freeNode(mMaster);

    {
        Mutex::Autolock autoLock(mLock);
        ssize_t index = mDispatchers.indexOfKey(node);
        CHECK(index >= 0);
        mDispatchers.removeItemsAt(index);
    }

    return err;
}
示例#8
0
status_t OMX::setParameter(
        node_id node, OMX_INDEXTYPE index,
        const void *params, size_t size) {
    ALOGV("setParameter(%u %#x %p %zd)", node, index, params, size);
    return findInstance(node)->setParameter(
            index, params, size);
}
//static
bool LLFloaterReg::floaterInstanceMinimized(const LLSD& sdname)
{
	LLSD key;
	std::string name = sdname.asString();
	parse_name_key(name, key);
	LLFloater* instance = findInstance(name, key); 
	return LLFloater::isShown(instance);
}
示例#10
0
status_t OMX::setInternalOption(
        node_id node,
        OMX_U32 port_index,
        InternalOptionType type,
        const void *data,
        size_t size) {
    return findInstance(node)->setInternalOption(port_index, type, data, size);
}
示例#11
0
status_t OMX::emptyBuffer(
        node_id node,
        buffer_id buffer,
        OMX_U32 range_offset, OMX_U32 range_length,
        OMX_U32 flags, OMX_TICKS timestamp) {
    return findInstance(node)->emptyBuffer(
            buffer, range_offset, range_length, flags, timestamp);
}
示例#12
0
文件: cgco.cpp 项目: yujiali/pygco
extern "C" int gcoSetAllNeighbors(int handle, SiteID *s1, SiteID *s2, EnergyTermType *e, int nPairs)
{
    GCoptimizationGeneralGraph *gco = (GCoptimizationGeneralGraph*)findInstance(handle);
    for (int i = 0; i < nPairs; i++)
        if (s1[i] < s2[i])
            gco->setNeighbors(s1[i], s2[i], e[i]);
    return 0;
}
示例#13
0
文件: cgco.cpp 项目: yujiali/pygco
extern "C" int gcoExpansionOnAlpha(int handle, LabelID label, int *success)
{
    GCoptimization *gco = findInstance(handle);
    if (gco->alpha_expansion(label))
        *success = 1;
    else
        *success = 0;
    return 0;
}
//static
// returns true if the instance exists
bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) 
{ 
	LLFloater* instance = findInstance(name, key); 
	if (instance)
	{
		instance->closeHostedFloater();
	}
	return (instance != NULL);
}
示例#15
0
status_t OMX::freeNode(node_id node) {
    OMXNodeInstance *instance = findInstance(node);

    ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder());
    CHECK(index >= 0);
    mLiveNodes.removeItemsAt(index);
    instance->observer()->asBinder()->unlinkToDeath(this);

    return instance->freeNode(mMaster);
}
//static
LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) 
{
	LLFloater* res = findInstance(name, key);
	if (!res)
	{
		const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc;
//		const std::string& xui_file = sBuildMap[name].mFile;
// [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.5.0a
		const std::string& xui_file = (!sBuildMap[name].mFileFunc) ? sBuildMap[name].mFile : sBuildMap[name].mFileFunc();
// [/SL:KB]
		if (build_func)
		{
			const std::string& groupname = sGroupMap[name];
			if (!groupname.empty())
			{
				instance_list_t& list = sInstanceMap[groupname];

				res = build_func(key);
				if (!res)
				{
					LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
					return NULL;
				}
				bool success = res->buildFromFile(xui_file);
				if (!success)
				{
					LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL;
					return NULL;
				}

				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
				if (res->mKey.isUndefined()) 
				{
					res->mKey = key;
				}
				res->setInstanceName(name);
				
				LLFloater *last_floater = (list.empty() ? NULL : list.back());

				res->applyControlsAndPosition(last_floater);

				gFloaterView->adjustToFitScreen(res, false);

				list.push_back(res);
			}
		}
		if (!res)
		{
			LL_WARNS() << "Floater type: '" << name << "' not registered." << LL_ENDL;
		}
	}
	return res;
}
//static
// returns true if the instance is visible when completed
bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key)
{
	LLFloater* instance = findInstance(name, key); 
	if (LLFloater::isShown(instance))
	{
		instance->closeHostedFloater();
		return false;
	}
	else
	{
		return showInstance(name, key, TRUE) ? true : false;
	}
}
//static
bool LLObjectBackup::confirmCloseCallback(const LLSD& notification,
										  const LLSD& response)
{
	if (LLNotification::getSelectedOption(notification, response) == 0)
	{
		LLObjectBackup* self = findInstance();
		if (self)
		{
			self->destroy();
		}
	}
	return false;
}
示例#19
0
//static
LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) 
{
	LLFloater* res = findInstance(name, key);
	if (!res)
	{
		const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc;
		const std::string& xui_file = sBuildMap[name].mFile;
		if (build_func)
		{
			const std::string& groupname = sGroupMap[name];
			if (!groupname.empty())
			{
				instance_list_t& list = sInstanceMap[groupname];
				int index = list.size();

				res = build_func(key);
				
				bool success = res->buildFromFile(xui_file, NULL);
				if (!success)
				{
					llwarns << "Failed to build floater type: '" << name << "'." << llendl;
					return NULL;
				}
					
				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
				res->mKey = key;
				res->setInstanceName(name);
				res->applySavedVariables(); // Can't apply rect and dock state until setting instance name
				if (res->mAutoTile && !res->getHost() && index > 0)
				{
					const LLRect& cur_rect = res->getRect();
					LLRect next_rect = getFloaterRect(groupname);
					next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight());
					res->setRect(next_rect);
					res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters
					gFloaterView->adjustToFitScreen(res, true);
				}
				else
				{
					gFloaterView->adjustToFitScreen(res, false);
				}
				list.push_back(res);
			}
		}
		if (!res)
		{
			llwarns << "Floater type: '" << name << "' not registered." << llendl;
		}
	}
	return res;
}
//static
// returns true if the instance is visible when completed
bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key)
{
	LLFloater* instance = findInstance(name, key); 
	if (LLFloater::isShown(instance))
	{
		// When toggling *visibility*, close the host instead of the floater when hosted
		if (instance->getHost())
			instance->getHost()->closeFloater();
		else
			instance->closeFloater();
		return false;
	}
	else
	{
		return showInstance(name, key, TRUE) ? true : false;
	}
}
示例#21
0
OMX_ERRORTYPE OMX::OnEvent(
        node_id node,
        OMX_IN OMX_EVENTTYPE eEvent,
        OMX_IN OMX_U32 nData1,
        OMX_IN OMX_U32 nData2,
        OMX_IN OMX_PTR pEventData) {
    ALOGV("OnEvent(%d, %" PRIu32", %" PRIu32 ")", eEvent, nData1, nData2);

    // Forward to OMXNodeInstance.
    findInstance(node)->onEvent(eEvent, nData1, nData2);

    sp<OMX::CallbackDispatcher> dispatcher = findDispatcher(node);

    // output rendered events are not processed as regular events until they hit the observer
    if (eEvent == OMX_EventOutputRendered) {
        if (pEventData == NULL) {
            return OMX_ErrorBadParameter;
        }

        // process data from array
        OMX_VIDEO_RENDEREVENTTYPE *renderData = (OMX_VIDEO_RENDEREVENTTYPE *)pEventData;
        for (size_t i = 0; i < nData1; ++i) {
            omx_message msg;
            msg.type = omx_message::FRAME_RENDERED;
            msg.node = node;
            msg.fenceFd = -1;
            msg.u.render_data.timestamp = renderData[i].nMediaTimeUs;
            msg.u.render_data.nanoTime = renderData[i].nSystemTimeNs;

            dispatcher->post(msg, false /* realTime */);
        }
        return OMX_ErrorNone;
    }

    omx_message msg;
    msg.type = omx_message::EVENT;
    msg.node = node;
    msg.fenceFd = -1;
    msg.u.event_data.event = eEvent;
    msg.u.event_data.data1 = nData1;
    msg.u.event_data.data2 = nData2;

    dispatcher->post(msg, true /* realTime */);

    return OMX_ErrorNone;
}
示例#22
0
void SWProcess::addInstance(IPropertyTree *computerNode, IPropertyTree *parent, IPropertyTree *attrs, const char* instanceXMLTagName)
{

   IPropertyTree *instanceNode = NULL;
   StringBuffer xpath;
   if (m_singleInstanceList.find(m_name.str()) != NotFound)
   {
      xpath.clear().appendf("%s[1]", instanceXMLTagName);
      instanceNode = parent->queryPropTree(xpath.str());
   }
   else
   {
      instanceNode = findInstance(parent, computerNode);
   }

   if (!instanceNode)
   {
      // create instance
      instanceNode = createPTree(instanceXMLTagName);
      instanceNode->addProp("@computer", computerNode->queryProp(XML_ATTR_NAME));
      // get unique name

      StringBuffer sbName;
      if (String(instanceXMLTagName).indexOf("Master") > 0)
         sbName.append("m");
      else
         sbName.append("s");

      instanceNode->addProp(XML_ATTR_NAME, getUniqueName(parent, sbName, instanceXMLTagName, ""));
      instanceNode->addProp(m_ipAttribute.str(), computerNode->queryProp(XML_ATTR_NETADDRESS));
      parent->addPropTree(instanceXMLTagName, instanceNode);
   }

   StringArray excludeList;
   excludeList.append("ip");
   excludeList.append("ipfile");
   if (attrs)
      updateNode(instanceNode, attrs, &excludeList);

   checkInstanceAttributes(instanceNode, parent);

}
示例#23
0
status_t OMX::freeNode(node_id node) {
    OMXNodeInstance *instance = findInstance(node);

    ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder());
    CHECK(index >= 0);
    mLiveNodes.removeItemsAt(index);

    instance->observer()->asBinder()->unlinkToDeath(this);

    status_t err = instance->freeNode(mMaster);

    {
        Mutex::Autolock autoLock(mLock);
        index = mDispatchers.indexOfKey(node);
        CHECK(index >= 0);
        mDispatchers.removeItemsAt(index);
    }

    return err;
}
示例#24
0
void setInstance(const char	*str,	void *instance)	// set a named association with	this instance.
{
	void *mem	=	findInstance(str);

	assert(mem ==	0);	// this	should never happen?

	if (mem	== 0)
	{
		str	=	getGlobalString(str);	// convert it	to a global	string.

		gInstanceCount++;
		gInstanceMem +=	sizeof(InstanceList);

		InstanceList *il = new InstanceList;

		il->mNextInstance	=	gInstanceRoot;
		gInstanceRoot	=	il;
		il->mName	=	str;
		il->mInstance	=	instance;
	}

}
示例#25
0
OMX_ERRORTYPE OMX::OnEvent(
        node_id node,
        OMX_IN OMX_EVENTTYPE eEvent,
        OMX_IN OMX_U32 nData1,
        OMX_IN OMX_U32 nData2,
        OMX_IN OMX_PTR pEventData) {
    ALOGV("OnEvent(%d, %ld, %ld)", eEvent, nData1, nData2);

    // Forward to OMXNodeInstance.
    findInstance(node)->onEvent(eEvent, nData1, nData2);

    omx_message msg;
    msg.type = omx_message::EVENT;
    msg.node = node;
    msg.u.event_data.event = eEvent;
    msg.u.event_data.data1 = nData1;
    msg.u.event_data.data2 = nData2;

    findDispatcher(node)->post(msg);

    return OMX_ErrorNone;
}
				virtual bool apply(LLViewerObject* object)
				{
					bool is_attachment = object->isAttachment();
					object->boostTexturePriority(true);
					LLViewerObject::child_list_t children = object->getChildren();
					children.push_front(object); //push root onto list
					LLObjectBackup* self = findInstance();
					LLSD prim_llsd = self->primsToLLSD(children,
													   is_attachment);
					LLSD stuff;
					if (is_attachment)
					{
						stuff["root_position"] = object->getPositionEdit().getValue();
						stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotationEdit());
					}
					else
					{
						stuff["root_position"] = object->getPosition().getValue();
						stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation());
					}
					stuff["group_body"] = prim_llsd;
					self->mLLSD["data"].append(stuff);
					return true;
				}
示例#27
0
status_t OMX::fillBuffer(node_id node, buffer_id buffer) {
    return findInstance(node)->fillBuffer(buffer);
}
示例#28
0
status_t OMX::freeBuffer(node_id node, OMX_U32 port_index, buffer_id buffer) {
    return findInstance(node)->freeBuffer(
            port_index, buffer);
}
示例#29
0
status_t OMX::allocateBufferWithBackup(
        node_id node, OMX_U32 port_index, const sp<IMemory> &params,
        buffer_id *buffer) {
    return findInstance(node)->allocateBufferWithBackup(
            port_index, params, buffer);
}
示例#30
0
status_t OMX::allocateBuffer(
        node_id node, OMX_U32 port_index, size_t size,
        buffer_id *buffer, void **buffer_data) {
    return findInstance(node)->allocateBuffer(
            port_index, size, buffer, buffer_data);
}