Exemple #1
0
void CtrlVideo::onUpdate( Subject<VarBool> &rVariable, void *arg  )
{
    // Visibility changed
    if( &rVariable == m_pVisible )
    {
        msg_Dbg( getIntf(), "VideoCtrl : Visibility changed (visible=%d)",
                                  isVisible() );
    }

    // Active Layout changed
    if( &rVariable == &m_pLayout->getActiveVar() )
    {
        msg_Dbg( getIntf(), "VideoCtrl : Active Layout changed (isActive=%d)",
                      m_pLayout->getActiveVar().get() );
    }

    m_bIsUseable = isVisible() && m_pLayout->getActiveVar().get();

    if( m_bIsUseable && !isUsed() )
    {
        VoutManager::instance( getIntf() )->requestVout( this );
    }
    else if( !m_bIsUseable && isUsed() )
    {
        VoutManager::instance( getIntf() )->discardVout( this );
    }
}
int DecodedMux::HowManyTextures()
{
    int n=0;
    if( isUsed(MUX_TEXEL0) ) n++;
    if( isUsed(MUX_TEXEL1) ) n++;
    return n;
}
Exemple #3
0
void CtrlVideo::onUpdate( Subject<VarBool> &rVariable, void *arg  )
{
    (void)arg;

    // Visibility changed
    if( &rVariable == m_pVisible )
    {
        msg_Dbg( getIntf(), "VideoCtrl : Visibility changed (visible=%d)",
                                  isVisible() );
        notifyLayout();
    }

    // Active Layout changed
    if( &rVariable == &m_pLayout->getActiveVar() )
    {
        msg_Dbg( getIntf(), "VideoCtrl : Active Layout changed (isActive=%d)",
                      m_pLayout->getActiveVar().get() );
    }

    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
    if( &rVariable == &rFullscreen )
    {
        msg_Dbg( getIntf(), "VideoCtrl : fullscreen toggled (fullscreen = %d)",
                      rFullscreen.get() );
    }

    if( isUseable() && !isUsed() )
    {
        VoutManager::instance( getIntf() )->requestVout( this );
    }
    else if( !isUseable() && isUsed() )
    {
        VoutManager::instance( getIntf() )->discardVout( this );
    }
}
int DecodedMux::HowManyConstFactors()
{
    int n=0;
    if( isUsed(MUX_PRIM) ) n++;
    if( isUsed(MUX_ENV) ) n++;
    if( isUsed(MUX_LODFRAC) ) n++;
    if( isUsed(MUX_PRIMLODFRAC) ) n++;
    return n;
}
void DecodedMux::Simplify(void)
{
    CheckCombineInCycle1();
    if( gRDP.otherMode.text_lod )
        ConvertLODFracTo0();
    if( g_curRomInfo.bTexture1Hack )
    {
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,2);
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,3);
    }
    Reformat();

    UseShadeForConstant();
    Reformat();

    if( m_dwShadeColorChannelFlag == MUX_0 )
    {
        MergeShadeWithConstants();
        Reformat();
    }

#ifdef ALLOW_USE_TEXTURE_FOR_CONSTANTS
    UseTextureForConstant();
    for( int i=0; i<2; i++ )
    {
        if( m_ColorTextureFlag[i] != 0 )
        {
            if( m_dwShadeColorChannelFlag == m_ColorTextureFlag[i] )
            {
                ReplaceVal(MUX_SHADE,MUX_TEXEL0+i,N64Cycle0RGB);
                ReplaceVal(MUX_SHADE,MUX_TEXEL0+i,N64Cycle1RGB);
                m_dwShadeColorChannelFlag = 0;
            }
            if( m_dwShadeAlphaChannelFlag == m_ColorTextureFlag[i] )
            {
                ReplaceVal(MUX_SHADE,MUX_TEXEL0+i,N64Cycle0Alpha);
                ReplaceVal(MUX_SHADE,MUX_TEXEL0+i,N64Cycle1Alpha);
                ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE,(MUX_TEXEL0+i)|MUX_ALPHAREPLICATE,N64Cycle0RGB,MUX_MASK_WITH_ALPHA);
                ReplaceVal(MUX_SHADE|MUX_ALPHAREPLICATE,(MUX_TEXEL0+i)|MUX_ALPHAREPLICATE,N64Cycle1RGB,MUX_MASK_WITH_ALPHA);
                m_dwShadeAlphaChannelFlag = 0;
            }
        }
    }
    Reformat();
