i.e. Disard refers to whether the data can be released after uploading.
ResourcePolicy::RETAIN does not mean that the data is externally owned.
Change-Id: I550f227e5463d677ba7e5ac5e889989360834089
TestPlatformAbstraction& platform = application.GetPlatform();
platform.SetClosestImageSize(Vector2( 16, 16));
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
unsigned int initialColor = 0xFF;
ids.push_back( textureId );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
{
// emulate load success
Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource( bitmap );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height, width, height );
if( request )
application.SendNotification(); // Flush update messages
application.Render(); // Process resource request
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80,80,80,80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
application.SendNotification(); // Flush update messages
application.Render(); // Process resource request
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, w, h, w, h );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Create a new resource - the image size could have changed in the meantime
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
DALI_TEST_CHECK( req->GetId() == ticket->GetId() );
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Create a new resource - the image size could have changed in the meantime
req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
DALI_TEST_CHECK( req->GetId() == id );
tet_infoline("Testing AddBitmap with reserved buffer()");
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGB565, 80, 80, 80, 80 );
Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
tet_infoline("Testing AddBitmap without reserved buffer()");
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
DALI_TEST_CHECK( imageTicket );
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 20, 20, 80, 80 );
Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
void LoadBitmapResource(TestPlatformAbstraction& platform)
{
Integration::ResourceRequest* request = platform.GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
Integration::ResourceRequest* request = platform.GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, initialImageSize.width,initialImageSize.height, initialImageSize.width,initialImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Now complete the image load
req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Now complete the image load
req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
tet_infoline("Test the successful loading of a nine-patch image\n");
platform.SetClosestImageSize(Vector2(4, 4));
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Integration::PixelBuffer* pixels = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 4,4,4,4 );
memset( pixels, 0, 64 );
tet_infoline("Test the successful loading of a nine-patch image added using ImageActor::SetImage()\n");
platform.SetClosestImageSize(Vector2(4, 4));
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Integration::PixelBuffer* pixels = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 4,4,4,4 );
memset( pixels, 0, 64 );
Integration::Bitmap* CreateBitmap( unsigned int imageHeight, unsigned int imageWidth, unsigned int initialColor, Pixel::Format pixelFormat )
{
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth,imageHeight,imageWidth,imageHeight );
unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
void LoadBitmapResource(TestPlatformAbstraction& platform)
{
Integration::ResourceRequest* request = platform.GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
if(request)
{
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD)));
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
}
application.Render(16);
Integration::Bitmap* CreateBitmap( unsigned int imageHeight, unsigned int imageWidth, unsigned int initialColor )
{
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, imageWidth,imageHeight,imageWidth,imageHeight );
unsigned int bytesPerPixel = GetBytesPerPixel( Pixel::RGBA8888 );
}
Bitmap* Bitmap::New( const Profile profile = BITMAP_2D_PACKED_PIXELS,
- ResourcePolicy::Discardable discardable = ResourcePolicy::DISCARD )
+ ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_DISCARD )
{
DALI_ASSERT_DEBUG(profile == BITMAP_2D_PACKED_PIXELS || profile == BITMAP_COMPRESSED);
void Bitmap::DiscardBuffer()
{
- if( mDiscardable == ResourcePolicy::DISCARD )
+ if( mDiscardable == ResourcePolicy::OWNED_DISCARD )
{
DeletePixelBuffer();
}
Bitmap::~Bitmap()
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- if( mDiscardable == ResourcePolicy::DISCARD )
+
+ // If owned
+ if( mDiscardable == ResourcePolicy::OWNED_DISCARD ||
+ mDiscardable == ResourcePolicy::OWNED_RETAIN )
{
DeletePixelBuffer();
}
* @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
* @param[in] pixBuf External buffer of pixel data or null.
*/
- Bitmap( ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN, Dali::Integration::PixelBuffer* pixBuf = 0 );
+ Bitmap( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = 0 );
/**
* Initializes internal class members
* wrap this in a reference-counting smart pointer or store it in a similarly
* automatic owning collection.
* @param[in] profile Defines required features of the bitmap (\sa Profile).
- * @param[in] discardable If this is set to DISCARD, the bitmap
- * object owns it's own buffer of pixel data and can delete it. If
- * it's set to RETAIN, then the lifetime of the pixel buffer is
- * managed by an external component and is guaranteed to remain
- * dereferenceable at least as long as the Bitmap remains alive.
- **/
+ * @param[in] discardable OWNED_DISCARD means that the data is owned by bitmap,
+ * and may released away after uploading to GPU.
+ * OWNED_RETAIN means that the data is owned and must be kept in CPU memory
+ * e.g. for an image that cannot be reloaded from disk.
+ * NOT_OWNED means that the data is managed by an external component and is
+ * guaranteed to remain dereferenceable at least as long as the Bitmap remains alive.
+ */
static Bitmap* New( Profile profile, ResourcePolicy::Discardable discardable );
/** \name GeneralFeatures
*/
bool IsDiscardable() const
{
- return mDiscardable == ResourcePolicy::DISCARD;
+ return mDiscardable == ResourcePolicy::OWNED_DISCARD;
}
/**
*/
enum DataRetention
{
- DALI_RETAINS_ALL_DATA, // retains Meshes and bitmaps
- DALI_RETAINS_MESH_DATA, // retains meshes, but discards bitmaps loaded from files
+ DALI_RETAINS_ALL_DATA, // retains all data e.g. bitmaps
DALI_DISCARDS_ALL_DATA, // discards all data (expects application to regenerate UI on context loss)
};
/**
- * The discardable policy describes whether a resource can be discarded (i.e. it is throw-away
- * or recoverable)
+ * The discardable policy describes whether a resource is owned or can be discarded.
+ * Discarded means that it can be released after uploading to GPU.
*/
enum Discardable
{
- DISCARD, // @todo Change to IS_RECOVERABLE?
- RETAIN
+ OWNED_DISCARD,
+ OWNED_RETAIN,
+ NOT_OWNED
};
} // namespace ResourcePolicy
RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
TextureCache& textureCache = mRenderManager->GetTextureCache();
- ResourcePolicy::Discardable discardPolicy = ResourcePolicy::DISCARD;
+ ResourcePolicy::Discardable discardPolicy = ResourcePolicy::OWNED_DISCARD;
if( dataRetentionPolicy == ResourcePolicy::DALI_RETAINS_ALL_DATA )
{
- discardPolicy = ResourcePolicy::RETAIN;
+ discardPolicy = ResourcePolicy::OWNED_RETAIN;
}
textureCache.SetDiscardBitmapsPolicy(discardPolicy);
mStage->Initialize();
- mResourceClient = new ResourceClient( *mResourceManager, *mStage, dataRetentionPolicy );
+ mResourceClient = new ResourceClient( *mResourceManager, *mStage );
mGestureEventProcessor = new GestureEventProcessor(*mStage, gestureManager, mRenderController);
mEventProcessor = new EventProcessor(*mStage, *mNotificationManager, *mGestureEventProcessor);
* Constructor
* @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
*/
- BitmapCompressed( ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN );
+ BitmapCompressed( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN );
virtual const Bitmap::CompressedProfile* GetCompressedProfile() const { return this; }
virtual Bitmap::CompressedProfile* GetCompressedProfile() { return this; }
Pixel::Format pixelFormat,
unsigned int bufferWidth,
unsigned int bufferHeight)
-: BitmapPackedPixel(ResourcePolicy::RETAIN, NULL/*pixBuf is externally owned*/),
+: BitmapPackedPixel(ResourcePolicy::NOT_OWNED, NULL/*pixBuf is externally owned*/),
mExternalData(pixBuf)
{
mImageWidth = width;
* Constructor
* @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
*/
- BitmapPackedPixel( ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN, Dali::Integration::PixelBuffer* pixBuf = 0 );
+ BitmapPackedPixel( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = 0 );
public:
virtual const Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() const { return this; }
struct ResourceClient::Impl
{
- Impl(ResourcePolicy::DataRetention dataRetentionPolicy)
- : mNextId(0),
- mDataRetentionPolicy( dataRetentionPolicy )
+ Impl()
+ : mNextId(0)
{
}
ResourceId mNextId;
TicketContainer mTickets;
BitmapCache mBitmaps;
- ResourcePolicy::DataRetention mDataRetentionPolicy;
};
ResourceClient::ResourceClient( ResourceManager& resourceManager,
- EventThreadServices& eventThreadServices,
- ResourcePolicy::DataRetention dataRetentionPolicy)
+ EventThreadServices& eventThreadServices)
: mResourceManager(resourceManager),
mEventThreadServices(eventThreadServices)
{
- mImpl = new ResourceClient::Impl(dataRetentionPolicy);
+ mImpl = new ResourceClient::Impl();
mResourceManager.SetClient(*this);
}
delete mImpl;
}
-ResourcePolicy::DataRetention ResourceClient::GetResourceDataRetentionPolicy()
-{
- return mImpl->mDataRetentionPolicy;
-}
-
ResourceTicketPtr ResourceClient::RequestResource(
const ResourceType& type,
const std::string& path,
Pixel::Format pixelformat )
{
/* buffer is available via public-api, therefore not discardable */
- Bitmap* const bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Bitmap* const bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Bitmap::PackedPixelsProfile* const packedBitmap = bitmap->GetPackedPixelsProfile();
DALI_ASSERT_DEBUG(packedBitmap);
* There should exactly one of these objects per Dali Core.
* @param[in] resourceManager The resource manager
* @param[in] eventThreadServices Used for messaging to and reading from scene-graph.
- * @param[in] dataRetentionPolicy The data retention policy of the current application
*/
ResourceClient( ResourceManager& resourceManager,
- EventThreadServices& eventThreadServices,
- ResourcePolicy::DataRetention dataRetentionPolicy );
+ EventThreadServices& eventThreadServices );
/**
* Virtual destructor.
virtual ~ResourceClient();
public:
- /**
- * Get the global data retention policy.
- * @return the global data retention policy
- */
- ResourcePolicy::DataRetention GetResourceDataRetentionPolicy();
/**
* Request a resource from the native filesystem.
void BitmapTexture::DiscardBitmapBuffer()
{
- DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, "BitmapTexture::DiscardBitmapBuffer() DiscardPolicy: %s\n", mDiscardPolicy == ResourcePolicy::DISCARD?"DISCARD":"RETAIN");
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, "BitmapTexture::DiscardBitmapBuffer() DiscardPolicy: %s\n", mDiscardPolicy == ResourcePolicy::OWNED_DISCARD?"DISCARD":"RETAIN");
- if( ResourcePolicy::DISCARD == mDiscardPolicy )
+ if( ResourcePolicy::OWNED_DISCARD == mDiscardPolicy )
{
DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, " Discarding bitmap\n");
mBitmap->DiscardBuffer();
{
AssignBitmap( false, pixels, mBitmap->GetBufferSize() );
- if( mDiscardPolicy == ResourcePolicy::DISCARD )
+ if( mDiscardPolicy == ResourcePolicy::OWNED_DISCARD )
{
mBitmap->DiscardBuffer();
}
: TextureCacheDispatcher(renderQueue),
mPostProcessResourceDispatcher(postProcessResourceDispatcher),
mContext(context),
- mDiscardBitmapsPolicy(ResourcePolicy::DISCARD)
+ mDiscardBitmapsPolicy(ResourcePolicy::OWNED_DISCARD)
{
}
void TextureCache::SetDiscardBitmapsPolicy( ResourcePolicy::Discardable policy )
{
DALI_LOG_INFO( gTextureCacheFilter, Debug::General, "TextureCache::SetDiscardBitmapsPolicy(%s)\n",
- policy==ResourcePolicy::RETAIN?"RETAIN":"DISCARD" );
+ policy==ResourcePolicy::OWNED_DISCARD?"DISCARD":"RETAIN" );
mDiscardBitmapsPolicy = policy;
}