-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
#include <dali/internal/render/gl-resources/texture-cache.h>
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 *********************
********************************************************************************/