ResourceLoadingClient& operator =( ResourceLoadingClient& rhs );
};
+/**
+ * @brief Default implementation of a caller of a low-level resource loading
+ * function which does nothing.
+ */
+class StubbedResourceLoadingClient : public ResourceLoadingClient
+{
+public:
+ /**
+ * @brief Check whether the current request has been cancelled.
+ *
+ * This does nothing and so can never throw an exception.
+ **/
+ virtual void InterruptionPoint() const {}
+
+ /** Construction is a NOP. */
+ StubbedResourceLoadingClient() {}
+ /** Destruction has no work to do. */
+ ~StubbedResourceLoadingClient() {}
+
+private:
+ StubbedResourceLoadingClient( const StubbedResourceLoadingClient& rhs );
+ StubbedResourceLoadingClient& operator =( StubbedResourceLoadingClient& rhs );
+};
+
} /* namespace SlpPlatform */
} /* namespace Dali */
FILE * const fp = fopen( resourcePath.c_str(), "rb" );
if( fp != NULL )
{
- bool result = ConvertStreamToBitmap( resourceType, resourcePath, fp, bitmap );
+ bool result = ConvertStreamToBitmap( resourceType, resourcePath, fp, StubbedResourceLoadingClient(), bitmap );
if( result && bitmap )
{
resource.Reset(bitmap.Get());
if( fp != NULL )
{
- result = ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, bitmap );
+ result = ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, *this, bitmap );
// Last chance to interrupt a cancelled load before it is reported back to clients
// which have already stopped tracking it:
InterruptionPoint(); // Note: This can throw an exception.
FILE * const fp = fileCloser.GetFile();
if ( fp != NULL )
{
- bool result = ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, bitmap );
+ bool result = ConvertStreamToBitmap( *request.GetType(), request.GetPath(), fp, StubbedResourceLoadingClient(), bitmap );
if ( result && bitmap )
{
DALI_LOG_WARNING( "Image saving not supported on background resource threads." );
}
-bool ResourceThreadImage::ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, FILE * const fp, BitmapPtr& ptr)
+bool ResourceThreadImage::ConvertStreamToBitmap(const ResourceType& resourceType, std::string path, FILE * const fp, const ResourceLoadingClient& client, BitmapPtr& ptr)
{
DALI_LOG_TRACE_METHOD(mLogFilter);
DALI_ASSERT_DEBUG( ResourceBitmap == resourceType.id );
ImageAttributes attributes = resType.imageAttributes;
// Check for cancellation now we have hit the filesystem, done some allocation, and burned some cycles:
- InterruptionPoint(); // Note: This can throw an exception.
+ client.InterruptionPoint(); // Note: This can throw an exception.
- result = function( fp, *bitmap, attributes, *this );
+ result = function( fp, *bitmap, attributes, client );
if (!result)
{
// Make a new bitmap with the central part of the loaded one if required:
if( scanlinesToTrim > 0 || columnsToTrim > 0 ) ///@ToDo: Make this test a bit fuzzy (allow say a 5% difference).
{
- InterruptionPoint(); // Note: This can throw an exception.
+ client.InterruptionPoint(); // Note: This can throw an exception.
const unsigned newWidth = loadedWidth - 2 * columnsToTrim;
const unsigned newHeight = loadedHeight - 2 * scanlinesToTrim;
* @param[in] resourceType The type of resource to convert.
* @param[in] path The path to the resource.
* @param[in] fp File Pointer. Closed on exit.
+ * @param[in] client The component that is initiating the conversion.
* @param[out] bitmap Pointer to write bitmap to
* @return true on success, false on failure
*/
bool ConvertStreamToBitmap( const Integration::ResourceType& resourceType,
std::string path,
FILE * const fp,
+ const ResourceLoadingClient& client,
Integration::BitmapPtr& ptr );
}; // class ResourceThreadImage