#endif

    m_bTexel0IsUsed = isUsed(MUX_TEXEL0);
    m_bTexel1IsUsed = isUsed(MUX_TEXEL1);
}
void DecodedMux::UseTextureForConstant(void)
{
    int numofconst = HowManyConstFactors();
    int numOftex = HowManyTextures();

    if( numofconst > m_maxConstants && numOftex < m_maxTextures )
    {
        // We can use a texture for a constant
        for( int i=0; i<2 && numofconst > m_maxConstants ; i++ )
        {
            if( isUsed(MUX_TEXEL0+i) )
            {
                continue;   // can not use this texture
            }

            if( isUsed(MUX_PRIM) )
            {
                ReplaceVal(MUX_PRIM, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_PRIM;
                numofconst--;
                continue;
            }

            if( isUsed(MUX_ENV) )
            {
                ReplaceVal(MUX_ENV, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_ENV;
                numofconst--;
                continue;
            }

            if( isUsed(MUX_LODFRAC) )
            {
                ReplaceVal(MUX_LODFRAC, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_LODFRAC;
                numofconst--;
                continue;
            }

            if( isUsed(MUX_PRIMLODFRAC) )
            {
                ReplaceVal(MUX_PRIMLODFRAC, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_PRIMLODFRAC;
                numofconst--;
                continue;
            }
        }
    }
}
void DecodedMuxForOGL14V2::UseTextureForConstant(void)
{
    bool envused = isUsed(MUX_ENV);
    bool lodused = isUsed(MUX_LODFRAC);
    
    int numofconst = 0;
    if( envused ) numofconst++;
    if( lodused ) numofconst++;

    int numOftex = HowManyTextures();

    if( numofconst > 0 && numOftex < 2 )
    {
        // We can use a texture for a constant
        for( int i=0; i<2 && numofconst > 0 ; i++ )
        {
            if( isUsed(MUX_TEXEL0+i) )
            {
                continue;   // can not use this texture
            }

            if( envused )
            {
                ReplaceVal(MUX_ENV, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_ENV;
                numofconst--;
                envused = false;
                continue;
            }

            if( isUsed(MUX_LODFRAC) )
            {
                ReplaceVal(MUX_LODFRAC, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_LODFRAC;
                numofconst--;
                continue;
            }

            if( isUsed(MUX_PRIMLODFRAC) )
            {
                ReplaceVal(MUX_PRIMLODFRAC, MUX_TEXEL0+i);
                m_ColorTextureFlag[i] = MUX_PRIMLODFRAC;
                numofconst--;
                continue;
            }
        }
    }
}
/**
* @brief Removes unused global variables from the module.
*/
void UnusedGlobalVarOptimizer::removeUnusedGlobalVars() {
	for (auto &var : globalVars) {
		if (!isUsed(var)) {
			module->removeGlobalVar(var);
		}
	}
}
Exemple #9
0
bool ContextMap::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
	_argc = argc;
	_argv = argv;
	_skipFirstArgs = skipFirstArgs;
	if (_argc < 2) {
		setShowHelp(true);
		return false;
	}

	setProgram(_programNames[argv[0]]);

	_argsProcessed.resize(_argc - _skipFirstArgs, false);

	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
        else if (strcmp(_argv[_i], "-o") == 0) {
			if (!handle_o()) return false;
        }
        else if (strcmp(_argv[_i], "-c") == 0) {
			if (!handle_c()) return false;
        }
        else if (strcmp(_argv[_i], "-null") == 0) {
			if (!handle_null()) return false;
        }
	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
bool ContextGroupBy::parseCmdArgs(int argc, char **argv, int skipFirstArgs)
{
	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		else if ((strcmp(_argv[_i], "-g") == 0) || (strcmp(_argv[_i], "-grp") == 0)) {
			if (!handle_g()) return false;
		}
		else if (strcmp(_argv[_i], "-inheader") == 0) {
			if (!handle_inheader()) return false;
		}
		else if (strcmp(_argv[_i], "-outheader") == 0) {
			if (!handle_outheader()) return false;
		}
		else if (strcmp(_argv[_i], "-header") == 0) {
			if (!handle_header()) return false;
		}
		else if (strcmp(_argv[_i], "-full") == 0) {
			if (!handle_full()) return false;
		}
		else if (strcmp(_argv[_i], "-ignorecase") == 0) {
			if (!handle_ignorecase()) return false;
		}
	}
	return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs);
}
Exemple #11
0
int getMaxGain(int parent, int S, int values[LENGTH][LENGTH], int nvalues, int nattributes, att * test)
{
	float max=0;
	int maxAtt;
	int i;
	float gain;

	for(i=-1; i>-nattributes; i--)
	{
		if(isUsed(i, test)==0)
		{
			gain=getGain(parent, S, i, values, nvalues, nattributes, test);
			printf("Gain of %d and %d is %lf\n", S, i, gain);
			if(gain>max)
			{
				max=gain;
				maxAtt=i;
			}
		}
	}
	if (max==0)
	{
		int pos=positiveValues(0, S, values, nvalues, nattributes, test);
		int neg=negativeValues(0, S, values, nvalues, nattributes, test);
		if (pos>neg)
		{
			maxAtt=100;
		}
		else
		{
			maxAtt=101;
		}
	}
	return maxAtt;
}
Exemple #12
0
void NetSignal::updateErcMessages() noexcept {
  if (mIsAddedToCircuit && (!isUsed())) {
    if (!mErcMsgUnusedNetSignal) {
      mErcMsgUnusedNetSignal.reset(
          new ErcMsg(mCircuit.getProject(), *this, mUuid.toStr(), "Unused",
                     ErcMsg::ErcMsgType_t::CircuitError, QString()));
    }
    mErcMsgUnusedNetSignal->setMsg(
        QString(tr("Unused net signal: \"%1\"")).arg(*mName));
    mErcMsgUnusedNetSignal->setVisible(true);
  } else if (mErcMsgUnusedNetSignal) {
    mErcMsgUnusedNetSignal.reset();
  }

  if (mIsAddedToCircuit && (mRegisteredComponentSignals.count() < 2)) {
    if (!mErcMsgConnectedToLessThanTwoPins) {
      mErcMsgConnectedToLessThanTwoPins.reset(new ErcMsg(
          mCircuit.getProject(), *this, mUuid.toStr(),
          "ConnectedToLessThanTwoPins", ErcMsg::ErcMsgType_t::CircuitWarning));
    }
    mErcMsgConnectedToLessThanTwoPins->setMsg(
        QString(tr("Net signal connected to less than two pins: \"%1\""))
            .arg(*mName));
    mErcMsgConnectedToLessThanTwoPins->setVisible(true);
  } else if (mErcMsgConnectedToLessThanTwoPins) {
    mErcMsgConnectedToLessThanTwoPins.reset();
  }
}
void DecodedMuxForOGL14V2::Simplify(void)
{
    CheckCombineInCycle1();
    if( g_curRomInfo.bTexture1Hack )
    {
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,2);
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,3);
    }
    Reformat();

    UseTextureForConstant();
    Reformat();

    m_bTexel0IsUsed = isUsed(MUX_TEXEL0);
    m_bTexel1IsUsed = isUsed(MUX_TEXEL1);
}
	void VulkanResource::notifyUsed(UINT32 globalQueueIdx, UINT32 queueFamily, VulkanUseFlags useFlags)
	{
		Lock lock(mMutex);
		assert(useFlags != VulkanUseFlag::None);

		if(isUsed() && mState == State::Normal) // Used without support for concurrency
		{
			assert(mQueueFamily == queueFamily &&
				"Vulkan resource without concurrency support can only be used by one queue family at once.");
		}

		mNumUsedHandles++;
		mQueueFamily = queueFamily;

		assert(globalQueueIdx < MAX_UNIQUE_QUEUES);
		
		if (useFlags.isSet(VulkanUseFlag::Read))
		{
			assert(mReadUses[globalQueueIdx] < 255 && "Resource used in too many command buffers at once.");
			mReadUses[globalQueueIdx]++;
		}
		
		if(useFlags.isSet(VulkanUseFlag::Write))
		{
			assert(mWriteUses[globalQueueIdx] < 255 && "Resource used in too many command buffers at once.");
			mWriteUses[globalQueueIdx]++;
		}
	}
Exemple #15
0
bool ContextMap::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
	_argc = argc;
	_argv = argv;
	_skipFirstArgs = skipFirstArgs;
	if (_argc < 2) {
		setShowHelp(true);
		return false;
	}

	setProgram(_programNames[argv[0]]);

	_argsProcessed.resize(_argc - _skipFirstArgs, false);

	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		if (strcmp(_argv[_i], "-c") == 0) {
			//bypass intersect's use of the -c option, because -c
			//means writeCount for intersect, but means columns for map.
			if (!ContextBase::handle_c()) return false;
		}

	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
Exemple #16
0
void NetSignal::addToCircuit() {
  if (mIsAddedToCircuit || isUsed()) {
    throw LogicError(__FILE__, __LINE__);
  }
  mNetClass->registerNetSignal(*this);  // can throw
  mIsAddedToCircuit = true;
  updateErcMessages();
}
Exemple #17
0
bool ContextBase::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
	_argc = argc;
	_argv = argv;
	_skipFirstArgs = skipFirstArgs;
	if (_argc < 2) {
		setShowHelp(true);
		return false;
	}

	setProgram(_programNames[argv[0]]);

	_argsProcessed.resize(_argc - _skipFirstArgs, false);

	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}

		if (strcmp(_argv[_i], "-i") == 0) {
			if (!handle_i()) return false;
		}
		else if (strcmp(_argv[_i], "-g") == 0) {
			if (!handle_g()) return false;
		}
		else if ((strcmp(_argv[_i], "-h") == 0) || (strcmp(_argv[_i], "--help") == 0)) {
			if (!handle_h()) return false;
		}
		else if (strcmp(_argv[_i], "-split") == 0) {
			if (!handle_split()) return false;
		}
        else if (strcmp(_argv[_i], "-bed") == 0) {
			if (!handle_bed()) return false;
       }
        else if (strcmp(_argv[_i], "-ubam") == 0) {
			if (!handle_ubam()) return false;
        }
        else if (strcmp(_argv[_i], "-fbam") == 0) {
			if (!handle_fbam()) return false;
        }
        else if(strcmp(_argv[_i], "-sorted") == 0) {
			if (!handle_sorted()) return false;
        }
        else if (strcmp(_argv[_i], "-nobuf") == 0) {
			if (!handle_nobuf()) return false;
        }
        else if (strcmp(_argv[_i], "-header") == 0) {
			if (!handle_header()) return false;
        }
        else if (strcmp(_argv[_i], "-n") == 0) {
			if (!handle_n()) return false;
        }
        else if (strcmp(_argv[_i], "-seed") == 0) {
			if (!handle_seed()) return false;
        }
	}
	return true;
}
std::string UniqueNameSet::makeUnique(const std::string& name) {
	if (!isUsed(name) && !name.empty() && name[name.size()-1] != '_') {
		addUsedName(name);
		return name;
	}

	int i = 1;
	std::string name2;
	do {
		std::stringstream s;
		s << name << (i++);
		name2 = s.str();
	} while (isUsed(name2));

	addUsedName(name2);

	return name2;
}
Exemple #19
0
void SingleValueOption::setValue(const std::string& v)
{
	if(isUsed() && value != v) {
		std::ostringstream ss;
		ss << "Option '" << getName() << "' only takes a single value, but more than one was specified.";
		throw std::runtime_error(ss.str());
	}
	value = v;
}
Exemple #20
0
void FileLogger::logString(const char* buf, size_t len)
{
  if (!isUsed())
    return;

  if (len == kInvalidSize)
    len = strlen(buf);

  fwrite(buf, 1, len, _stream);
}
void DecodedMuxForPixelShader::Simplify(void)
{
    CheckCombineInCycle1();
    //Reformat();

    if( g_curRomInfo.bTexture1Hack )
    {
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,2);
        ReplaceVal(MUX_TEXEL1,MUX_TEXEL0,3);
    }
    splitType[0] = CM_FMT_TYPE_NOT_USED;
    splitType[1] = CM_FMT_TYPE_NOT_USED;
    splitType[2] = CM_FMT_TYPE_NOT_USED;
    splitType[3] = CM_FMT_TYPE_NOT_USED;
    mType = CM_FMT_TYPE_NOT_USED;

    m_bTexel0IsUsed = isUsed(MUX_TEXEL0);
    m_bTexel1IsUsed = isUsed(MUX_TEXEL1);
}
Exemple #22
0
void BI_Via::removeFromBoard(GraphicsScene& scene) throw (Exception)
{
    if ((!isAddedToBoard()) || isUsed()) {
        throw LogicError(__FILE__, __LINE__);
    }
    if (mNetSignal) {
        mNetSignal->unregisterBoardVia(*this); // can throw
    }
    BI_Base::removeFromBoard(scene, *mGraphicsItem);
}
Exemple #23
0
void Task_Implement::runTask()
{
	runBeforce();
	if (isUsed()){
		run();
	}
	else{
		runFailed();
	}
	runAfter();
}
Exemple #24
0
bool ContextFisher::parseCmdArgs(int argc, char **argv, int skipFirstArgs)
{
	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		else if (strcmp(_argv[_i], "-exclude") == 0) {
			if (!handle_exclude()) return false;
		}
	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
Exemple #25
0
void BasePlayerInfo::Serialize(Serializer& ser, bool lightData) const
{
    ser.PushUnsignedChar(static_cast<unsigned char>(ps));
    if(lightData && !isUsed())
        return;
    if(!lightData || ps == PS_AI)
        aiInfo.serialize(ser);
    ser.PushString(name);
    ser.PushUnsignedChar(static_cast<unsigned char>(nation));
    ser.PushUnsignedInt(color);
    ser.PushUnsignedChar(static_cast<unsigned char>(team));
}
bool ContextSample::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
    for (_i=_skipFirstArgs; _i < argc; _i++) {
        if (isUsed(_i - _skipFirstArgs)) {
            continue;
        }

        else if (strcmp(_argv[_i], "-s") == 0) {
            if (!handle_s()) return false;
        }
    }
    return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs);
}
Exemple #27
0
int32_t Remap::Map(int32_t pred,int32_t err)
{
  int sgn=1;
  if (err==0) return 0;
  if (err<0) {err=-err;sgn=-1;};

  int merr=0;
  for (int i=1;i<=err;i++) {
    if (isUsed(pred+(sgn*i))) merr++;
  }
  return sgn*merr;
}
Exemple #28
0
bool ContextBase::cmdArgsValid()
{
	bool retval = true;
	for (_i = _skipFirstArgs; _i < _argc; _i++) {
		if (!isUsed(_i - _skipFirstArgs)) {
			_errorMsg += "\n***** ERROR: Unrecognized parameter: ";
			_errorMsg += _argv[_i];
			_errorMsg += " *****";
			retval = false;
		}
	}
	return retval;
}
Exemple #29
0
void MidiInterface::autoconnect()
{
    if(isUsed())
    {
        if(!_connected)
            open();
    }
    else
    {
        if(_connected)
            close();
    }
}
Exemple #30
0
void NetSignal::removeFromCircuit() {
  if (!mIsAddedToCircuit) {
    throw LogicError(__FILE__, __LINE__);
  }
  if (isUsed()) {
    throw RuntimeError(__FILE__, __LINE__,
                       QString(tr("The net signal \"%1\" cannot be removed "
                                  "because it is still in use!"))
                           .arg(*mName));
  }
  mNetClass->unregisterNetSignal(*this);  // can throw
  mIsAddedToCircuit = false;
  updateErcMessages();
}