Пример #1
0
void Content::dispose()
{
	if (_disposed)
		return;

	Ref<Content> safe = this;

	_disposed			= true;

	try
	{
		unload();
	}
	catch (Exception& ex)
	{
		LOG(0, "*** '%s': disposed but unload failed: %s", getSourceUrl().c_str(), ex.getFullDescription().c_str());
	}

	ContentManager* manager = getManager();
	if (manager)
		manager->onDispose(this);

	onDispose();

	_source			= NULL;
	_proxy				= NULL;
	_linked			= false;
	_loading			= false;
	_loaded			= false;

	if (hasCacheEntry())
		getCacheEntry()->discard();
}
Пример #2
0
PRInt32
nsCertTree::CmpBy(void *cache, nsIX509Cert *a, nsIX509Cert *b, 
                  sortCriterion c0, sortCriterion c1, sortCriterion c2)
{
  // This will be called when comparing items for display sorting.
  // Some items might have no cert associated, so either a or b is null.
  // We want all those orphans show at the top of the list,
  // so we treat a null cert as "smaller" by returning -1.
  // We don't try to sort within the group of no-cert entries,
  // so we treat them as equal wrt sort order.

  if (!a && !b)
    return 0;

  if (!a)
    return -1;

  if (!b)
    return 1;

  NS_ENSURE_TRUE( (cache!=0 && a!=0 && b!=0), 0 );

  CompareCacheHashEntry *ace = getCacheEntry(cache, a);
  CompareCacheHashEntry *bce = getCacheEntry(cache, b);

  PRInt32 cmp;
  cmp = CmpByCrit(a, ace, b, bce, c0, 0);
  if (cmp != 0)
    return cmp;

  if (c1 != sort_None) {
    cmp = CmpByCrit(a, ace, b, bce, c1, 1);
    if (cmp != 0)
      return cmp;
    
    if (c2 != sort_None) {
      return CmpByCrit(a, ace, b, bce, c2, 2);
    }
  }

  return cmp;
}
Пример #3
0
bool Font::drawString(const std::wstring& s, float x, float y)
{
    bool Ret = true;
    float penX = x, penY = y;
    uint32_t previousGlyph = 0;
    FT_Vector Delta;
    CacheEntry* theGlyph = NULL;
    std::size_t Length = s.length();

    for (std::size_t i = 0; i < Length; ++i)
    {
        if (mAutoCache)
            cacheChar(s[i]);

        //Special cases
        switch (s[i])
        {
        case L'\t':
            penX += spaceAdvance() * TabSize;
            previousGlyph = 0;
            continue;
        case L'\v':
            penY += mHeight * TabSize;
            previousGlyph = 0;
            continue;
        case L'\n':
            penY += mHeight;
            penX = x;
            previousGlyph = 0;
            continue;
        }
        theGlyph = getCacheEntry(s[i]);
        if (theGlyph == NULL)
        {
            Ret = false;
            previousGlyph = 0;
            continue;
        }
        //Kerning
        if (previousGlyph != 0 && mHaveKerning && mUseKerning)
        {
            FT_Get_Kerning(mFace, previousGlyph, theGlyph->glyphIndex, FT_KERNING_DEFAULT, &Delta);
            penX += Delta.x >> 6;
            penY += Delta.y >> 6;
        }
        if (!drawChar(s[i], penX, penY))
            Ret = false;

        penX += theGlyph->Advance;
        previousGlyph = theGlyph->glyphIndex;
    }
Пример #4
0
bool Font::drawChar(wchar_t charCode, float x, float y)
{
    if (mAutoCache)
        cacheChar(charCode);

    CacheEntry* theGlyph = getCacheEntry(charCode);
    if (NULL == theGlyph || NULL == theGlyph->Texture)
        return false;

    x += theGlyph->Left;
    y -= theGlyph->Top;

    mSprite->SetTexture(theGlyph->Texture);
    mSprite->SetTextureRect(0.0f, 0.0f, static_cast<float>(theGlyph->textureWidth), static_cast<float>(theGlyph->textureHeight));

    x += mHotSpotX * theGlyph->glyphWidth;
    y += mHotSpotY * theGlyph->glyphHeight;

    mSprite->SetHotSpot(mHotSpotX * theGlyph->glyphWidth, mHotSpotY * theGlyph->glyphHeight);
    mSprite->RenderEx(x, y, mRotation, mXScale, mYScale);
    mSprite->SetHotSpot(0.0f, 0.0f);
    return true;
}
Пример #5
0
    int realizeSubsystemDynamicsImpl(const State& s) const override {
        const MultibodySystem&        mbs    = getMultibodySystem();
        const SimbodyMatterSubsystem& matter = mbs.getMatterSubsystem();

        // Get access to the discrete state variable that records whether each
        // force element is enabled.
        const Array_<bool>& forceEnabled = Value< Array_<bool> >::downcast
                                    (getDiscreteVariable(s, forceEnabledIndex));
        const Array_<Force*>& enabledNonParallelForces = Value<Array_<Force*>>::
                      downcast(getCacheEntry(s, enabledNonParallelForcesIndex));
        const Array_<Force*>& enabledParallelForces = Value<Array_<Force*>>::
                         downcast(getCacheEntry(s, enabledParallelForcesIndex));

        // Get access to System-global force cache arrays.
        Vector_<SpatialVec>&   rigidBodyForces =
                                    mbs.updRigidBodyForces(s, Stage::Dynamics);
        Vector_<Vec3>&         particleForces  =
                                    mbs.updParticleForces (s, Stage::Dynamics);
        Vector&                mobilityForces  =
                                    mbs.updMobilityForces (s, Stage::Dynamics);

        // Short circuit if we're not doing any caching here. Note that we're
        // checking whether the *index* is valid (i.e. does the cache entry
        // exist?), not the contents.
        if (!cachedForcesAreValidCacheIndex.isValid()) {
            // Call calcForce() on all Forces, in parallel.
            calcForcesTask->initializeAll(s,
                    enabledNonParallelForces, enabledParallelForces,
                    rigidBodyForces, particleForces, mobilityForces);
            calcForcesExecutor->execute(calcForcesTask.updRef(),
                          enabledParallelForces.size() + NumNonParallelThreads);

            // Allow forces to do their own realization, but wait until all
            // forces have executed calcForce(). TODO: not sure if that is
            // necessary (sherm 20130716).
            for (int i = 0; i < (int)forces.size(); ++i)
                if (forceEnabled[i])
                    forces[i]->getImpl().realizeDynamics(s);
            return 0;
        }

        // OK, we're doing some caching. This is a little messier.
        // Get access to subsystem force cache entries.
        bool& cachedForcesAreValid = Value<bool>::updDowncast
                          (updCacheEntry(s, cachedForcesAreValidCacheIndex));

        Vector_<SpatialVec>&
            rigidBodyForceCache = Value<Vector_<SpatialVec> >::updDowncast
                                 (updCacheEntry(s, rigidBodyForceCacheIndex));
        Vector_<Vec3>&
            particleForceCache  = Value<Vector_<Vec3> >::updDowncast
                                 (updCacheEntry(s, particleForceCacheIndex));
        Vector&
            mobilityForceCache  = Value<Vector>::updDowncast
                                 (updCacheEntry(s, mobilityForceCacheIndex));


        if (!cachedForcesAreValid) {
            // We need to calculate the velocity independent forces.
            rigidBodyForceCache.resize(matter.getNumBodies());
            rigidBodyForceCache = SpatialVec(Vec3(0), Vec3(0));
            particleForceCache.resize(matter.getNumParticles());
            particleForceCache = Vec3(0);
            mobilityForceCache.resize(matter.getNumMobilities());
            mobilityForceCache = 0;

            // Run through all the forces, accumulating directly into the
            // force arrays or indirectly into the cache as appropriate.
            calcForcesTask->initializeCachedAndNonCached(s,
                                enabledNonParallelForces, enabledParallelForces,
                                rigidBodyForces, particleForces, mobilityForces,
                                rigidBodyForceCache, particleForceCache,
                                mobilityForceCache);
            calcForcesExecutor->execute(calcForcesTask.updRef(),
                          enabledParallelForces.size() + NumNonParallelThreads);
            cachedForcesAreValid = true;
        } else {
            // Cache already valid; just need to do the non-cached ones (the
            // ones for which dependsOnlyOnPositions is false).
            calcForcesTask->initializeNonCached(s,
                               enabledNonParallelForces, enabledParallelForces,
                               rigidBodyForces, particleForces, mobilityForces);
            calcForcesExecutor->execute(calcForcesTask.updRef(),
                          enabledParallelForces.size() + NumNonParallelThreads);
        }

        // Accumulate the values from the cache into the global arrays.
        rigidBodyForces += rigidBodyForceCache;
        particleForces += particleForceCache;
        mobilityForces += mobilityForceCache;

        // Allow forces to do their own Dynamics-stage realization. Note that
        // this *follows* all the calcForce() calls.
        for (int i = 0; i < (int) forces.size(); ++i)
            if (forceEnabled[i]) forces[i]->getImpl().realizeDynamics(s);
        return 0;
    }
Пример #6
0
bool Font::isCharCached(wchar_t charCode)
{
    return getCacheEntry(charCode) != NULL;
}