Giter Site home page Giter Site logo

Comments (4)

irwinb avatar irwinb commented on May 13, 2024

I have temporarily fixed it by modifying CCTextureCache::addImageAsyncCallBack(ccTime dt)

void CCTextureCache::addImageAsyncCallBack(ccTime dt)
{
    // the image is generated in loading thread
    std::queue<ImageInfo*> *imagesQueue = s_pImageQueue;

    pthread_mutex_lock(&s_ImageInfoMutex);
    if (imagesQueue->empty())
    {
        pthread_mutex_unlock(&s_ImageInfoMutex);
    }
    else
    {
        ImageInfo *pImageInfo = imagesQueue->front();
        imagesQueue->pop();
        pthread_mutex_unlock(&s_ImageInfoMutex);

        AsyncStruct *pAsyncStruct = pImageInfo->asyncStruct;
        CCImage *pImage = pImageInfo->image;

        SelectorProtocol *target = pAsyncStruct->target;
        SEL_CallFuncO selector = pAsyncStruct->selector;
        const char* filename = pAsyncStruct->filename.c_str();

        // generate texture in render thread
        CCTexture2D *texture = new CCTexture2D();
        texture->initWithImage(pImage);

        // cache the texture
        m_pTextures->setObject(texture, filename);
        texture->autorelease();

        if (target && selector)
        {
#if CC_ENABLE_CACHE_TEXTTURE_DATA
            if ( std::string::npos != pImageInfo->asyncStruct->filename.find( ".jpg" ) 
                || std::string::npos != pImageInfo->asyncStruct->filename.find( ".jpeg" ) )
            {
                VolatileTexture::addImageTexture(texture, pImageInfo->asyncStruct->filename.c_str(), CCImage::kFmtJpg);
            } 
            else if ( std::string::npos != pImageInfo->asyncStruct->filename.find( ".pvr" ) )
            {
                // ?
            }
            else
            {
                VolatileTexture::addImageTexture(texture, pImageInfo->asyncStruct->filename.c_str(), CCImage::kFmtPng);
            }
#endif
            (target->*selector)(texture);
            target->selectorProtocolRelease();
        }       

        delete pImage;
        delete pAsyncStruct;
        delete pImageInfo;
    }
}

from cocos2d-x.

minggo avatar minggo commented on May 13, 2024

It caches data in addImageAsyncCallBack(), may be your code is too old.
Yes, addImageAsync() donesn't support pvr format now.

from cocos2d-x.

irwinb avatar irwinb commented on May 13, 2024

Oh yes, oops. Looks like I have an older version.

But for my last point, when removing unused textures for example, I don't see any calls to removing the texture from the "textures" container containing the VolatileTexture objects.

from cocos2d-x.

irwinb avatar irwinb commented on May 13, 2024

Neveremind..I see the call to remove it inside the CCTexture2D descructor.

from cocos2d-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.