X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fimages%2Fimage-factory.h;h=4f235ed5c1ae8afa8e9af2b5d6cb77647088528e;hb=b957389f498b906edc927d225502ab08851f25c2;hp=5232ccf71482f9c8364265b5f2cef2099fbbe061;hpb=2637b48f1dba3520a4a26f1b63fc25ddc5524abf;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/image-factory.h b/dali/internal/event/images/image-factory.h index 5232ccf..4f235ed 100644 --- a/dali/internal/event/images/image-factory.h +++ b/dali/internal/event/images/image-factory.h @@ -19,8 +19,9 @@ */ // INTERNAL INCLUDES -#include +#include #include +#include #include namespace Dali @@ -38,7 +39,7 @@ struct Request; /** * ImageFactory is an object that manages Image resource load requests. * It utilises an internal caching system where previous requests and associated - * resources are stored to avoid accessing the file system when not neccessary. + * resources are stored to avoid accessing the file system when not necessary. */ class ImageFactory : public ImageFactoryCache::RequestLifetimeObserver { @@ -67,10 +68,10 @@ public: /** * Issue a request which has already been registered with ImageFactory. * If the associated Ticket is no longer alive ImageFactory issues a resource load request. - * @param [in] req pointer to request + * @param [in] request Request to be loaded. * @return intrusive pointer to image ticket. If Load fails, returned pointer is invalid. (!ret) */ - ResourceTicketPtr Load( ImageFactoryCache::Request* req ); + ResourceTicketPtr Load( ImageFactoryCache::Request& request ); /** * Tells ResourceManager to reload image from filesystem. @@ -78,10 +79,38 @@ public: * This operation uses the originally requested attributes when reloading the image. * @pre req must be registered with ImageFactory * @note if image is still loading, no new load request will be issued - * @param [in] req Request pointer - * @return[out] the ResourceTicket mapped to the request + * @param[in] request Request to be reloaded. + * @return the ResourceTicket mapped to the request */ - ResourceTicketPtr Reload( ImageFactoryCache::Request* req ); + ResourceTicketPtr Reload( ImageFactoryCache::Request& request ); + + /** + * Ensures all filesystem images are reloaded into textures. + * This operation uses the originally requested attributes when reloading the image. + * + * Recovering from context loss does not change the number of tickets if the + * image size has changed on the file system since the last load/reload. + * + * If two different requests mapped to the same resource before, they will still + * map to the same resource after context regain even if there would be a better + * fitting texture. + * @pre requests must be registered with ImageFactory + * @note If an image is still loading, no new load request will be issued. + */ + void RecoverFromContextLoss(); + + /** + * Register an object into the context recovery list of the image factory. + * Thus its RecoverFromContextLoss() function would be called when the Stage regaining context. + * @param[in] object The object whose RecoverFromContextLoss() function needs to be called to regain the context. + */ + void RegisterForContextRecovery( ContextRecoveryInterface* object ); + + /** + * Unregister an object from the context recovery list of the image factory + * @param[in] object The object whose RecoverFromContextLoss() function needs to be called to regain the context. + */ + void UnregisterFromContextRecovery( ContextRecoveryInterface* object ); /** * Get resource path used in request. @@ -151,8 +180,8 @@ private: * @param [in] actual The actual attributes * @return True if the attributes are compatible */ - bool CompareAttributes( const Dali::ImageAttributes& requested, - const Dali::ImageAttributes& actual ) const; + bool CompareAttributes( const ImageAttributes& requested, + const ImageAttributes& actual ) const; /** * Inserts a new request to the request cache and url cache. @@ -191,13 +220,22 @@ private: */ ResourceTicketPtr IssueLoadRequest( const std::string& filename, const ImageAttributes* attributes ); + /** + * Looks-up the hash of the string locator of the already-registered Request + * passed in. + * @param[in] request The image load request to return a locator string hash for. + * @return The hash of the locator string used in the request. + */ + std::size_t GetHashForCachedRequest( const ImageFactoryCache::Request& request ); + private: - ResourceClient& mResourceClient; - ImageFactoryCache::RequestPathHashMap mUrlCache; ///< A multimap of url hashes and request IDs - ImageFactoryCache::RequestIdMap mRequestCache; ///< A map of request IDs and request information. - ResourceTicketContainer mTicketsToRelease; ///< List of ticket handles - float mMaxScale; ///< Defines maximum size difference between compatible resources - ImageFactoryCache::RequestId mReqIdCurrent; ///< Internal counter for Request IDs + ResourceClient& mResourceClient; + ImageFactoryCache::RequestPathHashMap mUrlCache; ///< A multimap of url hashes and request IDs + ImageFactoryCache::RequestIdMap mRequestCache; ///< A map of request IDs and request information. + ResourceTicketContainer mTicketsToRelease; ///< List of ticket handles + Vector mContextRecoveryList; ///< List of the objects who needs context recovery + float mMaxScale; ///< Defines maximum size difference between compatible resources + ImageFactoryCache::RequestId mReqIdCurrent; ///< Internal counter for Request IDs }; } // namespace Internal