using Dali::Internal::FrameBufferTexture;
using Dali::Integration::Bitmap;
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gTextureCacheFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TEXTURE_CACHE");
+#endif
+}
+
+
namespace Dali
{
namespace Internal
Context& context)
: TextureCacheDispatcher(renderQueue),
mPostProcessResourceDispatcher(postProcessResourceDispatcher),
- mContext(context)
+ mContext(context),
+ mDiscardBitmapsPolicy(ResourcePolicy::DISCARD)
{
}
{
DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::CreateTexture(id=%i width:%u height:%u)\n", id, width, height);
- Texture* texture = TextureFactory::NewBitmapTexture(width, height, pixelFormat, clearPixels, mContext);
+ Texture* texture = TextureFactory::NewBitmapTexture(width, height, pixelFormat, clearPixels, mContext, GetDiscardBitmapsPolicy() );
mTextures.insert(TexturePair(id, texture));
}
{
DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddBitmap(id=%i Bitmap:%p)\n", id, bitmap.Get());
- Texture* texture = TextureFactory::NewBitmapTexture(bitmap.Get(), mContext);
+ Texture* texture = TextureFactory::NewBitmapTexture(bitmap.Get(), mContext, GetDiscardBitmapsPolicy());
mTextures.insert(TexturePair(id, texture));
}
TexturePointer texturePtr = textureIter->second;
if( texturePtr )
{
- texturePtr->Update(bitmap.Get());
+ texturePtr->Update( bitmap.Get() );
ResourcePostProcessRequest ppRequest( id, ResourcePostProcessRequest::UPLOADED );
mPostProcessResourceDispatcher.DispatchPostProcessRequest(ppRequest);
}
}
-void TextureCache::BindTexture( Texture *texture, ResourceId id, GLenum target, GLenum textureunit )
+void TextureCache::BindTexture( Texture *texture, ResourceId id, GLenum target, TextureUnit textureunit )
{
bool created = texture->Bind(target, textureunit);
if( created && texture->UpdateOnCreate() ) // i.e. the pixel data was sent to GL
{
(*iter->second).GlContextDestroyed(); // map holds intrusive pointers
}
+
+ end = mFramebufferTextures.end();
+ iter = mFramebufferTextures.begin();
+ for( ; iter != end; ++iter )
+ {
+ (*iter->second).GlContextDestroyed(); // map holds intrusive pointers
+ }
+}
+
+void TextureCache::SetDiscardBitmapsPolicy( ResourcePolicy::Discardable policy )
+{
+ DALI_LOG_INFO( gTextureCacheFilter, Debug::General, "TextureCache::SetDiscardBitmapsPolicy(%s)\n",
+ policy==ResourcePolicy::RETAIN?"RETAIN":"DISCARD" );
+ mDiscardBitmapsPolicy = policy;
}
+ResourcePolicy::Discardable TextureCache::GetDiscardBitmapsPolicy()
+{
+ return mDiscardBitmapsPolicy;
+}
+
+
/********************************************************************************
********************** Implements TextureCacheDispatcher *********************
********************************************************************************/